From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: Florian Fainelli <f.fainelli@gmail.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
bcm-kernel-feedback-list@broadcom.com,
Eric Anholt <eric@anholt.net>, Stefan Wahren <wahrenst@gmx.net>
Cc: mbrugger@suse.com, hch@lst.de,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Russell King <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org
Subject: [RFC] ARM: bcm2835: register dmabounce on devices hooked to main interconnect
Date: Tue, 23 Jul 2019 18:19:33 +0200 [thread overview]
Message-ID: <20190723161934.4590-1-nsaenzjulienne@suse.de> (raw)
NOTE: This patch builds upon Stefan's series providing basic support for
RPi4[1]. I'm mostly interested in verifying if this is the correct approach
to the issue stated below. If so I assume this will be added to Stefan's
v2 series.
The new Raspberry Pi 4 happens to have weird DMA constraints. Even
though it might contain up to 4 GB of ram, most devices can only access
the first lower GB of memory.
This breaks the overall assumption DMA API makes whereas 32-bit DMA
masks are always supported[2], and potentially breaks DMA addressing for
all streaming DMA users. This has already been observed with
'sdhci-iproc' but might as well happen elsewhere. Note that contiguous
allocations are safe as 'dma_zone_size' is set accordingly.
To get around that limitation we register arm's dmabounce dma-ops on all
devices hooked to the SoC's main interconnect.
[1] https://www.spinics.net/lists/arm-kernel/msg742120.html
[2] https://www.spinics.net/lists/arm-kernel/msg742736.html
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
arch/arm/mach-bcm/Kconfig | 1 +
arch/arm/mach-bcm/board_bcm2835.c | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 5e5f1fabc3d4..588326f7e269 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -168,6 +168,7 @@ config ARCH_BCM2835
select PINCTRL
select PINCTRL_BCM2835
select MFD_CORE
+ select DMABOUNCE if ARCH_MULTI_V7
help
This enables support for the Broadcom BCM2835 and BCM2836 SoCs.
This SoC is used in the Raspberry Pi and Roku 2 devices.
diff --git a/arch/arm/mach-bcm/board_bcm2835.c b/arch/arm/mach-bcm/board_bcm2835.c
index c09cf25596af..7aff29f77ca7 100644
--- a/arch/arm/mach-bcm/board_bcm2835.c
+++ b/arch/arm/mach-bcm/board_bcm2835.c
@@ -3,6 +3,8 @@
* Copyright (C) 2010 Broadcom
*/
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
#include <linux/init.h>
#include <linux/irqchip.h>
#include <linux/of_address.h>
@@ -24,8 +26,35 @@ static const char * const bcm2835_compat[] = {
NULL
};
+static int bcm2835_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
+{
+ /*
+ * The accepted dma addresses are [0xc0000000, 0xffffffff] which map to
+ * ram's [0x00000000, 0x3fffffff].
+ */
+ return dma_addr < 3ULL * SZ_1G;
+}
+
+static int bcm2835_platform_notify(struct device *dev)
+{
+ if (dev->parent && !strcmp("soc", dev_name(dev->parent))) {
+ dev->dma_mask = &dev->coherent_dma_mask;
+ dev->coherent_dma_mask = DMA_BIT_MASK(30);
+ dmabounce_register_dev(dev, 2048, 4096, bcm2835_needs_bounce);
+ }
+
+ return 0;
+}
+
+void __init bcm2835_init_early(void)
+{
+ if(of_machine_is_compatible("brcm,bcm2711"))
+ platform_notify = bcm2835_platform_notify;
+}
+
DT_MACHINE_START(BCM2835, "BCM2835")
.dma_zone_size = SZ_1G,
.dt_compat = bcm2835_compat,
.smp = smp_ops(bcm2836_smp_ops),
+ .init_early = bcm2835_init_early,
MACHINE_END
--
2.22.0
next reply other threads:[~2019-07-23 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 16:19 Nicolas Saenz Julienne [this message]
2019-07-23 16:34 ` Christoph Hellwig
2019-07-27 8:36 ` Florian Fainelli
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=20190723161934.4590-1-nsaenzjulienne@suse.de \
--to=nsaenzjulienne@suse.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=eric@anholt.net \
--cc=f.fainelli@gmail.com \
--cc=hch@lst.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=mbrugger@suse.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=wahrenst@gmx.net \
/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
all inboxes | Powered by JetHome®