From: Paolo Abeni <pabeni@redhat.com>
To: jiawenwu@trustnetic.com
Cc: kees@kernel.org, michal.swiatkowski@linux.intel.com,
kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
richardcochran@gmail.com, mengyuanlou@net-swift.com,
jacob.e.keller@intel.com, joe@dama.to, linux@armlinux.org.uk,
abdun.nihaal@gmail.com, edumazet@google.com, horms@kernel.org,
davem@davemloft.net, larysa.zaremba@intel.com,
netdev@vger.kernel.org, leitao@debian.org
Subject: Re: [net-next,v4,10/10] net: wangxun: implement pci_error_handlers ops
Date: Tue, 10 Mar 2026 11:51:41 +0100 [thread overview]
Message-ID: <20260310105141.167206-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260306063211.20536-11-jiawenwu@trustnetic.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: wangxun: implement pci_error_handlers ops
This commit adds PCIe AER error handling support by implementing
pci_error_handlers operations. The implementation includes error
detection, slot reset, and resume callbacks with device state tracking.
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_err.c b/drivers/net/ethernet/wangxun/libwx/wx_err.c
> index bb77bdce69d2..86b318647a3c 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_err.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_err.c
[ ... ]
> +static pci_ers_result_t wx_io_slot_reset(struct pci_dev *pdev)
> +{
> + struct wx *wx = pci_get_drvdata(pdev);
> + pci_ers_result_t result;
> +
> + if (pci_enable_device_mem(pdev)) {
> + wx_err(wx, "Cannot re-enable PCI device after reset.\n");
> + result = PCI_ERS_RESULT_DISCONNECT;
> + } else {
> + /* make all bar access done before reset. */
> + smp_mb__before_atomic();
> + clear_bit(WX_STATE_DISABLED, wx->state);
> + pci_set_master(pdev);
> + pci_restore_state(pdev);
> + pci_save_state(pdev);
> + pci_wake_from_d3(pdev, false);
> +
> + wx->do_reset(wx->netdev, false);
> + result = PCI_ERS_RESULT_RECOVERED;
> + }
> +
> + pci_aer_clear_nonfatal_status(pdev);
> +
> + return result;
> +}
[ ... ]
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 5a21478a592b..1cd73b424d7f 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> @@ -3418,7 +3418,8 @@ static void wx_dev_shutdown(struct pci_dev *pdev, bool *enable_wake)
> *enable_wake = !!wufc;
> wx_control_hw(wx, false);
>
> - pci_disable_device(pdev);
> + if (!test_and_set_bit(WX_STATE_DISABLED, wx->state))
> + pci_disable_device(pdev);
> }
>
> int wx_suspend(struct pci_dev *pdev, pm_message_t state)
Does this code correctly handle the WX_STATE_DISABLED bit across suspend/resume
cycles?
The AER recovery path clears this bit in wx_io_slot_reset():
wx_err.c:wx_io_slot_reset() {
...
clear_bit(WX_STATE_DISABLED, wx->state);
...
}
But the normal PM resume path doesn't clear it. Looking at wx_resume() in
wx_lib.c (lines 3436-3464), after calling pci_enable_device_mem()
successfully, the WX_STATE_DISABLED bit remains set from the earlier
suspend.
This means after a suspend/resume cycle:
1. wx_suspend() calls wx_dev_shutdown() which sets WX_STATE_DISABLED
2. wx_resume() calls pci_enable_device_mem() but doesn't clear the bit
3. A subsequent wx_dev_shutdown() (from second suspend or shutdown) will see
the bit already set and skip pci_disable_device(), leaving the device
enabled
The same stale bit affects ngbe_remove() and txgbe_remove(), which would skip
pci_disable_device() if the device was previously suspended and resumed.
Should wx_resume() clear WX_STATE_DISABLED after successfully enabling the
device, matching the pattern in wx_io_slot_reset()?
prev parent reply other threads:[~2026-03-10 10:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 6:32 [PATCH net-next v4 00/10] Wangxun improvement and new support Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 01/10] net: ngbe: remove netdev->ethtool->wol_enabled setting Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 02/10] net: ngbe: move the WOL functions to libwx Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 03/10] net: ngbe: remove redundant macros Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 04/10] net: ngbe: improve the reset flow Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 05/10] net: wangxun: move reusable PCI driver ops functions into libwx Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 06/10] net: txgbe: add power management support Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 07/10] net: wangxun: move ethtool_ops.set_channels into libwx Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 08/10] net: wangxun: delete service_timer before cancel service_work Jiawen Wu
2026-03-06 6:32 ` [PATCH net-next v4 09/10] net: wangxun: add Tx timeout process Jiawen Wu
2026-03-10 10:51 ` [net-next,v4,09/10] " Paolo Abeni
2026-03-06 6:32 ` [PATCH net-next v4 10/10] net: wangxun: implement pci_error_handlers ops Jiawen Wu
2026-03-10 10:51 ` Paolo Abeni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260310105141.167206-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=abdun.nihaal@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jiawenwu@trustnetic.com \
--cc=joe@dama.to \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=leitao@debian.org \
--cc=linux@armlinux.org.uk \
--cc=mengyuanlou@net-swift.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox