lkml.org 
[lkml]   [2021]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH net-next v4 4/4] net: ocelot: add FDMA support
Date
On Sat, Dec 04, 2021 at 07:52:06AM +0100, Clément Léger wrote:
> > +void ocelot_fdma_netdev_init(struct ocelot *ocelot, struct net_device *dev)
> > +{
> > + struct ocelot_fdma *fdma = ocelot->fdma;
> > +
> > + dev->needed_headroom = OCELOT_TAG_LEN;
> > + dev->needed_tailroom = ETH_FCS_LEN;
> > +
> > + if (fdma->napi_init)
> > + return;
> > +
> > + fdma->napi_init = true;
> > + netif_napi_add(dev, &ocelot->napi, ocelot_fdma_napi_poll,
> > + OCELOT_FDMA_WEIGHT);
> > +}
> > +
> > +void ocelot_fdma_netdev_deinit(struct ocelot *ocelot, struct net_device *dev)
> > +{
> > + struct ocelot_fdma *fdma = ocelot->fdma;
> > +
> > + if (fdma->napi_init) {
> > + netif_napi_del(&ocelot->napi);
> > + fdma->napi_init = false;
> > + }
>
> Using a boolean is acutally a bad idea, if the last netdev
> registration fails in ocelot, then the napi context will be deleted.
> The net_device should actually be used.

I think that you could try to call netif_napi_del() only if dev == napi->dev.
Because, as you say, if the NAPI structure has been added to the first
net device, and the registration of subsequent net devices fails, that
NAPI might actually even be in use by now, we should not disturb it.
\
 
 \ /
  Last update: 2021-12-04 12:53    [W:0.066 / U:3.652 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site