Re: [PATCH] vfio: mlx5, pds: add IOMMU_SUPPORT dependency

From: Arnd Bergmann
Date: Mon Oct 23 2023 - 10:53:26 EST


On Mon, Oct 23, 2023, at 16:43, Jason Gunthorpe wrote:
> On Mon, Oct 23, 2023 at 04:35:15PM +0200, Arnd Bergmann wrote:
>> >> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
>> >> index 4a79704b164f7..2902b89a48f17 100644
>> >> --- a/drivers/gpu/drm/nouveau/Kconfig
>> >> +++ b/drivers/gpu/drm/nouveau/Kconfig
>> >> @@ -4,7 +4,7 @@ config DRM_NOUVEAU
>> >> depends on DRM && PCI && MMU
>> >> depends on (ACPI_VIDEO && ACPI_WMI && MXM_WMI) || !(ACPI && X86)
>> >> depends on BACKLIGHT_CLASS_DEVICE
>> >> - select IOMMU_API
>> >> + depends on IOMMU_API
>> >> select FW_LOADER
>> >> select DRM_DISPLAY_DP_HELPER
>> >> select DRM_DISPLAY_HDMI_HELPER
>> >
>> > Like here, nouveau should still be compilable even if no iommu driver
>> > was selected, and it should compile on arches without iommu drivers at
>> > all.
>>
>> Right, so with my draft patch, we can't build nouveau without
>> having an IOMMU driver, which matches the original intention
>> behind the Kconfig logic, while your suggestion would add the
>> same dependency here but still allow it to be compile tested
>> on target systems with no IOMMU. A minor downside of your
>> approach is that you end up building drivers (without
>> CONFIG_COMPILE_TEST) that currently exclude because we know
>> they will never work.
>
> I wonder how true that is, even nouveau only seems to have this for
> some tegra specific situation. The driver broadly does work without an
> iommu. (even weirder that already seems to have IS_ENABLED so I don't
> know what this is for)
>
> I'd prefer clarity over these kinds of optimizations..

It does look like a mistake in ee8642162a9e ("drm/nouveau: fix build
error without CONFIG_IOMMU_API"), which was done in response
to a compile-time failure that was also addressed in commit
0008d0c3b1ab ("iommu: Define dev_iommu_fwspec_get() for
!CONFIG_IOMMU_API") in a different way that made it possible to
use NOUVEAU without the IOMMU API again.

For drm/panfrost and drm/msm the dependency on IOMMU_SUPPORT
is different, as those apparently just want to select
CONFIG_IOMMU_IO_PGTABLE but can build without IOMMU_API.
This can also be handled in different ways, but it's a
separate problem.

Arnd