All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: thomas.lendacky-5C7GfCeVMHo@public.gmane.org,
	robin.murphy-5wv7dgnIgG8@public.gmane.org
Subject: [PATCH 1/2] kernel/dma/direct: take DMA offset into account in dma_direct_supported
Date: Fri, 24 Aug 2018 08:53:23 +0200	[thread overview]
Message-ID: <20180824065324.654-2-hch@lst.de> (raw)
In-Reply-To: <20180824065324.654-1-hch-jcswGhMUV9g@public.gmane.org>

When a device has a DMA offset the dma capable result will change due
to the difference between the physical and DMA address.  Take that into
account.

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Reviewed-by: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
---
 kernel/dma/direct.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 1c35b7b945d0..de87b0282e74 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -168,7 +168,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
 int dma_direct_supported(struct device *dev, u64 mask)
 {
 #ifdef CONFIG_ZONE_DMA
-	if (mask < DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
+	if (mask < phys_to_dma(dev, DMA_BIT_MASK(ARCH_ZONE_DMA_BITS)))
 		return 0;
 #else
 	/*
@@ -177,7 +177,7 @@ int dma_direct_supported(struct device *dev, u64 mask)
 	 * memory, or by providing a ZONE_DMA32.  If neither is the case, the
 	 * architecture needs to use an IOMMU instead of the direct mapping.
 	 */
-	if (mask < DMA_BIT_MASK(32))
+	if (mask < phys_to_dma(dev, DMA_BIT_MASK(32)))
 		return 0;
 #endif
 	/*
-- 
2.18.0

  parent reply	other threads:[~2018-08-24  6:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24  6:53 two dma-direct fixes for 4.18 Christoph Hellwig
     [not found] ` <20180824065324.654-1-hch-jcswGhMUV9g@public.gmane.org>
2018-08-24  6:53   ` Christoph Hellwig [this message]
     [not found]     ` <20180824065324.654-2-hch-jcswGhMUV9g@public.gmane.org>
2018-08-24 11:11       ` [PATCH 1/2] kernel/dma/direct: take DMA offset into account in dma_direct_supported Robin Murphy
     [not found]         ` <0e95df80-38f7-7970-ef74-419567f13fdc-5wv7dgnIgG8@public.gmane.org>
2018-08-29 16:59           ` Christoph Hellwig
2018-08-24  6:53   ` [PATCH 2/2] kernel/dma/direct: refine dma_direct_alloc zone selection Christoph Hellwig
     [not found]     ` <20180824065324.654-3-hch-jcswGhMUV9g@public.gmane.org>
2018-08-24 11:38       ` Robin Murphy
     [not found]         ` <bfba5bae-a88c-f777-ba1f-f0db310904dc-5wv7dgnIgG8@public.gmane.org>
2018-08-24 11:49           ` Robin Murphy

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=20180824065324.654-2-hch@lst.de \
    --to=hch-jcswghmuv9g@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
    --cc=thomas.lendacky-5C7GfCeVMHo@public.gmane.org \
    /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.