diff mbox series

[net-next,v2] r8169: reset bus if NIC isn't accessible after tx timeout

Message ID 4534318d-b679-9399-e410-8aee2a9cbf58@gmail.com (mailing list archive)
State Accepted
Commit ce870af39558448dcfabef7114b9aa389f3f895a
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] r8169: reset bus if NIC isn't accessible after tx timeout | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heiner Kallweit Jan. 13, 2023, 10:46 p.m. UTC
ASPM issues may result in the NIC not being accessible any longer.
In this case disabling ASPM may not work. Therefore detect this case
by checking whether register reads return ~0, and try to make the
NIC accessible again by resetting the secondary bus.

v2:
- add exception handling for the case that pci_reset_bus() fails

Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Alexander Duyck Jan. 14, 2023, 12:24 a.m. UTC | #1
On Fri, Jan 13, 2023 at 2:46 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> ASPM issues may result in the NIC not being accessible any longer.
> In this case disabling ASPM may not work. Therefore detect this case
> by checking whether register reads return ~0, and try to make the
> NIC accessible again by resetting the secondary bus.
>
> v2:
> - add exception handling for the case that pci_reset_bus() fails
>
> Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/ethernet/realtek/r8169_main.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 49c124d8e..02ef98a95 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -4535,6 +4535,16 @@ static void rtl_task(struct work_struct *work)
>                 goto out_unlock;
>
>         if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) {
> +               /* if chip isn't accessible, reset bus to revive it */
> +               if (RTL_R32(tp, TxConfig) == ~0) {
> +                       ret = pci_reset_bus(tp->pci_dev);
> +                       if (ret < 0) {
> +                               netdev_err(tp->dev, "Can't reset secondary PCI bus, detach NIC\n");
> +                               netif_device_detach(tp->dev);
> +                               goto out_unlock;
> +                       }
> +               }
> +
>                 /* ASPM compatibility issues are a typical reason for tx timeouts */
>                 ret = pci_disable_link_state(tp->pci_dev, PCIE_LINK_STATE_L1 |
>                                                           PCIE_LINK_STATE_L0S);

Looks good to me.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
patchwork-bot+netdevbpf@kernel.org Jan. 16, 2023, 1:40 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 13 Jan 2023 23:46:19 +0100 you wrote:
> ASPM issues may result in the NIC not being accessible any longer.
> In this case disabling ASPM may not work. Therefore detect this case
> by checking whether register reads return ~0, and try to make the
> NIC accessible again by resetting the secondary bus.
> 
> v2:
> - add exception handling for the case that pci_reset_bus() fails
> 
> [...]

Here is the summary with links:
  - [net-next,v2] r8169: reset bus if NIC isn't accessible after tx timeout
    https://git.kernel.org/netdev/net-next/c/ce870af39558

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 49c124d8e..02ef98a95 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4535,6 +4535,16 @@  static void rtl_task(struct work_struct *work)
 		goto out_unlock;
 
 	if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) {
+		/* if chip isn't accessible, reset bus to revive it */
+		if (RTL_R32(tp, TxConfig) == ~0) {
+			ret = pci_reset_bus(tp->pci_dev);
+			if (ret < 0) {
+				netdev_err(tp->dev, "Can't reset secondary PCI bus, detach NIC\n");
+				netif_device_detach(tp->dev);
+				goto out_unlock;
+			}
+		}
+
 		/* ASPM compatibility issues are a typical reason for tx timeouts */
 		ret = pci_disable_link_state(tp->pci_dev, PCIE_LINK_STATE_L1 |
 							  PCIE_LINK_STATE_L0S);