[SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

Kai-Heng Feng
BugLink: https://bugs.launchpad.net/bugs/1847063

[Impact]
If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
under the following steps:
1. Connect to a Dell dock
2. Suspend the system
3. Re-plug the dock
4. Resume the system
5. Ethernet stops working

[Fix]
The USB port lose its power when the dock gets replugged, so we need to
re-write the MAC address at reset_resume callback.

[Test]
The fix is succesfully tested on Dell WD15 dock and TB16 dock.

[Regression Potential]
Low. The fix limits to one single device and only take affect when MAC
passthrough is enabled.

Kai-Heng Feng (1):
  r8152: Set macpassthru in reset_resume callback

Mario Limonciello (2):
  r8152: remove extra action copying ethernet address
  r8152: Refresh MAC address during USBDEVFS_RESET

 drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 18 deletions(-)

--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[B/D/E/OEM-B/OEM-OSP1-B] [PATCH 1/3] r8152: remove extra action copying ethernet address

Kai-Heng Feng
From: Mario Limonciello <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1847063

This already happens later on in `rtl8152_set_mac_address`

Signed-off-by: Mario Limonciello <[hidden email]>
Signed-off-by: David S. Miller <[hidden email]>
(cherry picked from commit 78fdde30d4bd3175f77bcdfc1bb18f96e3dedef0)
Signed-off-by: Kai-Heng Feng <[hidden email]>
---
 drivers/net/usb/r8152.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ada7efe926e7..ba11cc7dad04 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1212,7 +1212,6 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
  goto amacout;
  }
  memcpy(sa->sa_data, buf, 6);
- ether_addr_copy(tp->netdev->dev_addr, sa->sa_data);
  netif_info(tp, probe, tp->netdev,
    "Using pass-thru MAC addr %pM\n", sa->sa_data);
 
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[B/OEM-B] [PATCH 2/3] r8152: Refresh MAC address during USBDEVFS_RESET

Kai-Heng Feng
In reply to this post by Kai-Heng Feng
From: Mario Limonciello <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1847063

On some platforms it is possible to dynamically change the policy
of what MAC address is selected from the ASL at runtime.

These tools will reset the USB device and expect the change to be
made immediately.

Signed-off-by: Mario Limonciello <[hidden email]>
Signed-off-by: David S. Miller <[hidden email]>
(backported from commit 25766271e42f6b15b72ba156cb42a3fea91b5b21)
Signed-off-by: Kai-Heng Feng <[hidden email]>
---
 drivers/net/usb/r8152.c | 50 ++++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 15 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 460ff22f21dd..566555cb12dc 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1223,43 +1223,55 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
  return ret;
 }
 
-static int set_ethernet_addr(struct r8152 *tp)
+static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
 {
  struct net_device *dev = tp->netdev;
- struct sockaddr sa;
  int ret;
 
  if (tp->version == RTL_VER_01) {
- ret = pla_ocp_read(tp, PLA_IDR, 8, sa.sa_data);
+ ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
  } else {
  /* if device doesn't support MAC pass through this will
  * be expected to be non-zero
  */
- ret = vendor_mac_passthru_addr_read(tp, &sa);
+ ret = vendor_mac_passthru_addr_read(tp, sa);
  if (ret < 0)
- ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa.sa_data);
+ ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa->sa_data);
  }
 
  if (ret < 0) {
  netif_err(tp, probe, dev, "Get ether addr fail\n");
- } else if (!is_valid_ether_addr(sa.sa_data)) {
+ } else if (!is_valid_ether_addr(sa->sa_data)) {
  netif_err(tp, probe, dev, "Invalid ether addr %pM\n",
-  sa.sa_data);
+  sa->sa_data);
  eth_hw_addr_random(dev);
- ether_addr_copy(sa.sa_data, dev->dev_addr);
- ret = rtl8152_set_mac_address(dev, &sa);
+ ether_addr_copy(sa->sa_data, dev->dev_addr);
  netif_info(tp, probe, dev, "Random ether addr %pM\n",
-   sa.sa_data);
- } else {
- if (tp->version == RTL_VER_01)
- ether_addr_copy(dev->dev_addr, sa.sa_data);
- else
- ret = rtl8152_set_mac_address(dev, &sa);
+   sa->sa_data);
+ return 0;
  }
 
  return ret;
 }
 
+static int set_ethernet_addr(struct r8152 *tp)
+{
+ struct net_device *dev = tp->netdev;
+ struct sockaddr sa;
+ int ret;
+
+ ret = determine_ethernet_addr(tp, &sa);
+ if (ret < 0)
+ return ret;
+
+ if (tp->version == RTL_VER_01)
+ ether_addr_copy(dev->dev_addr, sa.sa_data);
+ else
+ ret = rtl8152_set_mac_address(dev, &sa);
+
+ return ret;
+}
+
 static void read_bulk_callback(struct urb *urb)
 {
  struct net_device *netdev;
@@ -4263,10 +4275,18 @@ static int rtl8152_post_reset(struct usb_interface *intf)
 {
  struct r8152 *tp = usb_get_intfdata(intf);
  struct net_device *netdev;
+ struct sockaddr sa;
 
  if (!tp)
  return 0;
 
+ /* reset the MAC adddress in case of policy change */
+ if (determine_ethernet_addr(tp, &sa) >= 0) {
+ rtnl_lock();
+ dev_set_mac_address (tp->netdev, &sa);
+ rtnl_unlock();
+ }
+
  netdev = tp->netdev;
  if (!netif_running(netdev))
  return 0;
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[D/E/OEM-OSP1-B] [PATCH 2/3] r8152: Refresh MAC address during USBDEVFS_RESET

Kai-Heng Feng
In reply to this post by Kai-Heng Feng
From: Mario Limonciello <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1847063

On some platforms it is possible to dynamically change the policy
of what MAC address is selected from the ASL at runtime.

These tools will reset the USB device and expect the change to be
made immediately.

Signed-off-by: Mario Limonciello <[hidden email]>
Signed-off-by: David S. Miller <[hidden email]>
(cherry picked from commit 25766271e42f6b15b72ba156cb42a3fea91b5b21)
Signed-off-by: Kai-Heng Feng <[hidden email]>
---
 drivers/net/usb/r8152.c | 50 ++++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 15 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ba11cc7dad04..9193f845095f 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1220,43 +1220,55 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
  return ret;
 }
 
-static int set_ethernet_addr(struct r8152 *tp)
+static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
 {
  struct net_device *dev = tp->netdev;
- struct sockaddr sa;
  int ret;
 
  if (tp->version == RTL_VER_01) {
- ret = pla_ocp_read(tp, PLA_IDR, 8, sa.sa_data);
+ ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
  } else {
  /* if device doesn't support MAC pass through this will
  * be expected to be non-zero
  */
- ret = vendor_mac_passthru_addr_read(tp, &sa);
+ ret = vendor_mac_passthru_addr_read(tp, sa);
  if (ret < 0)
- ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa.sa_data);
+ ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa->sa_data);
  }
 
  if (ret < 0) {
  netif_err(tp, probe, dev, "Get ether addr fail\n");
- } else if (!is_valid_ether_addr(sa.sa_data)) {
+ } else if (!is_valid_ether_addr(sa->sa_data)) {
  netif_err(tp, probe, dev, "Invalid ether addr %pM\n",
-  sa.sa_data);
+  sa->sa_data);
  eth_hw_addr_random(dev);
- ether_addr_copy(sa.sa_data, dev->dev_addr);
- ret = rtl8152_set_mac_address(dev, &sa);
+ ether_addr_copy(sa->sa_data, dev->dev_addr);
  netif_info(tp, probe, dev, "Random ether addr %pM\n",
-   sa.sa_data);
- } else {
- if (tp->version == RTL_VER_01)
- ether_addr_copy(dev->dev_addr, sa.sa_data);
- else
- ret = rtl8152_set_mac_address(dev, &sa);
+   sa->sa_data);
+ return 0;
  }
 
  return ret;
 }
 
+static int set_ethernet_addr(struct r8152 *tp)
+{
+ struct net_device *dev = tp->netdev;
+ struct sockaddr sa;
+ int ret;
+
+ ret = determine_ethernet_addr(tp, &sa);
+ if (ret < 0)
+ return ret;
+
+ if (tp->version == RTL_VER_01)
+ ether_addr_copy(dev->dev_addr, sa.sa_data);
+ else
+ ret = rtl8152_set_mac_address(dev, &sa);
+
+ return ret;
+}
+
 static void read_bulk_callback(struct urb *urb)
 {
  struct net_device *netdev;
@@ -4262,10 +4274,18 @@ static int rtl8152_post_reset(struct usb_interface *intf)
 {
  struct r8152 *tp = usb_get_intfdata(intf);
  struct net_device *netdev;
+ struct sockaddr sa;
 
  if (!tp)
  return 0;
 
+ /* reset the MAC adddress in case of policy change */
+ if (determine_ethernet_addr(tp, &sa) >= 0) {
+ rtnl_lock();
+ dev_set_mac_address (tp->netdev, &sa, NULL);
+ rtnl_unlock();
+ }
+
  netdev = tp->netdev;
  if (!netif_running(netdev))
  return 0;
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[B/D/E/OEM-B/OEM-OSP1-B] [PATCH 3/3] r8152: Set macpassthru in reset_resume callback

Kai-Heng Feng
In reply to this post by Kai-Heng Feng
BugLink: https://bugs.launchpad.net/bugs/1847063

r8152 may fail to establish network connection after resume from system
suspend.

If the USB port connects to r8152 lost its power during system suspend,
the MAC address was written before is lost. The reason is that The MAC
address doesn't get written again in its reset_resume callback.

So let's set MAC address again in reset_resume callback. Also remove
unnecessary lock as no other locking attempt will happen during
reset_resume.

Signed-off-by: Kai-Heng Feng <[hidden email]>
Signed-off-by: David S. Miller <[hidden email]>
(cherry picked from commit a54cdeeb04fc719e4c7f19d6e28dba7ea86cee5b)
Signed-off-by: Kai-Heng Feng <[hidden email]>
---
 drivers/net/usb/r8152.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 9193f845095f..e6fd644a6110 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -4501,10 +4501,9 @@ static int rtl8152_reset_resume(struct usb_interface *intf)
  struct r8152 *tp = usb_get_intfdata(intf);
 
  clear_bit(SELECTIVE_SUSPEND, &tp->flags);
- mutex_lock(&tp->control);
  tp->rtl_ops.init(tp);
  queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
- mutex_unlock(&tp->control);
+ set_ethernet_addr(tp);
  return rtl8152_resume(intf);
 }
 
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

Stefan Bader-2
In reply to this post by Kai-Heng Feng
On 07.10.19 12:45, Kai-Heng Feng wrote:

> BugLink: https://bugs.launchpad.net/bugs/1847063
>
> [Impact]
> If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
> under the following steps:
> 1. Connect to a Dell dock
> 2. Suspend the system
> 3. Re-plug the dock
> 4. Resume the system
> 5. Ethernet stops working
>
> [Fix]
> The USB port lose its power when the dock gets replugged, so we need to
> re-write the MAC address at reset_resume callback.
>
> [Test]
> The fix is succesfully tested on Dell WD15 dock and TB16 dock.
>
> [Regression Potential]
> Low. The fix limits to one single device and only take affect when MAC
> passthrough is enabled.
>
> Kai-Heng Feng (1):
>   r8152: Set macpassthru in reset_resume callback
>
> Mario Limonciello (2):
>   r8152: remove extra action copying ethernet address
>   r8152: Refresh MAC address during USBDEVFS_RESET
>
>  drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 18 deletions(-)
>
Fixes a specific issue and is testable (limited to specific HW, too).

Acked-by: Stefan Bader <[hidden email]>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

You-Sheng Yang
In reply to this post by Kai-Heng Feng
Acked-by: You-Sheng Yang <[hidden email]>

On 2019-10-07 18:45, Kai-Heng Feng wrote:

> BugLink: https://bugs.launchpad.net/bugs/1847063
>
> [Impact]
> If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
> under the following steps:
> 1. Connect to a Dell dock
> 2. Suspend the system
> 3. Re-plug the dock
> 4. Resume the system
> 5. Ethernet stops working
>
> [Fix]
> The USB port lose its power when the dock gets replugged, so we need to
> re-write the MAC address at reset_resume callback.
>
> [Test]
> The fix is succesfully tested on Dell WD15 dock and TB16 dock.
>
> [Regression Potential]
> Low. The fix limits to one single device and only take affect when MAC
> passthrough is enabled.
>
> Kai-Heng Feng (1):
>   r8152: Set macpassthru in reset_resume callback
>
> Mario Limonciello (2):
>   r8152: remove extra action copying ethernet address
>   r8152: Refresh MAC address during USBDEVFS_RESET
>
>  drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 18 deletions(-)
>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

APPLIED [OEM-OSP1-B] Re: [SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

Timo Aaltonen-6
In reply to this post by Kai-Heng Feng
On 7.10.2019 13.45, Kai-Heng Feng wrote:

> BugLink: https://bugs.launchpad.net/bugs/1847063
>
> [Impact]
> If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
> under the following steps:
> 1. Connect to a Dell dock
> 2. Suspend the system
> 3. Re-plug the dock
> 4. Resume the system
> 5. Ethernet stops working
>
> [Fix]
> The USB port lose its power when the dock gets replugged, so we need to
> re-write the MAC address at reset_resume callback.
>
> [Test]
> The fix is succesfully tested on Dell WD15 dock and TB16 dock.
>
> [Regression Potential]
> Low. The fix limits to one single device and only take affect when MAC
> passthrough is enabled.
>
> Kai-Heng Feng (1):
>   r8152: Set macpassthru in reset_resume callback
>
> Mario Limonciello (2):
>   r8152: remove extra action copying ethernet address
>   r8152: Refresh MAC address during USBDEVFS_RESET
>
>  drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 18 deletions(-)
>

Applied to osp1 oem-next, thanks

--
t

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK/Cmnt: [SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

Connor Kuehl
In reply to this post by Kai-Heng Feng
On 10/7/19 3:45 AM, Kai-Heng Feng wrote:

> BugLink: https://bugs.launchpad.net/bugs/1847063
>
> [Impact]
> If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
> under the following steps:
> 1. Connect to a Dell dock
> 2. Suspend the system
> 3. Re-plug the dock
> 4. Resume the system
> 5. Ethernet stops working
>
> [Fix]
> The USB port lose its power when the dock gets replugged, so we need to
> re-write the MAC address at reset_resume callback.
>
> [Test]
> The fix is succesfully tested on Dell WD15 dock and TB16 dock.
>
> [Regression Potential]
> Low. The fix limits to one single device and only take affect when MAC
> passthrough is enabled.
>
> Kai-Heng Feng (1):
>    r8152: Set macpassthru in reset_resume callback
>
> Mario Limonciello (2):
>    r8152: remove extra action copying ethernet address
>    r8152: Refresh MAC address during USBDEVFS_RESET
>
>   drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
>   1 file changed, 36 insertions(+), 18 deletions(-)
>

Apologies if I missed it, but I suspect the backport line in "[B/OEM-B]
[PATCH 2/3] r8152: Refresh MAC address during USBDEVFS_RESET" was just
an offset/context adjustment, right?

Acked-by: Connor Kuehl <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED [OEM-B] Re: [SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

Timo Aaltonen-6
In reply to this post by Kai-Heng Feng
On 7.10.2019 13.45, Kai-Heng Feng wrote:

> BugLink: https://bugs.launchpad.net/bugs/1847063
>
> [Impact]
> If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
> under the following steps:
> 1. Connect to a Dell dock
> 2. Suspend the system
> 3. Re-plug the dock
> 4. Resume the system
> 5. Ethernet stops working
>
> [Fix]
> The USB port lose its power when the dock gets replugged, so we need to
> re-write the MAC address at reset_resume callback.
>
> [Test]
> The fix is succesfully tested on Dell WD15 dock and TB16 dock.
>
> [Regression Potential]
> Low. The fix limits to one single device and only take affect when MAC
> passthrough is enabled.
>
> Kai-Heng Feng (1):
>   r8152: Set macpassthru in reset_resume callback
>
> Mario Limonciello (2):
>   r8152: remove extra action copying ethernet address
>   r8152: Refresh MAC address during USBDEVFS_RESET
>
>  drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 18 deletions(-)

since we-re re-spinning; applied to oem-next


--
t

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED[B/D/E]/cmnt: [SRU] [B/D/E/OEM-B/OEM-OSP1-B] [PATCH 0/3] Fix non-working Realtek USB ethernet after system resume

Kleber Souza
In reply to this post by Kai-Heng Feng
On 07.10.19 12:45, Kai-Heng Feng wrote:

> BugLink: https://bugs.launchpad.net/bugs/1847063
>
> [Impact]
> If mac passthrough is enbled, Realtek USB ethernet (r8152) doesn't work
> under the following steps:
> 1. Connect to a Dell dock
> 2. Suspend the system
> 3. Re-plug the dock
> 4. Resume the system
> 5. Ethernet stops working
>
> [Fix]
> The USB port lose its power when the dock gets replugged, so we need to
> re-write the MAC address at reset_resume callback.
>
> [Test]
> The fix is succesfully tested on Dell WD15 dock and TB16 dock.
>
> [Regression Potential]
> Low. The fix limits to one single device and only take affect when MAC
> passthrough is enabled.
>
> Kai-Heng Feng (1):
>   r8152: Set macpassthru in reset_resume callback
>
> Mario Limonciello (2):
>   r8152: remove extra action copying ethernet address
>   r8152: Refresh MAC address during USBDEVFS_RESET
>
>  drivers/net/usb/r8152.c | 54 +++++++++++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 18 deletions(-)
>

Applied to bionic, disco and eoan master-next branches.

Patches 1/3 and 2/3 was already applied to Eoan, so I applied
only patch 3/3.


Thanks,
Kleber

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team