[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YZKjq3sXb9+UTDSz@infradead.org>
Date: Mon, 15 Nov 2021 10:15:07 -0800
From: Christoph Hellwig <hch@...radead.org>
To: Jason Gunthorpe <jgg@...dia.com>
Cc: Robin Murphy <robin.murphy@....com>,
Christoph Hellwig <hch@...radead.org>,
Kevin Tian <kevin.tian@...el.com>,
Chaitanya Kulkarni <kch@...dia.com>,
Ashok Raj <ashok.raj@...el.com>, kvm@...r.kernel.org,
rafael@...nel.org, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Cornelia Huck <cohuck@...hat.com>,
Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
iommu@...ts.linux-foundation.org,
Alex Williamson <alex.williamson@...hat.com>,
Jacob jun Pan <jacob.jun.pan@...el.com>,
linux-pci@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>,
Diana Craciun <diana.craciun@....nxp.com>
Subject: Re: [PATCH 02/11] driver core: Set DMA ownership during driver
bind/unbind
On Mon, Nov 15, 2021 at 11:56:13AM -0400, Jason Gunthorpe wrote:
> drivers/base/platform.c: .dma_configure = platform_dma_configure,
> drivers/bus/fsl-mc/fsl-mc-bus.c: .dma_configure = fsl_mc_dma_configure,
> drivers/pci/pci-driver.c: .dma_configure = pci_dma_configure,
> drivers/gpu/host1x/bus.c: .dma_configure = host1x_dma_configure,
>
> Other than host1x they all work with VFIO.
>
> Also, there is no bus->dma_unconfigure() which would be needed to
> restore the device as well.
>
> So, would you rather see duplicated code into the 4 drivers, and a new
> bus op to 'unconfigure dma'
The tend to mostly call into common helpers eventually.
>
> Or, a 'dev_configure_dma()' function that is roughly:
>
> if (dev->bus->dma_configure) {
> ret = dev->bus->dma_configure(dev);
> if (ret)
> return ret;
> if (!drv->suppress_auto_claim_dma_owner) {
> ret = iommu_device_set_dma_owner(dev, DMA_OWNER_KERNEL,
> NULL);
> if (ret)
> ret;
> }
> }
>
> And a pair'd undo.
But that seems like an even better idea to me. Even better with an
early return and avoiding the pointless indentation.
Powered by blists - more mailing lists