Re: [PATCH v5 2/7] iommu: Decouple iommu_present() from bus ops

From: Baolu Lu
Date: Thu Oct 12 2023 - 08:57:50 EST


On 2023/10/12 20:37, Jason Gunthorpe wrote:
On Thu, Oct 12, 2023 at 12:40:01PM +0100, Robin Murphy wrote:
On 2023-10-12 07:05, Baolu Lu wrote:
On 10/12/23 2:14 AM, Robin Murphy wrote:
Much as I'd like to remove iommu_present(), the final remaining users
are proving stubbornly difficult to clean up, so kick that can down the
road and just rework it to preserve the current behaviour without
depending on bus ops. Since commit 57365a04c921 ("iommu: Move bus setup

The iommu_present() is only used in below two drivers.

$ git grep iommu_present
drivers/gpu/drm/mediatek/mtk_drm_drv.c: if
(!iommu_present(&platform_bus_type))
drivers/gpu/drm/tegra/drm.c:    if (host1x_drm_wants_iommu(dev) &&
iommu_present(&platform_bus_type)) {

Both are platform drivers and have the device pointer passed in. Just
out of curiosity, why not replacing them with device_iommu_mapped()
instead? Sorry if I overlooked previous discussion.

Yes, we've already gone round in circles on this several times, that's why
it's explicitly called out as "stubbornly difficult" in the commit message.
The Mediatek one is entirely redundant, but it seems I have yet to figure
out the right CC list to get anyone to care about that patch[1].

I see now. Thanks for the explanation.


Please just have Joerg take such a trivial patch, there is no reason
we need to torture outselves because DRM side is not behaving well. :(

I was not object to the patch. Just want to make sure that I understand
the reason why device_iommu_mapped() can't be used in those two drivers.

It's fine to me. I will add my r-b.

Best regards,
baolu