* [PATCH net v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops
2023-11-29 21:25 [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset Douglas Anderson
@ 2023-11-29 21:25 ` Douglas Anderson
2023-11-30 8:27 ` Hayes Wang
2023-11-29 21:25 ` [PATCH net v3 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() Douglas Anderson
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Douglas Anderson @ 2023-11-29 21:25 UTC (permalink / raw)
To: Jakub Kicinski, Hayes Wang, David S . Miller
Cc: linux-usb, Grant Grundler, Laura Nao, Edward Hill, Alan Stern,
Simon Horman, Douglas Anderson, Bjørn Mork, Eric Dumazet,
Paolo Abeni, linux-kernel, netdev
Previous commits added checks for RTL8152_INACCESSIBLE in the loops in
the driver. There are still a few more that keep tripping the driver
up in error cases and make things take longer than they should. Add
those in.
All the loops that are part of this commit existed in some form or
another since the r8152 driver was first introduced, though
RTL8152_INACCESSIBLE was known as RTL8152_UNPLUG before commit
715f67f33af4 ("r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE")
Fixes: ac718b69301c ("net/usb: new driver for RTL8152")
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
Changes in v3:
- Use `break` when we see RTL8152_INACCESSIBLE, not `return`.
Changes in v2:
- Added Fixes tag to RTL8152_INACCESSIBLE patches.
- Split RTL8152_INACCESSIBLE patches by the commit the loop came from.
drivers/net/usb/r8152.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index d6edf0254599..e9955701f455 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3000,6 +3000,8 @@ static void rtl8152_nic_reset(struct r8152 *tp)
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, CR_RST);
for (i = 0; i < 1000; i++) {
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ break;
if (!(ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR) & CR_RST))
break;
usleep_range(100, 400);
@@ -3329,6 +3331,8 @@ static void rtl_disable(struct r8152 *tp)
rxdy_gated_en(tp, true);
for (i = 0; i < 1000; i++) {
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ break;
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
if ((ocp_data & FIFO_EMPTY) == FIFO_EMPTY)
break;
@@ -3336,6 +3340,8 @@ static void rtl_disable(struct r8152 *tp)
}
for (i = 0; i < 1000; i++) {
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ break;
if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0) & TCR0_TX_EMPTY)
break;
usleep_range(1000, 2000);
@@ -5499,6 +5505,8 @@ static void wait_oob_link_list_ready(struct r8152 *tp)
int i;
for (i = 0; i < 1000; i++) {
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ break;
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
if (ocp_data & LINK_LIST_READY)
break;
--
2.43.0.rc1.413.gea7ed67945-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* RE: [PATCH net v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops
2023-11-29 21:25 ` [PATCH net v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops Douglas Anderson
@ 2023-11-30 8:27 ` Hayes Wang
0 siblings, 0 replies; 10+ messages in thread
From: Hayes Wang @ 2023-11-30 8:27 UTC (permalink / raw)
To: Douglas Anderson, Jakub Kicinski, David S . Miller
Cc: linux-usb@vger.kernel.org, Grant Grundler, Laura Nao, Edward Hill,
Alan Stern, Simon Horman, Bjørn Mork, Eric Dumazet,
Paolo Abeni, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Douglas Anderson <dianders@chromium.org>
[...]
>
> Previous commits added checks for RTL8152_INACCESSIBLE in the loops in
> the driver. There are still a few more that keep tripping the driver
> up in error cases and make things take longer than they should. Add
> those in.
>
> All the loops that are part of this commit existed in some form or
> another since the r8152 driver was first introduced, though
> RTL8152_INACCESSIBLE was known as RTL8152_UNPLUG before commit
> 715f67f33af4 ("r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE")
>
> Fixes: ac718b69301c ("net/usb: new driver for RTL8152")
> Reviewed-by: Grant Grundler <grundler@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Hayes Wang <hayeswang@realtek.com>
Best Regards,
Hayes
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v3 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash()
2023-11-29 21:25 [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset Douglas Anderson
2023-11-29 21:25 ` [PATCH net v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops Douglas Anderson
@ 2023-11-29 21:25 ` Douglas Anderson
2023-11-30 8:27 ` Hayes Wang
2023-11-29 21:25 ` [PATCH net v3 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1() Douglas Anderson
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Douglas Anderson @ 2023-11-29 21:25 UTC (permalink / raw)
To: Jakub Kicinski, Hayes Wang, David S . Miller
Cc: linux-usb, Grant Grundler, Laura Nao, Edward Hill, Alan Stern,
Simon Horman, Douglas Anderson, Bjørn Mork, Eric Dumazet,
Paolo Abeni, linux-kernel, netdev
Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
so that they don't delay too long if the device becomes
inaccessible. Add the break to the loop in
r8156b_wait_loading_flash().
Fixes: 195aae321c82 ("r8152: support new chips")
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
Changes in v3:
- Use `break` when we see RTL8152_INACCESSIBLE, not `return`.
Changes in v2:
- Added Fixes tag to RTL8152_INACCESSIBLE patches.
- Split RTL8152_INACCESSIBLE patches by the commit the loop came from.
drivers/net/usb/r8152.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e9955701f455..c4dd81e2421f 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -5521,6 +5521,8 @@ static void r8156b_wait_loading_flash(struct r8152 *tp)
int i;
for (i = 0; i < 100; i++) {
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ break;
if (ocp_read_word(tp, MCU_TYPE_USB, USB_GPHY_CTRL) & GPHY_PATCH_DONE)
break;
usleep_range(1000, 2000);
--
2.43.0.rc1.413.gea7ed67945-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* RE: [PATCH net v3 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash()
2023-11-29 21:25 ` [PATCH net v3 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() Douglas Anderson
@ 2023-11-30 8:27 ` Hayes Wang
0 siblings, 0 replies; 10+ messages in thread
From: Hayes Wang @ 2023-11-30 8:27 UTC (permalink / raw)
To: Douglas Anderson, Jakub Kicinski, David S . Miller
Cc: linux-usb@vger.kernel.org, Grant Grundler, Laura Nao, Edward Hill,
Alan Stern, Simon Horman, Bjørn Mork, Eric Dumazet,
Paolo Abeni, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Douglas Anderson <dianders@chromium.org>
> Sent: Thursday, November 30, 2023 5:25 AM
[...]
>
> Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
> so that they don't delay too long if the device becomes
> inaccessible. Add the break to the loop in
> r8156b_wait_loading_flash().
>
> Fixes: 195aae321c82 ("r8152: support new chips")
> Reviewed-by: Grant Grundler <grundler@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Hayes Wang <hayeswang@realtek.com>
Best Regards,
Hayes
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v3 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1()
2023-11-29 21:25 [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset Douglas Anderson
2023-11-29 21:25 ` [PATCH net v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops Douglas Anderson
2023-11-29 21:25 ` [PATCH net v3 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() Douglas Anderson
@ 2023-11-29 21:25 ` Douglas Anderson
2023-11-30 8:27 ` Hayes Wang
2023-11-29 21:25 ` [PATCH net v3 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en() Douglas Anderson
2023-12-04 12:30 ` [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset patchwork-bot+netdevbpf
4 siblings, 1 reply; 10+ messages in thread
From: Douglas Anderson @ 2023-11-29 21:25 UTC (permalink / raw)
To: Jakub Kicinski, Hayes Wang, David S . Miller
Cc: linux-usb, Grant Grundler, Laura Nao, Edward Hill, Alan Stern,
Simon Horman, Douglas Anderson, Bjørn Mork, Eric Dumazet,
Paolo Abeni, Prashant Malani, linux-kernel, netdev
Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
so that they don't delay too long if the device becomes
inaccessible. Add the break to the loop in r8153_pre_firmware_1().
Fixes: 9370f2d05a2a ("r8152: support request_firmware for RTL8153")
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
(no changes since v2)
Changes in v2:
- Added Fixes tag to RTL8152_INACCESSIBLE patches.
- Split RTL8152_INACCESSIBLE patches by the commit the loop came from.
drivers/net/usb/r8152.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index c4dd81e2421f..3958eb622d47 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -5645,6 +5645,8 @@ static int r8153_pre_firmware_1(struct r8152 *tp)
for (i = 0; i < 104; i++) {
u32 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_WDT1_CTRL);
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ return -ENODEV;
if (!(ocp_data & WTD1_EN))
break;
usleep_range(1000, 2000);
--
2.43.0.rc1.413.gea7ed67945-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* RE: [PATCH net v3 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1()
2023-11-29 21:25 ` [PATCH net v3 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1() Douglas Anderson
@ 2023-11-30 8:27 ` Hayes Wang
0 siblings, 0 replies; 10+ messages in thread
From: Hayes Wang @ 2023-11-30 8:27 UTC (permalink / raw)
To: Douglas Anderson, Jakub Kicinski, David S . Miller
Cc: linux-usb@vger.kernel.org, Grant Grundler, Laura Nao, Edward Hill,
Alan Stern, Simon Horman, Bjørn Mork, Eric Dumazet,
Paolo Abeni, Prashant Malani, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Douglas Anderson <dianders@chromium.org>
> Sent: Thursday, November 30, 2023 5:25 AM
[...]
>
> Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
> so that they don't delay too long if the device becomes
> inaccessible. Add the break to the loop in r8153_pre_firmware_1().
>
> Fixes: 9370f2d05a2a ("r8152: support request_firmware for RTL8153")
> Reviewed-by: Grant Grundler <grundler@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Hayes Wang <hayeswang@realtek.com>
Best Regards,
Hayes
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v3 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en()
2023-11-29 21:25 [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset Douglas Anderson
` (2 preceding siblings ...)
2023-11-29 21:25 ` [PATCH net v3 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1() Douglas Anderson
@ 2023-11-29 21:25 ` Douglas Anderson
2023-11-30 8:27 ` Hayes Wang
2023-12-04 12:30 ` [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset patchwork-bot+netdevbpf
4 siblings, 1 reply; 10+ messages in thread
From: Douglas Anderson @ 2023-11-29 21:25 UTC (permalink / raw)
To: Jakub Kicinski, Hayes Wang, David S . Miller
Cc: linux-usb, Grant Grundler, Laura Nao, Edward Hill, Alan Stern,
Simon Horman, Douglas Anderson, Bjørn Mork, Eric Dumazet,
Paolo Abeni, linux-kernel, netdev
Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
so that they don't delay too long if the device becomes
inaccessible. Add the break to the loop in r8153_aldps_en().
Fixes: 4214cc550bf9 ("r8152: check if disabling ALDPS is finished")
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
(no changes since v2)
Changes in v2:
- Added Fixes tag to RTL8152_INACCESSIBLE patches.
- Split RTL8152_INACCESSIBLE patches by the commit the loop came from.
drivers/net/usb/r8152.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 3958eb622d47..fcdc9ba0f826 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -5803,6 +5803,8 @@ static void r8153_aldps_en(struct r8152 *tp, bool enable)
data &= ~EN_ALDPS;
ocp_reg_write(tp, OCP_POWER_CFG, data);
for (i = 0; i < 20; i++) {
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+ return;
usleep_range(1000, 2000);
if (ocp_read_word(tp, MCU_TYPE_PLA, 0xe000) & 0x0100)
break;
--
2.43.0.rc1.413.gea7ed67945-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* RE: [PATCH net v3 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en()
2023-11-29 21:25 ` [PATCH net v3 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en() Douglas Anderson
@ 2023-11-30 8:27 ` Hayes Wang
0 siblings, 0 replies; 10+ messages in thread
From: Hayes Wang @ 2023-11-30 8:27 UTC (permalink / raw)
To: Douglas Anderson, Jakub Kicinski, David S . Miller
Cc: linux-usb@vger.kernel.org, Grant Grundler, Laura Nao, Edward Hill,
Alan Stern, Simon Horman, Bjørn Mork, Eric Dumazet,
Paolo Abeni, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Douglas Anderson <dianders@chromium.org>
> Sent: Thursday, November 30, 2023 5:25 AM
[...]
>
> Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
> so that they don't delay too long if the device becomes
> inaccessible. Add the break to the loop in r8153_aldps_en().
>
> Fixes: 4214cc550bf9 ("r8152: check if disabling ALDPS is finished")
> Reviewed-by: Grant Grundler <grundler@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Hayes Wang <hayeswang@realtek.com>
Best Regards,
Hayes
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset
2023-11-29 21:25 [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset Douglas Anderson
` (3 preceding siblings ...)
2023-11-29 21:25 ` [PATCH net v3 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en() Douglas Anderson
@ 2023-12-04 12:30 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-12-04 12:30 UTC (permalink / raw)
To: Doug Anderson
Cc: kuba, hayeswang, davem, linux-usb, grundler, laura.nao, ecgh,
stern, horms, bjorn, edumazet, pabeni, linux-kernel, netdev
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Wed, 29 Nov 2023 13:25:20 -0800 you wrote:
> As of commit d9962b0d4202 ("r8152: Block future register access if
> register access fails") there is a race condition that can happen
> between the USB device reset thread and napi_enable() (not) getting
> called during rtl8152_open(). Specifically:
> * While rtl8152_open() is running we get a register access error
> that's _not_ -ENODEV and queue up a USB reset.
> * rtl8152_open() exits before calling napi_enable() due to any reason
> (including usb_submit_urb() returning an error).
>
> [...]
Here is the summary with links:
- [net,v3,1/5] r8152: Hold the rtnl_lock for all of reset
https://git.kernel.org/netdev/net/c/e62adaeecdc6
- [net,v3,2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops
https://git.kernel.org/netdev/net/c/32a574c7e268
- [net,v3,3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash()
https://git.kernel.org/netdev/net/c/8a67b47fced9
- [net,v3,4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1()
https://git.kernel.org/netdev/net/c/8c53a7bd7065
- [net,v3,5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en()
https://git.kernel.org/netdev/net/c/79321a793945
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 10+ messages in thread