From d71b2617166761078c9a5d2a02b8d8d090cfd4be Mon Sep 17 00:00:00 2001 From: Li Hua Qian Date: Tue, 3 Dec 2024 11:00:51 +0800 Subject: [PATCH] meta-hailo: Fix the CMA issue when PVU was integrated 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 --- kas/opt/meta-hailo.yml | 2 + ...tlb-Make-IO_TLB_SEGSIZE-configurable.patch | 50 +++++++++++++++++++ recipes-kernel/linux/linux-iot2050-6.1.inc | 2 + 3 files changed, 54 insertions(+) create mode 100644 recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch diff --git a/kas/opt/meta-hailo.yml b/kas/opt/meta-hailo.yml index a0844ee17..d4b26a7e9 100644 --- a/kas/opt/meta-hailo.yml +++ b/kas/opt/meta-hailo.yml @@ -14,6 +14,8 @@ header: local_conf_header: no-hailo: | IOT2050_META_HAILO = "1" + hailo_override: | + OVERRIDES .= ":meta-hailo" repos: meta-hailo: diff --git a/recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch b/recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch new file mode 100644 index 000000000..0a3859634 --- /dev/null +++ b/recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Li Hua Qian +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 +--- + 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 diff --git a/recipes-kernel/linux/linux-iot2050-6.1.inc b/recipes-kernel/linux/linux-iot2050-6.1.inc index 613a53a8e..271768d01 100644 --- a/recipes-kernel/linux/linux-iot2050-6.1.inc +++ b/recipes-kernel/linux/linux-iot2050-6.1.inc @@ -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')