On Wed, Feb 26, 2025 at 01:36:10PM -0400, Jason Gunthorpe wrote: > On Tue, Feb 25, 2025 at 06:25:27PM -0800, Nicolin Chen wrote: > > On Fri, Feb 21, 2025 at 10:39:59AM -0400, Jason Gunthorpe wrote: > > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > > > index 99dd72998cb7f7..082274e8ba6a3d 100644 > > > --- a/include/linux/iommu.h > > > +++ b/include/linux/iommu.h > > > @@ -1534,12 +1534,16 @@ void iommu_debugfs_setup(void); > > > static inline void iommu_debugfs_setup(void) {} > > > #endif > > > > > > -#ifdef CONFIG_IOMMU_DMA > > > +#if defined(CONFIG_IOMMU_DMA) && IS_ENABLED(CONFIG_IRQ_MSI_IOMMU) > > > int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base); > > > +void iommu_put_msi_cookie(struct iommu_domain *domain); > > > #else /* CONFIG_IOMMU_DMA */ > > > static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base) > > > { > > > - return -ENODEV; > > > + return 0; > > > > Should we keep the -ENODEV here for !CONFIG_IOMMU_DMA? > > My feeling was if the system doesn't have an IRQ driver that needs > MSI_IOMMU but does have a IOMMU driver that reports SW_MSI reserved > regions then iommufd/vfio should not fail. OK, I see. But we are also changing the behavior for the !CONFIG_IOMMU_DMA configuration, in which case all other iommu functions seem to return -ENODEV. And I assume we would need a justification for such a change? Perhaps, this can be explicit, just to keep the consistency: /* NOP if IOMMU driver reports SW_MSI reserved regions */ return IS_ENABLED(CONFIG_IOMMU_DMA) ? 0 : -ENODEV; > I don't think it is realistic that we'd ever hit this return. Yea, the only caller is VFIO, where there are quite a few IOMMU functions calls before reaching to this one. So, it would have been just returned with any -ENODEV prior. Thanks Nicolin