Re: [PATCH v2 00/26] IB: Optimize DMA mapping

From: Bart Van Assche
Date: Tue Jan 17 2017 - 18:08:56 EST


On Tue, 2017-01-17 at 15:27 -0700, Jason Gunthorpe wrote:
> On Tue, Jan 17, 2017 at 10:00:00PM +0000, Bart Van Assche wrote:
> > + /*
> > + * qib and hfi1 use two sets of DMA operations:
> > + * - The DMA operations of the PCIe device for SDMA.
> > + * - dma_virt_ops for users of the qib and hfi1 drivers.
> > + * The only purpose of @dma_device is to provide a struct device that
> > + * provides dma_virt_ops.
> > + */
> > + struct device dma_device;
>
> Creating a struct device, not calling device_initialize() and then
> passing it around it other places is pretty ugly and potentially
> dangerous.
>
> Is there some other way?
>
> Can you setup ibdev to be the 'dma device' for the user side?

Hello Jason,

The only member of this struct device that is used is dma_ops so this approach
should be fine as an interim solution. My plan is, if this patch is sufficient
to unbreak the hfi1 driver, to remove the struct device cited in your e-mail
again and also the dma_device pointer from struct ib_device. Since the
dev.dma_ops pointer in struct ib_device is not yet used dev.dma_ops can be used
instead of the dma_device pointer.

Bart.