[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89i+x3UbQWS_5jn4FLX0j8THitepvKUtK1rj3qxk1pVoKZA@mail.gmail.com>
Date: Tue, 14 Jan 2025 14:14:26 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, pabeni@...hat.com,
andrew+netdev@...n.ch, horms@...nel.org, jdamato@...tly.com,
pcnet32@...ntier.com, anthony.l.nguyen@...el.com,
przemyslaw.kitszel@...el.com, marcin.s.wojtas@...il.com, romieu@...zoreil.com
Subject: Re: [PATCH net-next 06/11] net: protect NAPI enablement with netdev_lock()
On Tue, Jan 14, 2025 at 4:51 AM Jakub Kicinski <kuba@...nel.org> wrote:
>
> Wrap napi_enable() / napi_disable() with netdev_lock().
> Provide the "already locked" flavor of the API"
>
> iavf needs the usual adjustment. A number of drivers call
> napi_enable() under a spin lock, so they have to be modified
> to take netdev_lock() first, then spin lock then call
> napi_enable_locked().
>
> Protecting napi_enable() implies that napi->napi_id is protected
> by netdev_lock().
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: pcnet32@...ntier.com
> CC: anthony.l.nguyen@...el.com
> CC: przemyslaw.kitszel@...el.com
> CC: marcin.s.wojtas@...il.com
> CC: romieu@...zoreil.com
> ---
> include/linux/netdevice.h | 11 ++----
> drivers/net/ethernet/amd/pcnet32.c | 11 +++++-
> drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +-
> drivers/net/ethernet/marvell/mvneta.c | 5 ++-
> drivers/net/ethernet/via/via-velocity.c | 4 +-
> net/core/dev.c | 41 +++++++++++++++++----
> 6 files changed, 55 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
> index dd4a07c97eee..892dc6ef3d3a 100644
> --- a/drivers/net/ethernet/via/via-velocity.c
> +++ b/drivers/net/ethernet/via/via-velocity.c
> @@ -2322,6 +2322,7 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu)
>
> napi_disable(&vptr->napi);
very minor nit: this line could be moved after netdev_lock() and
become napi_disable_locked();
>
> + netdev_lock(dev);
> spin_lock_irqsave(&vptr->lock, flags);
>
> netif_stop_queue(dev);
> @@ -2342,12 +2343,13 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu)
>
> velocity_give_many_rx_descs(vptr);
>
> - napi_enable(&vptr->napi);
> + napi_enable_locked(&vptr->napi);
>
> mac_enable_int(vptr->mac_regs);
> netif_start_queue(dev);
>
> spin_unlock_irqrestore(&vptr->lock, flags);
> + netdev_unlock(dev);
>
> velocity_free_rings(tmp_vptr);
>
Reviewed-by: Eric Dumazet <edumazet@...gle.com>
Powered by blists - more mailing lists