From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Jakub Kicinski'" <kuba@kernel.org>
Cc: <netdev@vger.kernel.org>, <mengyuanlou@net-swift.com>,
<andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<edumazet@google.com>, <pabeni@redhat.com>,
<richardcochran@gmail.com>, <linux@armlinux.org.uk>,
<horms@kernel.org>, <kees@kernel.org>, <larysa.zaremba@intel.com>,
<leitao@debian.org>, <joe@dama.to>, <jacob.e.keller@intel.com>,
<fabio.baltieri@gmail.com>, <netdev@vger.kernel.org>,
<mengyuanlou@net-swift.com>, <andrew+netdev@lunn.ch>,
<davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
<richardcochran@gmail.com>, <linux@armlinux.org.uk>,
<horms@kernel.org>, <kees@kernel.org>, <larysa.zaremba@intel.com>,
<leitao@debian.org>, <joe@dama.to>, <jacob.e.keller@intel.com>,
<fabio.baltieri@gmail.com>
Subject: RE: [PATCH net-next v2 1/6] net: ngbe: implement libwx reset ops
Date: Wed, 6 May 2026 17:05:30 +0800 [thread overview]
Message-ID: <051c01dcdd37$7d3cf940$77b6ebc0$@trustnetic.com> (raw)
In-Reply-To: <20260503021529.4127250-1-kuba@kernel.org>
On Sun, May 3, 2026 10:15 AM, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> net: ngbe: implement libwx reset ops
>
> This commit implements the wx->do_reset() operation for the ngbe driver,
> allowing the library module to trigger a reset by bringing the interface
> down and back up.
>
> > diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
> > index d8e3827a8b1f2..bd905e2675758 100644
> > --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
> > +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
>
> [ ... ]
>
> > +static void ngbe_reinit_locked(struct wx *wx)
> > +{
> > + netif_trans_update(wx->netdev);
> > +
> > + mutex_lock(&wx->reset_lock);
> > + set_bit(WX_STATE_RESETTING, wx->state);
> > +
> > + ngbe_down(wx);
> > + ngbe_up(wx);
> > +
> > + clear_bit(WX_STATE_RESETTING, wx->state);
>
> Does this introduce a regression by using WX_STATE_RESETTING as an ad-hoc
> lock here?
>
> While this pattern appears to exist elsewhere in the driver, adding it
> to ngbe_reinit_locked() relies on a design where background readers might
> check test_bit(WX_STATE_RESETTING, wx->state) without holding reset_lock.
>
> Since the flag check and subsequent accesses are not atomic, a reader could
> test the flag just before it is set and then proceed to access shared state
> concurrently with the ngbe_down() and ngbe_up() teardown path.
>
> Could this result in torn or corrupted reads, and would it be safer to use a
> proper synchronization mechanism like RCU or a shared lock for readers?
I think we have come up with a good way to deal with this in the previous
discussion:
https://lore.kernel.org/all/990c010b-f716-499d-b3ca-e8296003c37e@intel.com
Currently, only wx_update_stats() in watchdog that needs to test bit
WX_STATE_RESETTING, because the hardware statistics cannot be counted at the
reset time. Even if wx_update_stats() test the flag before ngbe_reinit_locked()
set it, the work task will be canceled before the reset.
>
> > + mutex_unlock(&wx->reset_lock);
> > +}
> > +
> > +void ngbe_do_reset(struct net_device *netdev)
>
> [ ... ]
>
next prev parent reply other threads:[~2026-05-06 9:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 8:25 [PATCH net-next v2 0/6] net: wangxun: timeout and error Jiawen Wu
2026-04-30 8:25 ` [PATCH net-next v2 1/6] net: ngbe: implement libwx reset ops Jiawen Wu
2026-05-03 2:15 ` Jakub Kicinski
2026-05-06 9:05 ` Jiawen Wu [this message]
2026-04-30 8:25 ` [PATCH net-next v2 2/6] net: wangxun: add Tx timeout process Jiawen Wu
2026-05-03 2:15 ` Jakub Kicinski
2026-04-30 8:25 ` [PATCH net-next v2 3/6] net: wangxun: add reinit parameter to wx->do_reset callback Jiawen Wu
2026-04-30 8:25 ` [PATCH net-next v2 4/6] net: wangxun: extract the close_suspend sequence Jiawen Wu
2026-05-03 2:15 ` Jakub Kicinski
2026-04-30 8:25 ` [PATCH net-next v2 5/6] net: wangxun: clear stored DMA addresses after dma_free_coherent() Jiawen Wu
2026-05-03 2:15 ` Jakub Kicinski
2026-04-30 8:25 ` [PATCH net-next v2 6/6] net: wangxun: implement pci_error_handlers ops Jiawen Wu
2026-05-03 2:15 ` Jakub Kicinski
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='051c01dcdd37$7d3cf940$77b6ebc0$@trustnetic.com' \
--to=jiawenwu@trustnetic.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fabio.baltieri@gmail.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.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=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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