Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Greg Kroah-Hartman
On Wed, Feb 23, 2022 at 05:05:23PM +, Robin Murphy wrote: > On 2022-02-23 16:03, Greg Kroah-Hartman wrote: > > On Wed, Feb 23, 2022 at 10:30:11AM -0400, Jason Gunthorpe wrote: > > > On Wed, Feb 23, 2022 at 10:09:01AM -0400, Jason Gunthorpe wrote: > > > > On Wed, Feb 23, 2022 at 03:06:35PM

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Robin Murphy
On 2022-02-23 16:03, Greg Kroah-Hartman wrote: On Wed, Feb 23, 2022 at 10:30:11AM -0400, Jason Gunthorpe wrote: On Wed, Feb 23, 2022 at 10:09:01AM -0400, Jason Gunthorpe wrote: On Wed, Feb 23, 2022 at 03:06:35PM +0100, Greg Kroah-Hartman wrote: On Wed, Feb 23, 2022 at 09:46:27AM -0400, Jason

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Greg Kroah-Hartman
On Wed, Feb 23, 2022 at 10:30:11AM -0400, Jason Gunthorpe wrote: > On Wed, Feb 23, 2022 at 10:09:01AM -0400, Jason Gunthorpe wrote: > > On Wed, Feb 23, 2022 at 03:06:35PM +0100, Greg Kroah-Hartman wrote: > > > On Wed, Feb 23, 2022 at 09:46:27AM -0400, Jason Gunthorpe wrote: > > > > On Wed, Feb 23,

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Jason Gunthorpe via iommu
On Wed, Feb 23, 2022 at 10:09:01AM -0400, Jason Gunthorpe wrote: > On Wed, Feb 23, 2022 at 03:06:35PM +0100, Greg Kroah-Hartman wrote: > > On Wed, Feb 23, 2022 at 09:46:27AM -0400, Jason Gunthorpe wrote: > > > On Wed, Feb 23, 2022 at 01:04:00PM +, Robin Murphy wrote: > > > > > > > 1 -

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Jason Gunthorpe via iommu
On Wed, Feb 23, 2022 at 03:06:35PM +0100, Greg Kroah-Hartman wrote: > On Wed, Feb 23, 2022 at 09:46:27AM -0400, Jason Gunthorpe wrote: > > On Wed, Feb 23, 2022 at 01:04:00PM +, Robin Murphy wrote: > > > > > 1 - tmp->driver is non-NULL because tmp is already bound. > > > 1.a - If

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Greg Kroah-Hartman
On Wed, Feb 23, 2022 at 09:46:27AM -0400, Jason Gunthorpe wrote: > On Wed, Feb 23, 2022 at 01:04:00PM +, Robin Murphy wrote: > > > 1 - tmp->driver is non-NULL because tmp is already bound. > > 1.a - If tmp->driver->driver_managed_dma == 0, the group must currently be > > DMA-API-owned as a

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Jason Gunthorpe via iommu
On Wed, Feb 23, 2022 at 01:04:00PM +, Robin Murphy wrote: > 1 - tmp->driver is non-NULL because tmp is already bound. > 1.a - If tmp->driver->driver_managed_dma == 0, the group must currently be > DMA-API-owned as a whole. Regardless of what driver dev has unbound from, > its removal does

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-23 Thread Robin Murphy
On 2022-02-23 05:01, Lu Baolu wrote: On 2/23/22 7:53 AM, Jason Gunthorpe wrote: To spell it out, the scheme I'm proposing looks like this: Well, I already got this, it is what is in driver_or_DMA_API_token() that matters I think you are suggesting to do something like:     if

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-22 Thread Lu Baolu
On 2/23/22 7:53 AM, Jason Gunthorpe wrote: To spell it out, the scheme I'm proposing looks like this: Well, I already got this, it is what is in driver_or_DMA_API_token() that matters I think you are suggesting to do something like: if (!READ_ONCE(dev->driver) || ???) return

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-22 Thread Jason Gunthorpe via iommu
On Tue, Feb 22, 2022 at 09:18:23PM +, Robin Murphy wrote: > > Still not sure I see what you are thinking though.. > > What part of "How hard is it to hold group->mutex when reading or writing > group->owner?" sounded like "complex lockless algorithm", exactly? group->owner is not the issue,

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-22 Thread Robin Murphy
On 2022-02-22 15:16, Jason Gunthorpe wrote: On Tue, Feb 22, 2022 at 10:58:37AM +, Robin Murphy wrote: On 2022-02-21 23:48, Jason Gunthorpe wrote: On Mon, Feb 21, 2022 at 08:43:33PM +, Robin Murphy wrote: On 2022-02-19 07:32, Christoph Hellwig wrote: So we are back to the callback

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-22 Thread Jason Gunthorpe via iommu
On Tue, Feb 22, 2022 at 10:58:37AM +, Robin Murphy wrote: > On 2022-02-21 23:48, Jason Gunthorpe wrote: > > On Mon, Feb 21, 2022 at 08:43:33PM +, Robin Murphy wrote: > > > On 2022-02-19 07:32, Christoph Hellwig wrote: > > > > So we are back to the callback madness instead of the nice and

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-22 Thread Robin Murphy
On 2022-02-21 23:48, Jason Gunthorpe wrote: On Mon, Feb 21, 2022 at 08:43:33PM +, Robin Murphy wrote: On 2022-02-19 07:32, Christoph Hellwig wrote: So we are back to the callback madness instead of the nice and simple flag? Sigh. TBH, I *think* this part could be a fair bit simpler. It

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-21 Thread Lu Baolu
On 2/22/22 7:48 AM, Jason Gunthorpe wrote: since we should only care about ownership at probe, hotplug, and other places well outside critical fast-paths, I'm not sure we really need to keep track of that anyway - it can always be recalculated by walking the group->devices list, It has to be

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-21 Thread Jason Gunthorpe via iommu
On Mon, Feb 21, 2022 at 08:43:33PM +, Robin Murphy wrote: > On 2022-02-19 07:32, Christoph Hellwig wrote: > > So we are back to the callback madness instead of the nice and simple > > flag? Sigh. > > TBH, I *think* this part could be a fair bit simpler. It looks like this > whole callback

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-21 Thread Robin Murphy
On 2022-02-19 07:32, Christoph Hellwig wrote: So we are back to the callback madness instead of the nice and simple flag? Sigh. TBH, I *think* this part could be a fair bit simpler. It looks like this whole callback mess is effectively just to decrement group->owner_cnt, but since we should

Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-18 Thread Christoph Hellwig
So we are back to the callback madness instead of the nice and simple flag? Sigh. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-17 Thread Lu Baolu
The bus_type structure defines dma_configure() callback for bus drivers to configure DMA on the devices. This adds the paired dma_cleanup() callback and calls it during driver unbinding so that bus drivers can do some cleanup work. One use case for this paired DMA callbacks is for the bus driver