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

From: Lu Baolu
Date: Wed Feb 23 2022 - 00:02:50 EST


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 NULL;
return group; // A DMA_API 'token'

Which is locklessly reading dev->driver, and why you are talking about
races, I guess.


I am afraid that we are not able to implement a race-free
driver_or_DMA_API_token() helper. The lock problem between the IOMMU
core and driver core always exists.

For example, when we implemented iommu_group_store_type() to change the
default domain type of a device through sysfs, we could only comprised
and limited this functionality to singleton groups to avoid the lock
issue.

Unfortunately, that compromise cannot simply applied to the problem to
be solved by this series, because the iommu core cannot abort the driver
binding when the conflict is detected in the bus notifier.

Best regards,
baolu