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 <[email protected]>
  • Loading branch information
huaqianli committed Dec 11, 2024
1 parent b6f57ce commit a52ed0b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
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:
hailo: |
IOT2050_META_HAILO = "1"
hailo_override: |
OVERRIDES .= ":meta-hailo"
repos:
meta-iot2050:
Expand Down
1 change: 1 addition & 0 deletions recipes-kernel/linux/files/iot2050_defconfig_hailo.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SWIOTLB_SEGSIZE=256
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Li Hua Qian <[email protected]>
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 <[email protected]>
---
include/linux/swiotlb.h | 2 +-
kernel/dma/Kconfig | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 35bc4e281c21..09d0ad1304a9 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -22,7 +22,7 @@ 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
+#define IO_TLB_SEGSIZE CONFIG_SWIOTLB_SEGSIZE

/*
* 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
14 changes: 13 additions & 1 deletion recipes-kernel/linux/linux-iot2050-6.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@ def get_patches(d, patchdir):

return ' '.join(['file://' + patch[len(files_dir)+1:] for patch in patches])

def get_extra_cfg(d):
import re

overrides = d.getVar('OVERRIDES')
extra_cfg = ""

if re.search("meta-hailo", overrides):
extra_cfg += " file://iot2050_defconfig_hailo.cfg"

return extra_cfg

SRC_URI += " \
https://cdn.kernel.org/pub/linux/kernel/projects/cip/6.1/linux-cip-${PV}.tar.xz \
${@get_patches(d, 'patches-6.1')} \
file://patches-6.1/ \
file://${KERNEL_DEFCONFIG} \
file://iot2050_defconfig_extra.cfg"
SRC_URI:append:pvu-dma = " \
file://iot2050_defconfig_pvu.cfg"
file://iot2050_defconfig_pvu.cfg \
${@get_extra_cfg(d)}"

S = "${WORKDIR}/linux-cip-${PV}"

Expand Down

0 comments on commit a52ed0b

Please sign in to comment.