[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d22320dd-2695-4f9b-bd72-38eabc1d934f@arm.com>
Date: Tue, 10 Jun 2025 15:40:40 +0100
From: Robin Murphy <robin.murphy@....com>
To: Jason Gunthorpe <jgg@...dia.com>, Nicolin Chen <nicolinc@...dia.com>
Cc: Baolu Lu <baolu.lu@...ux.intel.com>, joro@...tes.org, will@...nel.org,
bhelgaas@...gle.com, iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org, patches@...ts.linux.dev, pjaroszynski@...dia.com,
vsethi@...dia.com
Subject: Re: [PATCH RFC v1 1/2] iommu: Introduce iommu_dev_reset_prepare() and
iommu_dev_reset_done()
On 2025-06-10 2:04 pm, Jason Gunthorpe wrote:
> On Tue, Jun 10, 2025 at 12:07:00AM -0700, Nicolin Chen wrote:
>> On Tue, Jun 10, 2025 at 12:26:07PM +0800, Baolu Lu wrote:
>>> On 6/10/25 02:45, Nicolin Chen wrote:
>>>> + ops = dev_iommu_ops(dev);
>>>
>>> Should this be protected by group->mutext?
>>
>> Not seemingly, but should require the iommu_probe_device_lock I
>> think.
>
> group and ops are not permitted to change while a driver is attached..
>
> IIRC the FLR code in PCI doesn't always ensure that (due to the sysfs
> paths), so yeah, this looks troubled. iommu_probe_device_lock perhaps
> would fix it.
No, iommu_probe_device_lock is for protecting access to dev->iommu in
the probe path until the device is definitively assigned to a group (or
not). Fundamentally it defends against multiple sources triggering a
probe of the same device in parallel - once the device *is* probed it is
no longer relevant, and the group mutex is the right thing to protect
all subsequent operations.
Also I'm still working towards getting rid of iommu_probe_device_lock as
soon as I can because it's horrid... I now have most of a plan for
making it safe to rely on device_lock() for probe, which should nicely
solve the dev->driver races as well.
Thanks,
Robin.
Powered by blists - more mailing lists