From: kraxel@redhat.com (Gerd Hoffmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/9] arm64: Allow for different DMA and CPU bus offsets
Date: Fri, 3 Jun 2016 08:18:22 +0200 [thread overview]
Message-ID: <1464934708-24769-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1464934708-24769-1-git-send-email-kraxel@redhat.com>
From: Alexander Graf <agraf@suse.de>
On arm64, all SoCs we supported so far either have an IOMMU or have bus
addresses equal to CPU addresses.
However, with the Raspberry Pi 3 coming up, this is no longer true. To
allow DMA to work with an AArch64 kernel on those devices, let's allow
devices to have DMA offsets again.
Signed-off-by: Alexander Graf <agraf@suse.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
arch/arm64/include/asm/dma-mapping.h | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index 7dbea6c..ccea82c 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -66,12 +66,16 @@ static inline bool is_device_dma_coherent(struct device *dev)
static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
{
- return (dma_addr_t)paddr;
+ dma_addr_t dev_addr = (dma_addr_t)paddr;
+
+ return dev_addr - ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
}
static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
{
- return (phys_addr_t)dev_addr;
+ phys_addr_t paddr = (phys_addr_t)dev_addr;
+
+ return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
}
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
@@ -86,5 +90,14 @@ static inline void dma_mark_clean(void *addr, size_t size)
{
}
+/* Override for dma_max_pfn() */
+static inline unsigned long dma_max_pfn(struct device *dev)
+{
+ dma_addr_t dma_max = (dma_addr_t)*dev->dma_mask;
+
+ return (ulong)dma_to_phys(dev, dma_max) >> PAGE_SHIFT;
+}
+#define dma_max_pfn(dev) dma_max_pfn(dev)
+
#endif /* __KERNEL__ */
#endif /* __ASM_DMA_MAPPING_H */
--
1.8.3.1
next prev parent reply other threads:[~2016-06-03 6:18 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 6:18 [PATCH v2 0/9] raspberry pi 3 patch series, part 1: essentials Gerd Hoffmann
2016-06-03 6:18 ` [PATCH v2 1/9] pinctrl: walk into bcm subdir unconditionally Gerd Hoffmann
2016-06-08 8:12 ` Linus Walleij
2016-06-10 0:16 ` Eric Anholt
2016-06-13 7:26 ` Linus Walleij
2016-06-14 17:37 ` Eric Anholt
2016-06-03 6:18 ` [PATCH v2 2/9] irqchip: bcm2835: Avoid arch/arm-specific handle_IRQ Gerd Hoffmann
2016-06-03 6:18 ` Gerd Hoffmann [this message]
2016-06-03 6:18 ` [PATCH v2 4/9] arm64: Add platform selection for BCM2835 Gerd Hoffmann
2016-06-03 11:27 ` Catalin Marinas
2016-06-04 19:55 ` Eric Anholt
2016-06-08 9:12 ` Catalin Marinas
2016-06-10 0:21 ` Eric Anholt
2016-06-10 9:56 ` Catalin Marinas
2016-06-15 6:48 ` Eric Anholt
2016-06-15 8:07 ` Catalin Marinas
2016-06-15 21:57 ` Eric Anholt
2016-06-03 6:18 ` [PATCH v2 5/9] arm64: Add BCM2835 support to the defconfig Gerd Hoffmann
2016-06-03 7:36 ` Arnd Bergmann
2016-06-03 8:50 ` Gerd Hoffmann
2016-06-03 8:58 ` Arnd Bergmann
2016-06-03 9:53 ` Gerd Hoffmann
2016-06-07 22:16 ` Eric Anholt
2016-06-03 6:18 ` [PATCH v2 6/9] dt-bindings: Add root properties for Raspberry Pi 3 Gerd Hoffmann
2016-06-03 6:18 ` [PATCH v2 7/9] ARM: bcm2835: Add devicetree for the " Gerd Hoffmann
2016-06-03 7:38 ` Arnd Bergmann
2016-06-03 8:45 ` Gerd Hoffmann
2016-06-03 8:55 ` Arnd Bergmann
2016-06-03 10:39 ` Gerd Hoffmann
2016-06-03 11:15 ` Arnd Bergmann
2016-06-03 16:17 ` Rob Herring
2016-06-04 21:39 ` Arnd Bergmann
2016-06-06 7:20 ` Gerd Hoffmann
2016-06-06 7:28 ` Arnd Bergmann
2016-06-06 7:47 ` Gerd Hoffmann
2016-06-03 9:04 ` Stefan Wahren
2016-06-03 6:18 ` [PATCH v2 8/9] ARM: bcm2835: dt: Add the ethernet to the device trees Gerd Hoffmann
2016-06-03 6:18 ` [PATCH v2 9/9] ARM: bcm2837: " Gerd Hoffmann
2016-06-03 7:40 ` [PATCH v2 0/9] raspberry pi 3 patch series, part 1: essentials Arnd Bergmann
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=1464934708-24769-4-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=linux-arm-kernel@lists.infradead.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 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).