Re: [PATCH v3 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver

From: Kelvin.Cao
Date: Fri Apr 14 2023 - 19:34:16 EST


On Wed, 2023-04-12 at 22:33 +0530, Vinod Koul wrote:

> > +#include <linux/circ_buf.h>
> > +#include <linux/dmaengine.h>
> > +#include <linux/module.h>
> > +#include <linux/pci.h>
> > +#include <linux/delay.h>
> > +
> > +#include "dmaengine.h"
> > +
> > +MODULE_DESCRIPTION("Switchtec PCIe Switch DMA Engine");
> > +MODULE_VERSION("0.1");
>
> what is the use of this?
Not sure if I get it correctly. As a loadable module, it shows
'version: 0.1' for modinfo
> >
> > +#define HALT_RETRY 100
> > +static int halt_channel(struct switchtec_dma_chan *swdma_chan)
> > +{
> > +     u32 status;
> > +     struct chan_hw_regs __iomem *chan_hw = swdma_chan-
> > >mmio_chan_hw;
> > +     int retry = HALT_RETRY;
> > +     struct pci_dev *pdev;
> > +     int ret;
> > +
> > +     rcu_read_lock();
> > +     pdev = rcu_dereference(swdma_chan->swdma_dev->pdev);
>
> that sounds fishy, why does a driver need to use rcu functions
RCU is used to synchronize driver unbind and low level PCI operations.

The unbind issue was first spotted and fixed by Logan:
https://lore.kernel.org/all/20191216190120.21374-1-logang@xxxxxxxxxxxx/

>
Thanks,
Kelvin