From: Alberto Secondi <albertosecondi@gmail.com>
To: hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
alberto.secondi@abinsula.com,
Davide Salaris <davide.salaris@abinsula.com>
Subject: [PATCH] New config added to handle 64-bit systems with 32-bit DMA support
Date: Wed, 19 Jun 2024 11:17:37 +0200 [thread overview]
Message-ID: <20240619091737.669040-1-albertosecondi@gmail.com> (raw)
From: Alberto Secondi <alberto.secondi@abinsula.com>
The kernel assumes that 64-bit systems have 64-bit DMA support through
CONFIG_ARCH_DMA_ADDR_T_64BIT. This is not always true; for example, several
iMX8 systems (verified on iMX8MM and iMX8MP) have DMA with only 32-bit support.
This results in several drivers requesting DMA_BIT_MASK(64), which causes
malfunctions, particularly when systems have more than 3GB of DRAM (verified
with the lan743x driver and iMX8 systems with 4GB of DRAM). Therefore, a new
config ARCH_64BIT_HAS_DMA32_ONLY was added to manage 64-bit systems with 32-bit
DMA, which adjusts DMA_BIT_MASK(n) accordingly.
Signed-off-by: Alberto Secondi <alberto.secondi@abinsula.com>
Co-developed-by: Davide Salaris <davide.salaris@abinsula.com>
---
include/linux/dma-mapping.h | 4 ++++
kernel/dma/Kconfig | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index f693aafe221f..629220a777e3 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -74,7 +74,11 @@
*/
#define DMA_MAPPING_ERROR (~(dma_addr_t)0)
+#ifdef CONFIG_ARCH_64BIT_HAS_DMA32_ONLY
+#define DMA_BIT_MASK(n) (((n) > 32) ? ((1ULL<<(32))-1) : ((1ULL<<(n))-1))
+#else
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
+#endif
#ifdef CONFIG_DMA_API_DEBUG
void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
index c06e56be0ca1..0a27eafed808 100644
--- a/kernel/dma/Kconfig
+++ b/kernel/dma/Kconfig
@@ -36,6 +36,14 @@ config NEED_DMA_MAP_STATE
config ARCH_DMA_ADDR_T_64BIT
def_bool 64BIT || PHYS_ADDR_T_64BIT
+config ARCH_64BIT_HAS_DMA32_ONLY
+ bool "64bit System has DMA32 only"
+ depends on ARCH_DMA_ADDR_T_64BIT
+ default n
+ help
+ This enables forcing the maximum DMA_BIT_MASK to 32 bits for
+ 64-bit systems that have DMA support limited to 32 bits.
+
config ARCH_HAS_DMA_SET_MASK
bool
--
2.34.1
next reply other threads:[~2024-06-19 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 9:17 Alberto Secondi [this message]
2024-06-19 9:23 ` Michael Nazzareno Trimarchi
2024-06-19 9:29 ` Michael Nazzareno Trimarchi
2024-06-19 10:35 ` Robin Murphy
2024-06-19 11:43 ` Michael Nazzareno Trimarchi
2024-06-19 12:46 ` Robin Murphy
2024-06-19 13:21 ` Michael Nazzareno Trimarchi
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=20240619091737.669040-1-albertosecondi@gmail.com \
--to=albertosecondi@gmail.com \
--cc=alberto.secondi@abinsula.com \
--cc=davide.salaris@abinsula.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
/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®