From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 3/3] ARM: start: Place malloc pool within 32-bit address space
Date: Thu, 23 Aug 2018 20:05:11 -0700 [thread overview]
Message-ID: <20180824030511.23021-4-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20180824030511.23021-1-andrew.smirnov@gmail.com>
Some 64-bit SoC have IP cores whose DMA capability is limited to
32-bits only. To handles such cases introduced DMA_32_BIT_ONLY as well
as add the code to make sure that malloc pool (which will be used for
DMA buffers) is accessible using 32-bit address.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
arch/arm/cpu/Kconfig | 3 +++
arch/arm/cpu/start.c | 23 +++++++++++++++++++++++
drivers/mci/Kconfig | 1 +
drivers/net/Kconfig | 1 +
4 files changed, 28 insertions(+)
diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index 2359c56b3..d9f68d9d0 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -3,6 +3,9 @@ comment "Processor Type"
config PHYS_ADDR_T_64BIT
bool
+config DMA_32_BIT_ONLY
+ bool
+
config CPU_32
bool
select HAS_MODULES
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 898f7ae19..3fc322d52 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -203,6 +203,29 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
}
}
+ if (IS_ENABLED(CONFIG_DMA_32_BIT_ONLY) &&
+ /* If membase is past 4GiB there's nothing we can do */
+ !WARN_ON(membase > U32_MAX)) {
+ /*
+ * Using SZ_4G against unsigned long will produce
+ * warning when compiling for 32-bit machines, so we
+ * defined the constant below so we can compare
+ * against U32_MAX instead.
+ */
+ const unsigned long __malloc_end = malloc_end - 1;
+
+ if (__malloc_end > U32_MAX) {
+ /*
+ * Some ARMv8 SoCs use IP blocks that are
+ * only do DMA transfers in first 4GiB of
+ * address space. To avoid allocating bad
+ * DMA buffers we move our malloc pool to
+ * reside within that region.
+ */
+ malloc_end = U32_MAX + 1;
+ }
+ }
+
/*
* Maximum malloc space is the Kconfig value if given
* or 1GB.
diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 954f957bc..0687841a7 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -83,6 +83,7 @@ config MCI_IMX
config MCI_IMX_ESDHC
bool "i.MX esdhc"
depends on ARCH_IMX
+ select DMA_32_BIT_ONLY if PHYS_ADDR_T_64BIT
help
Enable this entry to add support to read and write SD cards on a
Freescale i.MX25/35/51 based system.
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index b633a3ac4..a1679d8f6 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -135,6 +135,7 @@ config DRIVER_NET_FEC_IMX
bool "i.MX FEC Ethernet driver"
depends on ARCH_HAS_FEC_IMX
select PHYLIB
+ select DMA_32_BIT_ONLY if PHYS_ADDR_T_64BIT
config DRIVER_NET_GIANFAR
bool "Gianfar Ethernet"
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-24 3:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 3:05 [PATCH 0/3] i.MX8 malloc pool position and 32-bit only DMA Andrey Smirnov
2018-08-24 3:05 ` [PATCH 1/3] mci: imx-esdhc: Bail out if DMA address is larger than 32-bits Andrey Smirnov
2018-08-27 6:53 ` Sascha Hauer
2018-08-27 23:33 ` Andrey Smirnov
2018-08-24 3:05 ` [PATCH 2/3] net: fec: " Andrey Smirnov
2018-08-24 3:05 ` Andrey Smirnov [this message]
2018-08-27 9:06 ` [PATCH 3/3] ARM: start: Place malloc pool within 32-bit address space Sascha Hauer
2018-08-27 23:38 ` Andrey Smirnov
2018-08-24 17:15 ` [PATCH 0/3] i.MX8 malloc pool position and 32-bit only DMA Sam Ravnborg
2018-08-27 23:32 ` Andrey Smirnov
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=20180824030511.23021-4-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@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