Skip to content

Commit

Permalink
meta-hailo: Fix the CMA issue when PVU was integrated
Browse files Browse the repository at this point in the history
PVU-based DMA isolation brings SWIO TLB to the table and
the maximum allowable number of contiguous slabs to map
is 128 by default, but meta-hailo requires more than 128.
Hence increase it to 256 when meta-hailo is included.

Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
  • Loading branch information
huaqianli committed Dec 3, 2024
1 parent 9a7fbeb commit b264f92
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kas/opt/meta-hailo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ header:
local_conf_header:
no-hailo: |
IOT2050_META_HAILO = "1"
hailo_override: |
OVERRIDES .= ":meta-hailo"
repos:
meta-hailo:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Li Hua Qian <huaqian.li@siemens.com>
Date: Tue, 3 Dec 2024 14:49:59 +0800
Subject: [PATCH] swiotlb: Make IO_TLB_SEGSIZE configurable

In some applications, the default value of 128 is not sufficient for
memory allocation and can cause runtime errors. This change makes
IO_TLB_SEGSIZE configurable, allowing it to be increased if needed.

Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
include/linux/swiotlb.h | 6 +++++-
kernel/dma/Kconfig | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 35bc4e281c21..bf1e1f5cd67b 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -22,7 +22,11 @@ struct scatterlist;
* must be a power of 2. What is the appropriate value ?
* The complexity of {map,unmap}_single is linearly dependent on this value.
*/
-#define IO_TLB_SEGSIZE 128
+#ifdef CONFIG_SWIOTLB_SEGSIZE
+#define IO_TLB_SEGSIZE CONFIG_SWIOTLB_SEGSIZE
+#else
+#define IO_TLB_SEGSIZE 128
+#endif

/*
* log of the size of each IO TLB slab. The number of slabs is command line
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
index 56866aaa2ae1..2eebe8836100 100644
--- a/kernel/dma/Kconfig
+++ b/kernel/dma/Kconfig
@@ -80,6 +80,13 @@ config SWIOTLB
bool
select NEED_DMA_MAP_STATE

+config SWIOTLB_SEGSIZE
+ int "SWIOTLB segment size"
+ default 128
+ help
+ Set the maximum allowable number of contiguous slabs to map.
+ Must be a power of 2.
+
config DMA_RESTRICTED_POOL
bool "DMA Restricted Pool"
depends on OF && OF_RESERVED_MEM && SWIOTLB
2 changes: 2 additions & 0 deletions recipes-kernel/linux/linux-iot2050-6.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def get_extra_configs(d):

if re.search("pvu-dma", overrides):
append_config.append('CONFIG_TI_PVU=y')
if re.search("meta-hailo", overrides):
append_config.append('CONFIG_SWIOTLB_SEGSIZE=256')

if append_config:
append_config_file = os.path.join(d.getVar('T'), 'iot2050_append_config.cfg')
Expand Down

0 comments on commit b264f92

Please sign in to comment.