[PATCH v6 net-next 2/2] net: airoha: Introduce ethernet support for EN7581 SoC
Lorenzo Bianconi
lorenzo at kernel.org
Tue Jul 9 14:41:21 PDT 2024
> > +static int airoha_qdma_init_rx_queue(struct airoha_eth *eth,
> > + struct airoha_queue *q, int ndesc)
> > +{
> > + struct page_pool_params pp_params = {
> > + .order = 0,
> > + .pool_size = 256,
> > + .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV,
> > + .dma_dir = DMA_FROM_DEVICE,
> > + .max_len = PAGE_SIZE,
> > + .nid = NUMA_NO_NODE,
> > + .dev = eth->dev,
> > + .napi = &q->napi,
> > + };
>
> I think you can make this const.
ack
>
> > +static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
> > +{
>
> > + port = netdev_priv(dev);
> > + mutex_init(&port->stats.mutex);
> > + port->dev = dev;
> > + port->eth = eth;
> > + port->id = id;
> > +
> > + err = register_netdev(dev);
> > + if (err)
> > + return err;
> > +
> > + eth->ports[index] = port;
>
> eth->ports[index] appears to be used in
> airoha_qdma_rx_process(). There is a small race condition here, since
> the interface could be in use before register_netdev() returns,
> e.g. NFS root. It would be better to do the assignment before
> registering the interface.
actually I check eth->ports[] is not NULL before accessing it in
airoha_qdma_rx_process():
p = airoha_qdma_get_gdm_port(eth, desc);
if (p < 0 || !eth->ports[p]) {
...
}
Moreover, in airoha_alloc_gdm_port(), I set eth->ports[index] pointer just if
register_netdev() is successful in order to avoid to call unregister_netdev()
on an not-registered net_device in the airoha_probe() error path. I guess we can
even check reg_state for this:
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
...
if (dev->reg_state == NETREG_REGISTERED)
unregister_netdev(dev);
}
What do you prefer?
Regards,
Lorenzo
>
> These are quite minor, so please add to the next version:
>
> Reviewed-by: Andrew Lunn <andrew at lunn.ch>
>
> Andrew
>
> ---
> pw-bot: cr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240709/fe5d55c0/attachment.sig>
More information about the linux-arm-kernel
mailing list