From: Lu Baolu <baolu.lu@linux.intel.com>
To: Arvind Sankar <nivedita@alum.mit.edu>, linux-kernel@vger.kernel.org
Cc: baolu.lu@linux.intel.com, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] iommu/vt-d: Return the correct dma mask when we are bypassing the IOMMU
Date: Wed, 9 Oct 2019 10:45:15 +0800 [thread overview]
Message-ID: <76d680ab-a454-4a69-597a-c0edbfc5014b@linux.intel.com> (raw)
In-Reply-To: <20191008143357.GA599223@rani.riverdale.lan>
Hi,
On 10/8/19 10:33 PM, Arvind Sankar wrote:
> We must return a mask covering the full physical RAM when bypassing the
> IOMMU mapping. Also, in iommu_need_mapping, we need to check using
> dma_direct_get_required_mask to ensure that the device's dma_mask can
> cover physical RAM before deciding to bypass IOMMU mapping.
>
> Fixes: 249baa547901 ("dma-mapping: provide a better default ->get_required_mask")
> Reported-by: Arvind Sankar <nivedita@alum.mit.edu>
> Tested-by: Arvind Sankar <nivedita@alum.mit.edu>
> Originally-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Fixed-by: Arvind Sankar <nivedita@alum.mit.edu>
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
> ---
> drivers/iommu/intel-iommu.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 3f974919d3bd..79e35b3180ac 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -3471,7 +3471,7 @@ static bool iommu_need_mapping(struct device *dev)
> if (dev->coherent_dma_mask && dev->coherent_dma_mask < dma_mask)
> dma_mask = dev->coherent_dma_mask;
>
> - if (dma_mask >= dma_get_required_mask(dev))
> + if (dma_mask >= dma_direct_get_required_mask(dev))
> return false;
>
> /*
> @@ -3775,6 +3775,13 @@ static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nele
> return nelems;
> }
>
> +static u64 intel_get_required_mask(struct device *dev)
> +{
> + if (!iommu_need_mapping(dev))
> + return dma_direct_get_required_mask(dev);
> + return DMA_BIT_MASK(32);
Do you mind explaining why we always return 32 bit here?
Best regards,
Baolu
> +}
> +
> static const struct dma_map_ops intel_dma_ops = {
> .alloc = intel_alloc_coherent,
> .free = intel_free_coherent,
> @@ -3787,6 +3794,7 @@ static const struct dma_map_ops intel_dma_ops = {
> .dma_supported = dma_direct_supported,
> .mmap = dma_common_mmap,
> .get_sgtable = dma_common_get_sgtable,
> + .get_required_mask = intel_get_required_mask,
> };
>
> static void
>
next prev parent reply other threads:[~2019-10-09 2:47 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 2:24 ehci-pci breakage with dma-mapping changes in 5.4-rc2 Arvind Sankar
2019-10-07 7:34 ` Christoph Hellwig
2019-10-07 17:54 ` Arvind Sankar
2019-10-07 17:55 ` Christoph Hellwig
2019-10-07 17:56 ` Christoph Hellwig
2019-10-07 17:58 ` Arvind Sankar
2019-10-07 18:32 ` Arvind Sankar
2019-10-07 18:47 ` Christoph Hellwig
2019-10-07 22:10 ` Arvind Sankar
2019-10-07 23:54 ` Arvind Sankar
2019-10-08 7:32 ` Christoph Hellwig
2019-10-08 11:51 ` Arvind Sankar
2019-10-08 12:50 ` Christoph Hellwig
2019-10-08 15:47 ` Arvind Sankar
2019-10-09 6:50 ` Christoph Hellwig
2019-10-09 13:48 ` Arvind Sankar
2019-10-08 7:29 ` Christoph Hellwig
2019-10-08 14:33 ` [PATCH] iommu/vt-d: Return the correct dma mask when we are bypassing the IOMMU Arvind Sankar
2019-10-09 2:45 ` Lu Baolu [this message]
2019-10-09 6:51 ` Christoph Hellwig
2019-10-10 1:24 ` Lu Baolu
2019-10-10 1:26 ` Lu Baolu
2019-10-16 19:15 ` Arvind Sankar
2019-10-17 7:08 ` Christoph Hellwig
2019-10-17 15:55 ` Arvind Sankar
2019-10-18 9:50 ` Joerg Roedel
2019-10-18 15:14 ` Christoph Hellwig
2019-10-18 15:21 ` Joerg Roedel
2019-10-18 15:22 ` Christoph Hellwig
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=76d680ab-a454-4a69-597a-c0edbfc5014b@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nivedita@alum.mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome