Re: [PATCH rdma-next v2] RDMA: Explicitly pass in the dma_device to ib_register_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 06, 2020 at 08:57:49AM +0100, Christoph Hellwig wrote:
> On Tue, Oct 06, 2020 at 10:53:45AM +0300, Leon Romanovsky wrote:
> > On Tue, Oct 06, 2020 at 08:35:54AM +0100, Christoph Hellwig wrote:
> > > > +	WARN_ON(!IS_ENABLED(CONFIG_DMA_VIRT_OPS) && !dma_device);
> > > > +	if (!dma_device) {
> > > >  		/*
> > > > -		 * The caller did not provide custom DMA operations. Use the
> > > > -		 * DMA mapping operations of the parent device.
> > > > +		 * If the caller does not provide a DMA capable device then the
> > > > +		 * IB device will be used. In this case the caller should fully
> > > > +		 * setup the ibdev for DMA. This usually means using
> > > > +		 * dma_virt_ops.
> > > >  		 */
> > > > +		device->dev.dma_ops = &dma_virt_ops;
> > > > +		dma_device = &device->dev;
> > >
> > > The lack of the if probably means this will fail to link now when
> > > CONFIG_DMA_VIRT_OPS is not set.  This also seems to not remove the
> > > dma_virt_ops assignment in the callers.
> >
> > I expect to see this during driver development/testing. It is not worth
> > to make if() case id device won't be operable.
>
> Then you'll need an ifdef or whatever your preferred method is to
> avoid the dma_virt_ops symbol reference for the !CONFIG_DMA_VIRT_OPS
> case.

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 882a7b389dc3..49d095f45216 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1181,7 +1181,7 @@ static void setup_dma_device(struct ib_device *device,
                             struct device *dma_device)
 {
        WARN_ON(!IS_ENABLED(CONFIG_DMA_VIRT_OPS) && !dma_device);
-       if (!dma_device) {
+       if (IS_ENABLED(CONFIG_DMA_VIRT_OPS) && !dma_device) {
                /*
                 * If the caller does not provide a DMA capable device then the
                 * IB device will be used. In this case the caller should fully




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux