Netdev List
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: jiawenwu@trustnetic.com
Cc: Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, mengyuanlou@net-swift.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com,
	linux@armlinux.org.uk, aleksandr.loktionov@intel.com,
	jacob.e.keller@intel.com, michal.swiatkowski@linux.intel.com,
	kees@kernel.org, joe@dama.to, leitao@debian.org,
	shaojijie@huawei.com, u.kleine-koenig@baylibre.com,
	weirongguang@kylinos.cn, larysa.zaremba@intel.com,
	fabio.baltieri@gmail.com
Subject: Re: [PATCH net-next v10 4/5] net: wangxun: implement soft quiesce for PCIe error recovery
Date: Tue, 14 Jul 2026 10:11:13 +0100	[thread overview]
Message-ID: <20260714091113.1815787-1-horms@kernel.org> (raw)
In-Reply-To: <20260707061455.39564-5-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.
Full review at: https://sashiko.dev
---
--- Patch [4]: [PATCH net-next v10 4/5] net: wangxun: implement soft quiesce for PCIe error recovery ---
commit 1b8a0e5e722ffb89c8fe24492e80dca44f3410f2
Author: Jiawen Wu <jiawenwu@trustnetic.com>

net: wangxun: implement soft quiesce for PCIe error recovery

This commit introduces a soft quiesce path for PCIe error recovery. It adds
WX_STATE_DOWN and WX_STATE_RESETTING state checks to subtasks to block
execution, explicitly avoiding a cancellation of the service task to speed
up recovery.

> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index c8a4822d38194..a65312c8078fa 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
[ ... ]
> @@ -3383,5 +3383,23 @@ void wx_service_timer(struct timer_list *t)
>  }
>  EXPORT_SYMBOL(wx_service_timer);
>  
> +void wx_soft_quiesce(struct wx *wx)
> +{
> +	if (!netif_running(wx->netdev) ||
> +	    test_and_set_bit(WX_STATE_DOWN, wx->state))
> +		return;
> +
> +	pci_clear_master(wx->pdev);
> +	netif_tx_stop_all_queues(wx->netdev);
> +	netif_carrier_off(wx->netdev);
> +	netif_tx_disable(wx->netdev);
> +	wx_napi_disable_all(wx);
> +	wx_ptp_quiesce(wx);
> +
> +	clear_bit(WX_FLAG_NEED_PF_RESET, wx->flags);
> +	timer_delete_sync(&wx->service_timer);

[Severity: High]
The commit message notes the service task is deliberately not cancelled here
to avoid delaying PCIe error recovery. However, does omitting
cancel_work_sync(&wx->service_task) open a race window with the subtasks
that rely on the WX_STATE_DOWN flag?

> +}
> +EXPORT_SYMBOL(wx_soft_quiesce);

> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> index a8773712cff82..a7bde03a98feb 100644
> --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
[ ... ]
> @@ -94,6 +94,10 @@ static void txgbe_module_detection_subtask(struct wx *wx)
>  {
>  	int err;
>  
> +	if (test_bit(WX_STATE_DOWN, wx->state) ||
> +	    test_bit(WX_STATE_RESETTING, wx->state))
> +		return;
> +

[Severity: High]
Does this state check adequately protect against concurrent MMIO access
during a PCIe reset?

If the task passes this check, it subsequently sleeps for 200ms:

txgbe_main.c:txgbe_module_detection_subtask() {
    ...
    if (!test_and_clear_bit(WX_FLAG_NEED_MODULE_RESET, wx->flags))
        return;

    /* wait for SFF module ready */
    msleep(200);

    err = txgbe_identify_module(wx);
    ...
}

If wx_soft_quiesce() runs on another CPU during this msleep(), it will set
WX_STATE_DOWN and begin a hardware reset. 

When the task wakes up from the sleep, will it call txgbe_identify_module()
and perform MMIO reads (such as rd32(wx, WX_GPIO_EXT)) while the device is
in reset?

Could this time-of-check to time-of-use race lead to Master Aborts or
fatal PCIe errors during AER recovery?

>  	if (!test_and_clear_bit(WX_FLAG_NEED_MODULE_RESET, wx->flags))
>  		return;

  reply	other threads:[~2026-07-14  9:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  6:14 [PATCH net-next v10 0/5] net: wangxun: timeout and error Jiawen Wu
2026-07-07  6:14 ` [PATCH net-next v10 1/5] net: ngbe: implement libwx reset ops Jiawen Wu
2026-07-07  6:14 ` [PATCH net-next v10 2/5] net: wangxun: add Tx timeout process Jiawen Wu
2026-07-07  6:14 ` [PATCH net-next v10 3/5] net: wangxun: add reinit parameter to wx->do_reset callback Jiawen Wu
2026-07-07  6:14 ` [PATCH net-next v10 4/5] net: wangxun: implement soft quiesce for PCIe error recovery Jiawen Wu
2026-07-14  9:11   ` Simon Horman [this message]
2026-07-14  9:43     ` Jiawen Wu
2026-07-07  6:14 ` [PATCH net-next v10 5/5] net: wangxun: add pcie error handler Jiawen Wu
2026-07-14  9:11   ` Simon Horman

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=20260714091113.1815787-1-horms@kernel.org \
    --to=horms@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fabio.baltieri@gmail.com \
    --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=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=shaojijie@huawei.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=weirongguang@kylinos.cn \
    /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