-
Notifications
You must be signed in to change notification settings - Fork 216
tg3: add napi_enabled flag to track napi_enable/napi_disable calls #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| From 821f6d79ad2773e0ff1537c0bb3c7af93a694709 Mon Sep 17 00:00:00 2001 | ||
| From: Yury Murashka <yurypm@arista.com> | ||
| Date: Thu, 8 May 2026 00:00:00 +0000 | ||
| Subject: tg3: guard napi_disable and pci_disable_device calls | ||
|
|
||
| Add a napi_enabled flag to struct tg3 to track whether napi_enable has | ||
| been called. Guard tg3_napi_disable() against being called before | ||
| tg3_napi_enable(), logging an error if that happens. Also guard | ||
| pci_disable_device() calls in tg3_remove_one() and tg3_shutdown() with | ||
| pci_is_enabled() to avoid disabling an already-disabled device. | ||
|
|
||
| Signed-off-by: Yury Murashka <yurypm@arista.com> | ||
| --- | ||
| drivers/net/ethernet/broadcom/tg3.c | 19 +++++++++++++++++-- | ||
| drivers/net/ethernet/broadcom/tg3.h | 1 + | ||
| 2 files changed, 18 insertions(+), 2 deletions(-) | ||
|
|
||
| diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c | ||
| index 52adda7..63f8f44 100644 | ||
| --- a/drivers/net/ethernet/broadcom/tg3.c | ||
| +++ b/drivers/net/ethernet/broadcom/tg3.c | ||
| @@ -7432,6 +7432,17 @@ tx_recovery: | ||
| static void tg3_napi_disable(struct tg3 *tp) | ||
| { | ||
| int i; | ||
| + struct net_device *netdev = tp->dev; | ||
| + | ||
| + if (!tp->napi_enabled) { | ||
| + netdev_err(netdev, "%s() called when napi_enable wasn't " | ||
| + "called before, netif_running=%d, pci_enabled=%d\n", | ||
| + __func__, netif_running(netdev), | ||
| + pci_is_enabled(tp->pdev)); | ||
| + return; | ||
| + } | ||
| + | ||
| + tp->napi_enabled = false; | ||
|
|
||
| for (i = tp->irq_cnt - 1; i >= 0; i--) | ||
| napi_disable(&tp->napi[i].napi); | ||
| @@ -7441,6 +7452,8 @@ static void tg3_napi_enable(struct tg3 *tp) | ||
| { | ||
| int i; | ||
|
|
||
| + tp->napi_enabled = true; | ||
|
yurypm marked this conversation as resolved.
|
||
| + | ||
| for (i = 0; i < tp->irq_cnt; i++) | ||
| napi_enable(&tp->napi[i].napi); | ||
| } | ||
| @@ -17734,6 +17747,7 @@ static int tg3_init_one(struct pci_dev *pdev, | ||
| tp->tx_mode = TG3_DEF_TX_MODE; | ||
| tp->irq_sync = 1; | ||
| tp->pcierr_recovery = false; | ||
| + tp->napi_enabled = false; | ||
|
|
||
| if (tg3_debug > 0) | ||
| tp->msg_enable = tg3_debug; | ||
| @@ -18125,7 +18139,8 @@ static void tg3_remove_one(struct pci_dev *pdev) | ||
| } | ||
| free_netdev(dev); | ||
| pci_release_regions(pdev); | ||
| - pci_disable_device(pdev); | ||
| + if (pci_is_enabled(pdev)) | ||
| + pci_disable_device(pdev); | ||
| } | ||
| } | ||
|
|
||
| @@ -18281,7 +18296,8 @@ static void tg3_shutdown(struct pci_dev *pdev, | ||
|
|
||
| rtnl_unlock(); | ||
|
|
||
| - pci_disable_device(pdev); | ||
| + if (pci_is_enabled(pdev)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If an AER error is reported, recovery is started and tg3_io_error_detected is called. In tg3_io_error_detected, NAPI is disabled and pci_disable_device is called. Then, if we try to reset the device, pci_disable_device will be called again; we want to avoid this. |
||
| + pci_disable_device(pdev); | ||
| } | ||
|
|
||
| /** | ||
| diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h | ||
| index 6017b17..dbbd87b 100644 | ||
| --- a/drivers/net/ethernet/broadcom/tg3.h | ||
| +++ b/drivers/net/ethernet/broadcom/tg3.h | ||
| @@ -3430,6 +3430,7 @@ struct tg3 { | ||
| struct device *hwmon_dev; | ||
| bool link_up; | ||
| bool pcierr_recovery; | ||
| + bool napi_enabled; | ||
|
|
||
| u32 ape_hb; | ||
| unsigned long ape_hb_interval; | ||
| -- | ||
| 2.39.0 | ||
Uh oh!
There was an error while loading. Please reload this page.