Re: [PATCH v3 1/4] iommu: Introduce device_iommu_capable()
From: Robin Murphy
Date: Wed Apr 06 2022 - 09:32:16 EST
On 2022-04-06 06:28, Christoph Hellwig wrote:
On Tue, Apr 05, 2022 at 11:41:01AM +0100, Robin Murphy wrote:
iommu_capable() only really works for systems where all IOMMU instances
are completely homogeneous, and all devices are IOMMU-mapped. Implement
the new variant which can give an accurate answer for whichever device
the caller is actually interested in.
Signed-off-by: Robin Murphy <robin.murphy@xxxxxxx>
---
v3: New patch; now that the dev_iommu_ops() work has landed we can go
straight to a proper implementation. Also s/dev/device/ to match
the precedent of device_iommu_mapped() for the public API.
I'm a little worrited about a method with a parameter than can be
NULL.
FWIW, the intent is that that's only temporary.
Also usnic, vmd, and vdpa really want to use your new
device_iommu_capable as they check based on a device. Just VFIO
is special as usual..
Indeed, I have those patches in my stack already, I'm just waiting for
this to land before I think about posting them. Once the DMA ownership
series lands in parallel, VFIO can also get converted and
iommu_capable() goes away entirely. At that point I have a patch for the
Arm SMMU drivers to start actually using the new device argument, but
Jason's new proposal now puts a twist on that...
On reflection, there's no real need for the internal method to change in
lock-step with the external interface. I've no objection to holding off
on adding that new parameter until it's reliably useful, and indeed now
that I'm looking at it outside the context of the entire cleanup
mission, that does sound like the right thing to do anyway :)
(also it turns out I need to respin this patch regardless since I
generated it from the wrong point in my branch, where iommu_present()
was already gone from the context in iommu.h...)
Cheers,
Robin.