All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: Joerg Roedel <jroedel@suse.de>
Cc: iommu@lists.linux-foundation.org,
	Robin Murphy <robin.murphy@arm.com>,
	Christoph Hellwig <hch@lst.de>, Tom Murphy <murphyt7@tcd.ie>,
	linux-kernel@vger.kernel.org
Subject: Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy
Date: Wed, 16 Oct 2019 12:11:27 -0400	[thread overview]
Message-ID: <1571242287.5937.66.camel@lca.pw> (raw)
In-Reply-To: <20191016160314.GH4695@suse.de>

On Wed, 2019-10-16 at 18:03 +0200, Joerg Roedel wrote:
> On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote:
> > On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote:
> > 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);
> 
> Yeah, that is a bug, I spotted that too.
> 
> > @@ -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;
> 
> Not so sure this is a bug, this code is only about setting up MSIs on
> ARM. It probably doesn't need to be atomic.

The patch "iommu: Add gfp parameter to iommu_ops::map" does this. It could be
called from an atomic context as showed in the arm64 call traces,

+int iommu_map(struct iommu_domain *domain, unsigned long iova,
+             phys_addr_t paddr, size_t size, int prot)
+{
+       might_sleep();
+       return __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
+}
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Qian Cai <cai@lca.pw>
To: Joerg Roedel <jroedel@suse.de>
Cc: Tom Murphy <murphyt7@tcd.ie>, Robin Murphy <robin.murphy@arm.com>,
	Christoph Hellwig <hch@lst.de>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy
Date: Wed, 16 Oct 2019 12:11:27 -0400	[thread overview]
Message-ID: <1571242287.5937.66.camel@lca.pw> (raw)
In-Reply-To: <20191016160314.GH4695@suse.de>

On Wed, 2019-10-16 at 18:03 +0200, Joerg Roedel wrote:
> On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote:
> > On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote:
> > 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);
> 
> Yeah, that is a bug, I spotted that too.
> 
> > @@ -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;
> 
> Not so sure this is a bug, this code is only about setting up MSIs on
> ARM. It probably doesn't need to be atomic.

The patch "iommu: Add gfp parameter to iommu_ops::map" does this. It could be
called from an atomic context as showed in the arm64 call traces,

+int iommu_map(struct iommu_domain *domain, unsigned long iova,
+             phys_addr_t paddr, size_t size, int prot)
+{
+       might_sleep();
+       return __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
+}

  parent reply	other threads:[~2019-10-16 16:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 14:55 "Convert the AMD iommu driver to the dma-iommu api" is buggy Qian Cai
2019-10-16 14:55 ` Qian Cai
2019-10-16 14:59 ` Qian Cai
2019-10-16 14:59   ` Qian Cai
2019-10-16 15:31   ` Joerg Roedel
2019-10-16 15:31     ` Joerg Roedel
2019-10-16 15:53     ` Qian Cai
2019-10-16 15:53       ` Qian Cai
2019-10-16 16:03       ` Joerg Roedel
2019-10-16 16:03         ` Joerg Roedel
2019-10-16 16:09         ` Robin Murphy
2019-10-16 16:09           ` Robin Murphy
2019-10-16 16:36           ` Julien Grall
2019-10-16 16:36             ` Julien Grall
2019-10-16 16:11         ` Qian Cai [this message]
2019-10-16 16:11           ` Qian Cai
2019-10-16 16:26           ` Robin Murphy
2019-10-16 16:26             ` Robin Murphy
2019-10-16 15:44   ` Joerg Roedel
2019-10-16 15:44     ` Joerg Roedel
2019-10-17 14:39     ` Qian Cai
2019-10-17 14:39       ` Qian Cai
2019-10-18  9:39       ` Joerg Roedel
2019-10-18  9:39         ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1571242287.5937.66.camel@lca.pw \
    --to=cai@lca.pw \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=murphyt7@tcd.ie \
    --cc=robin.murphy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.