Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

From: Qian Cai
Date: Wed Oct 16 2019 - 11:53:39 EST


On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote:
> Hi Qian,
>
> thanks for the report!
>
> On Wed, Oct 16, 2019 at 10:59:42AM -0400, Qian Cai wrote:
> > On Wed, 2019-10-16 at 10:55 -0400, Qian Cai wrote:
> > > Today's linux-next generates a lot of warnings on multiple servers during boot
> > > due to the series "iommu/amd: Convert the AMD iommu driver to the dma-iommu api"
> > > [1]. Reverted the whole things fixed them.
> > >
> > > [1] https://lore.kernel.org/lkml/20190908165642.22253-1-murphyt7@xxxxxx/
> > >
> >
> > BTW, the previous x86 warning was from only reverted one patch "iommu: Add gfp
> > parameter to iommu_ops::map" where proved to be insufficient. Now, pasting the
> > correct warning.

The x86 one might just be a mistake.

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index ad05484d0c80..63c4b894751d 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2542,7 +2542,7 @@ static int amd_iommu_map(struct iommu_domain *dom,
unsigned long iova,
ÂÂÂÂÂÂÂÂif (iommu_prot & IOMMU_WRITE)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂprot |= IOMMU_PROT_IW;
Â
-ÂÂÂÂÂÂÂret = iommu_map_page(domain, iova, paddr, page_size, prot, GFP_KERNEL);
+ÂÂÂÂÂÂÂret = iommu_map_page(domain, iova, paddr, page_size, prot, gfp);
Â
ÂÂÂÂÂÂÂÂdomain_flush_np_cache(domain, iova, page_size);

The arm64 -- does it forget to do this?

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index ecc08aef9b58..8dd0ef0656f4 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1185,7 +1185,7 @@ static struct iommu_dma_msi_page
*iommu_dma_get_msi_page(struct device *dev,
ÂÂÂÂÂÂÂÂif (!iova)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂgoto out_free_page;
Â
-ÂÂÂÂÂÂÂif (iommu_map(domain, iova, msi_addr, size, prot))
+ÂÂÂÂÂÂÂif (iommu_map_atomic(domain, iova, msi_addr, size, prot))
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂgoto out_free_iova;
Â
ÂÂÂÂÂÂÂÂINIT_LIST_HEAD(&msi_page->list);