From: Christoph Hellwig <hch@lst.de>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
iommu@lists.linux-foundation.org,
Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 2/3] dma-direct: avoid a forward declaration for phys_to_dma
Date: Wed, 13 Nov 2019 08:35:38 +0100 [thread overview]
Message-ID: <20191113073539.9660-3-hch@lst.de> (raw)
In-Reply-To: <20191113073539.9660-1-hch@lst.de>
Move dma_capable down a bit so that we don't need a forward declaration
for phys_to_dma.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/dma-direct.h | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index 991f8aa2676e..f8959f75e496 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -6,8 +6,6 @@
#include <linux/memblock.h> /* for min_low_pfn */
#include <linux/mem_encrypt.h>
-static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
-
#ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
#include <asm/dma-direct.h>
#else
@@ -26,20 +24,6 @@ static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
}
#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
-static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
-{
- dma_addr_t end = addr + size - 1;
-
- if (!dev->dma_mask)
- return false;
-
- if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
- min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
- return false;
-
- return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
-}
-
#ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED
bool force_dma_unencrypted(struct device *dev);
#else
@@ -65,6 +49,20 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
return __sme_clr(__dma_to_phys(dev, daddr));
}
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+ dma_addr_t end = addr + size - 1;
+
+ if (!dev->dma_mask)
+ return false;
+
+ if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
+ min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
+ return false;
+
+ return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
+}
+
u64 dma_direct_get_required_mask(struct device *dev);
void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp, unsigned long attrs);
--
2.20.1
next prev parent reply other threads:[~2019-11-13 7:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-13 7:35 unify the dma_capable definition Christoph Hellwig
2019-11-13 7:35 ` [PATCH 1/3] dma-direct: unify the dma_capable definitions Christoph Hellwig
2019-11-14 8:47 ` Michael Ellerman
2019-11-19 9:27 ` Marek Szyprowski
2019-11-19 9:44 ` Krzysztof Kozlowski
2019-11-19 10:26 ` Marek Szyprowski
2019-11-19 16:16 ` Robin Murphy
2019-11-19 16:46 ` Christoph Hellwig
2019-11-20 6:31 ` Marek Szyprowski
2019-11-19 10:19 ` Nicolas Saenz Julienne
2019-11-13 7:35 ` Christoph Hellwig [this message]
2019-11-13 7:35 ` [PATCH 3/3] powerpc: remove support for NULL dev in __phys_to_dma / __dma_to_phys Christoph Hellwig
2019-11-14 8:48 ` Michael Ellerman
2019-11-13 10:18 ` unify the dma_capable definition Nicolas Saenz Julienne
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=20191113073539.9660-3-hch@lst.de \
--to=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nsaenzjulienne@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).