Message ID | 451e7beb57ec6de66ee0da5b38886105436f53d7.1674849118.git.nicolinc@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iommu: Reject drivers with broken_unmanaged_domain | expand |
On 2023-01-27 20:04, Nicolin Chen wrote: > Add a sanity of the broken_unmanaged_domain flag to reject the use of > dma-iommu in the early stage, if the flag is set by the iommu driver. Realistically, iommu-dma will never be enabled on PPC32, let alone used. It will not be enabled on ARM until I've fixed any drivers which need fixing to work with it. We don't need to add dead code here. Thanks, Robin. > Suggested-by: Jason Gunthorpe <jgg@nvidia.com> > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> > --- > drivers/iommu/dma-iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index f798c44e0903..f1e8d952b17d 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -545,6 +545,9 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, > if (!cookie || cookie->type != IOMMU_DMA_IOVA_COOKIE) > return -EINVAL; > > + if (WARN_ON(!device_iommu_unmanaged_supported(dev))) > + return -EINVAL; > + > iovad = &cookie->iovad; > > /* Use the smallest supported page size for IOVA granularity */
On Fri, Jan 27, 2023 at 09:59:50PM +0000, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2023-01-27 20:04, Nicolin Chen wrote: > > Add a sanity of the broken_unmanaged_domain flag to reject the use of > > dma-iommu in the early stage, if the flag is set by the iommu driver. > > Realistically, iommu-dma will never be enabled on PPC32, let alone used. > It will not be enabled on ARM until I've fixed any drivers which need > fixing to work with it. We don't need to add dead code here. OK. Sounds like I can drop this patch. Thanks Nicolin
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index f798c44e0903..f1e8d952b17d 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -545,6 +545,9 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, if (!cookie || cookie->type != IOMMU_DMA_IOVA_COOKIE) return -EINVAL; + if (WARN_ON(!device_iommu_unmanaged_supported(dev))) + return -EINVAL; + iovad = &cookie->iovad; /* Use the smallest supported page size for IOVA granularity */
Add a sanity of the broken_unmanaged_domain flag to reject the use of dma-iommu in the early stage, if the flag is set by the iommu driver. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> --- drivers/iommu/dma-iommu.c | 3 +++ 1 file changed, 3 insertions(+)