arm: mach-k3: Refactor QoS settings
Subsystems (2)
PATCH 1/1 arm: mach-k3: Refactor QoS settings
Refactor common QoS code into a new common header file, and the soc specific setup_qos functions into a common API.
Rename $(soc)_qos_count and $(soc)_qos_data variables to qos_count and qos_data. When QoS settings of more SoCs are added, only one pair will be defined at a time, based on the config SOC_K3_$(soc).
This refactoring has been done for 2 major purposes.
- The auto-generated $(soc)_qos_data.c and $(soc)_qos.h files cannot have any code that is specific to any bootloader. Those files have to remain agnostic of different bootloader implementations and their header files.
- The existing implementation was less than ideal and would have enabled multiple $(soc)_qos_count and $(soc)_qos_data variables for all SoC variants.
---
arch/arm/mach-k3/Kconfig | 8 +++++++
arch/arm/mach-k3/am62a7_init.c | 14 ------------
arch/arm/mach-k3/common.c | 12 ++++++++++
arch/arm/mach-k3/common.h | 8 +++++++
arch/arm/mach-k3/include/mach/hardware.h | 9 --------
arch/arm/mach-k3/include/mach/k3-qos.h | 22 +++++++++++++++++++
arch/arm/mach-k3/r5/am62ax/Makefile | 2 +-
.../{include/mach => r5/am62ax}/am62a_qos.h | 0
.../{am62a_qos_data.c => am62a_qos_uboot.c} | 9 ++++----
9 files changed, 56 insertions(+), 28 deletions(-)
create mode 100644 arch/arm/mach-k3/include/mach/k3-qos.h
rename arch/arm/mach-k3/{include/mach => r5/am62ax}/am62a_qos.h (100%)
rename arch/arm/mach-k3/r5/am62ax/{am62a_qos_data.c => am62a_qos_uboot.c} (85%)arch/arm/mach-k3/Kconfig +8 -0
@@ -139,6 +139,14 @@ config K3_DM_FW bootloader, it makes RM and PM services not being available during R5 SPL execution time. +config K3_QOS + bool "Enable Quality of Service (QoS) Settings for TI K3 SoCs" + default y if CPU_V7R && SOC_K3_AM62A7 + help + This option enables the R5 SPL to apply QoS settings for various + HW controllers inside the TI K3 SoCs. The files for QoS settings are + generated from Sysconfig and k3-resource-partitioning tools. + config K3_X509_SWRV int "SWRV for X509 certificate used for boot images" default 1
arch/arm/mach-k3/am62a7_init.c +0 -14
@@ -69,20 +69,6 @@ static void ctrl_mmr_unlock(void)mmr_unlock (PADCFG_MMR1_BASE ,1 ); } -#if (IS_ENABLED (CONFIG_CPU_V7R )) -static void setup_qos (void ) -{ -u32 i; - -for (i =0 ; i < am62a_qos_count; i++) -writel (am62a_qos_data[i].val, (uintptr_t )am62a_qos_data[i].reg); -} -#else -static void setup_qos (void ) -{ -} -#endif -void board_init_f (ulong dummy) {struct udevice *dev;
arch/arm/mach-k3/common.c +12 -0
@@ -28,6 +28,8 @@#include <elf.h> #include <soc.h> +#include <asm/arch/k3-qos.h> +#if IS_ENABLED (CONFIG_SYS_K3_SPL_ATF )enum { IMAGE_ID_ATF,
@@ -595,3 +597,13 @@ int misc_init_r(void)void __weak do_board_detect (void ) { } + +#if (IS_ENABLED (CONFIG_K3_QOS )) +void setup_qos (void ) +{ +u32 i; + +for (i =0 ; i < qos_count; i++) +writel (qos_data[i].val, (uintptr_t )qos_data[i].reg); +} +#endif
arch/arm/mach-k3/common.h +8 -0
@@ -45,3 +45,11 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size);struct ti_sci_handle *get_ti_sci_handle (void );void do_board_detect (void );void ti_secure_image_check_binary (void **p_image,size_t *p_size); + +#if (IS_ENABLED (CONFIG_K3_QOS )) +void setup_qos (void ); +#else +static inline void setup_qos (void ) +{ +} +#endif
arch/arm/mach-k3/include/mach/hardware.h +0 -9
@@ -30,7 +30,6 @@#ifdef CONFIG_SOC_K3_AM62A7 #include "am62a_hardware.h" -#include "am62a_qos.h" #endif /* Assuming these addresses and definitions stay common across K3 devices */
@@ -97,12 +96,4 @@ struct rom_extended_boot_data { u32 num_components; }; -struct k3_qos_data { -u32 reg; -u32 val; -}; - -extern struct k3_qos_data am62a_qos_data[]; -extern u32 am62a_qos_count; -#endif /* _ASM_ARCH_HARDWARE_H_ */
arch/arm/mach-k3/include/mach/k3-qos.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Quality of Service (QoS) Configuration Header File +* +* Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/ +*/ +#ifndef _K3_QOS_H_ +#define _K3_QOS_H_ + +#include <linux/kernel.h> + +struct k3_qos_data { +u32 reg; +u32 val; +}; + +#if (IS_ENABLED (CONFIG_K3_QOS )) +extern struct k3_qos_data qos_data[]; +extern u32 qos_count; +#endif + +#endif /* _K3_QOS_H_ */
arch/arm/mach-k3/r5/am62ax/Makefile +1 -1
@@ -4,4 +4,4 @@ obj-y += clk-data.o obj-y += dev-data.o -obj-y += am62a_qos_data.o +obj-y += am62a_qos_uboot.o
arch/arm/mach-k3/r5/am62ax/am62a_qos.h renamed from arch/arm/mach-k3/include/mach/am62a_qos.h +0 -0
arch/arm/mach-k3/r5/am62ax/am62a_qos_uboot.c renamed from arch/arm/mach-k3/r5/am62ax/am62a_qos_data.c +5 -4
@@ -5,10 +5,11 @@* * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ */ -#include <asm/arch/hardware.h> -#include "common.h" -struct k3_qos_data am62a_qos_data[] = { +#include <asm/arch/k3-qos.h> +#include "am62a_qos.h" + +struct k3_qos_data qos_data[] = {/* modules_qosConfig0 - 1 endpoints, 4 channels */ { .reg =K3_DSS_UL_MAIN_0_VBUSM_DMA +0x100 +0x4 *0 ,
@@ -43,4 +44,4 @@ struct k3_qos_data am62a_qos_data[] = { }, }; -uint32_t am62a_qos_count =sizeof (am62a_qos_data) /sizeof (am62a_qos_data[0 ]); +u32 qos_count =ARRAY_SIZE (qos_data);
base-commit: daa3100250839dd30626f7f4b7daf041f1114f1c
Signature · 1 line
2.34.1
Quoted 39 lines · Aradhya Bhatia
Refactor common QoS code into a new common header file, and the soc specific
setup_qosfunctions into a common API.Rename $(soc)_qos_count and $(soc)_qos_data variables to
qos_countandqos_data. When QoS settings of more SoCs are added, only one pair will be defined at a time, based on the config SOC_K3_$(soc).This refactoring has been done for 2 major purposes.
- The auto-generated $(soc)_qos_data.c and $(soc)_qos.h files cannot have any code that is specific to any bootloader. Those files have to remain agnostic of different bootloader implementations and their header files.
- The existing implementation was less than ideal and would have enabled multiple $(soc)_qos_count and $(soc)_qos_data variables for all SoC variants.
Signed-off-by Aradhya Bhatia <[email protected]>--- arch/arm/mach-k3/Kconfig | 8 +++++++ arch/arm/mach-k3/am62a7_init.c | 14 ------------ arch/arm/mach-k3/common.c | 12 ++++++++++ arch/arm/mach-k3/common.h | 8 +++++++ arch/arm/mach-k3/include/mach/hardware.h | 9 -------- arch/arm/mach-k3/include/mach/k3-qos.h | 22 +++++++++++++++++++ arch/arm/mach-k3/r5/am62ax/Makefile | 2 +- .../{include/mach => r5/am62ax}/am62a_qos.h | 0 .../{am62a_qos_data.c => am62a_qos_uboot.c} | 9 ++++---- 9 files changed, 56 insertions(+), 28 deletions(-)create mode 100644
arch/arm/mach-k3/include/mach/k3-qos.h
renamearch/arm/mach-k3/{include/mach=>r5/am62ax}/am62a_qos.h(100%) renamearch/arm/mach-k3/r5/am62ax/{am62a_qos_data.c=>am62a_qos_uboot.c} (85%)arch/arm/mach-k3/Kconfig +0
-0
arch/arm/mach-k3/Kconfig config K3_DM_FW · line 144
Quoted 6 lines
arch/arm/mach-k3/Kconfig +3
-0@@ -139,6 +139,14 @@ config K3_DM_FW bootloader, it makes RM and PM services not being available during R5 SPL execution time. +config K3_QOS + bool "Enable Quality of Service (QoS) Settings for TI K3 SoCs" + default y if CPU_V7R && SOC_K3_AM62A7
If this is R5 only, then put it in the arch/arm/mach-k3/r5 Kconfig and you can drop the CPU_V7R check.
Andrew
Quoted 173 lines
arch/arm/mach-k3/Kconfig +5
-0+ help + This option enables the R5 SPL to apply QoS settings for various + HW controllers inside the TI K3 SoCs. The files for QoS settings are + generated from Sysconfig and k3-resource-partitioning tools. + config K3_X509_SWRV int "SWRV for X509 certificate used for boot images" default 1arch/arm/mach-k3/am62a7_init.c +0
-14@@ -69,20 +69,6 @@ static void ctrl_mmr_unlock(void)mmr_unlock (PADCFG_MMR1_BASE ,1 ); } -#if (IS_ENABLED (CONFIG_CPU_V7R )) -static void setup_qos (void ) -{ -u32 i; - -for (i =0 ; i < am62a_qos_count; i++) -writel (am62a_qos_data[i].val, (uintptr_t )am62a_qos_data[i].reg); -} -#else -static void setup_qos (void ) -{ -} -#endif -void board_init_f (ulong dummy) {struct udevice *dev;arch/arm/mach-k3/common.c +12
-0@@ -28,6 +28,8 @@#include <elf.h> #include <soc.h> +#include <asm/arch/k3-qos.h> +#if IS_ENABLED (CONFIG_SYS_K3_SPL_ATF )enum { IMAGE_ID_ATF,@@ -595,3 +597,13 @@ int misc_init_r(void)void __weak do_board_detect (void ) { } + +#if (IS_ENABLED (CONFIG_K3_QOS )) +void setup_qos (void ) +{ +u32 i; + +for (i =0 ; i < qos_count; i++) +writel (qos_data[i].val, (uintptr_t )qos_data[i].reg); +} +#endif arch/arm/mach-k3/common.h +8
-0@@ -45,3 +45,11 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size);struct ti_sci_handle *get_ti_sci_handle (void );void do_board_detect (void );void ti_secure_image_check_binary (void **p_image,size_t *p_size); + +#if (IS_ENABLED (CONFIG_K3_QOS )) +void setup_qos (void ); +#else +static inline void setup_qos (void ) +{ +} +#endif arch/arm/mach-k3/include/mach/hardware.h +0
-9@@ -30,7 +30,6 @@#ifdef CONFIG_SOC_K3_AM62A7 #include "am62a_hardware.h" -#include "am62a_qos.h" #endif /* Assuming these addresses and definitions stay common across K3 devices */ @@ -97,12 +96,4 @@ struct rom_extended_boot_data { u32 num_components; }; -struct k3_qos_data { -u32 reg; -u32 val; -}; - -extern struct k3_qos_data am62a_qos_data[]; -extern u32 am62a_qos_count; -#endif /* _ASM_ARCH_HARDWARE_H_ */ arch/arm/mach-k3/include/mach/k3-qos.h new file +22
-0@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Quality of Service (QoS) Configuration Header File +* +* Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/ +*/ +#ifndef _K3_QOS_H_ +#define _K3_QOS_H_ + +#include <linux/kernel.h> + +struct k3_qos_data { +u32 reg; +u32 val; +}; + +#if (IS_ENABLED (CONFIG_K3_QOS )) +extern struct k3_qos_data qos_data[]; +extern u32 qos_count; +#endif + +#endif /* _K3_QOS_H_ */ arch/arm/mach-k3/r5/am62ax/Makefile +1
-1@@ -4,4 +4,4 @@ obj-y += clk-data.o obj-y += dev-data.o -obj-y += am62a_qos_data.o +obj-y += am62a_qos_uboot.oarch/arm/mach-k3/r5/am62ax/am62a_qos.h renamed from arch/arm/mach-k3/include/mach/am62a_qos.h +0
-0arch/arm/mach-k3/r5/am62ax/am62a_qos_uboot.c renamed from arch/arm/mach-k3/r5/am62ax/am62a_qos_data.c +5
-4@@ -5,10 +5,11 @@* * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ */ -#include <asm/arch/hardware.h> -#include "common.h" -struct k3_qos_data am62a_qos_data[] = { +#include <asm/arch/k3-qos.h> +#include "am62a_qos.h" + +struct k3_qos_data qos_data[] = {/* modules_qosConfig0 - 1 endpoints, 4 channels */ { .reg =K3_DSS_UL_MAIN_0_VBUSM_DMA +0x100 +0x4 *0 ,@@ -43,4 +44,4 @@ struct k3_qos_data am62a_qos_data[] = { }, }; -uint32_t am62a_qos_count =sizeof (am62a_qos_data) /sizeof (am62a_qos_data[0 ]); +u32 qos_count =ARRAY_SIZE (qos_data);base-commit:
daa3100250839dd30626f7f4b7daf041f1114f1c
Quoted 50 lines · Andrew Davis
Quoted 40 lines · Aradhya Bhatia
Refactor common QoS code into a new common header file, and the soc specific
setup_qosfunctions into a common API.Rename $(soc)_qos_count and $(soc)_qos_data variables to
qos_countandqos_data. When QoS settings of more SoCs are added, only one pair will be defined at a time, based on the config SOC_K3_$(soc).This refactoring has been done for 2 major purposes.
- The auto-generated $(soc)_qos_data.c and $(soc)_qos.h files cannot have any code that is specific to any bootloader. Those files have to remain agnostic of different bootloader implementations and their header files.
- The existing implementation was less than ideal and would have enabled multiple $(soc)_qos_count and $(soc)_qos_data variables for all SoC variants.
Signed-off-by Aradhya Bhatia <[email protected]>---
arch/arm/mach-k3/Kconfig | 8 +++++++ arch/arm/mach-k3/am62a7_init.c | 14 ------------ arch/arm/mach-k3/common.c | 12 ++++++++++ arch/arm/mach-k3/common.h | 8 +++++++ arch/arm/mach-k3/include/mach/hardware.h | 9 -------- arch/arm/mach-k3/include/mach/k3-qos.h | 22 +++++++++++++++++++ arch/arm/mach-k3/r5/am62ax/Makefile | 2 +- .../{include/mach => r5/am62ax}/am62a_qos.h | 0.../{am62a_qos_data.c=> am62a_qos_uboot.c} | 9 ++++----9 files changed, 56 insertions(+), 28 deletions(-)create mode 100644
arch/arm/mach-k3/include/mach/k3-qos.hrenamearch/arm/mach-k3/{include/mach=>r5/am62ax}/am62a_qos.h(100%) renamearch/arm/mach-k3/r5/am62ax/{am62a_qos_data.c=>am62a_qos_uboot.c} (85%)arch/arm/mach-k3/Kconfig +0
-0@@ -139,6 +139,14 @@ config K3_DM_FWQuoted 5 lines
bootloader, it makes RM and PM services not being available during R5 SPL execution time.
+configK3_QOS
+ bool "Enable Quality of Service (QoS) Settings for TI K3 SoCs" + default y ifCPU_V7R&&SOC_K3_AM62A7If this is R5 only, then put it in the
arch/arm/mach-k3/r5Kconfigand you can drop theCPU_V7Rcheck.
Quoted 1 line
Andrew
That would indeed be better. Thanks!
Regards
Aradhya
Quoted 178 lines
Quoted 178 lines
+ help
+ This option enables the R5 SPL to apply QoS settings for various + HW controllers inside the TI K3 SoCs. The files for QoS settings are
+ generated from Sysconfig and k3-resource-partitioning tools. +
configK3_X509_SWRV
int "SWRV for X509 certificate used for boot images" default 1arch/arm/mach-k3/am62a7_init.c +0
-13@@ -69,20 +69,6 @@ static void ctrl_mmr_unlock(void) mmr_unlock(PADCFG_MMR1_BASE, 1); } -#if (IS_ENABLED(CONFIG_CPU_V7R)) -static void setup_qos (void ) -{ - u32 i; - - for (i = 0; i < am62a_qos_count; i++) - writel(am62a_qos_data[i].val, (uintptr_t)am62a_qos_data[i].reg); -} -#else -static void setup_qos (void ) -{ -} -#endif - void board_init_f(ulong dummy) { struct udevice *dev;arch/arm/mach-k3/common.c +0
-0@@ -28,6 +28,8 @@ #include <elf.h> #include <soc.h>+#include <
asm/arch/k3-qos.h>
+
#ifIS_ENABLED(CONFIG_SYS_K3_SPL_ATF)
enum {
IMAGE_ID_ATF,arch/arm/mach-k3/common.c +10
-0@@ -595,3 +597,13 @@ int misc_init_r(void) void __weak do_board_detect(void) { } + +#if (IS_ENABLED (CONFIG_K3_QOS )) +void setup_qos (void ) +{ + u32 i; + + for (i = 0; i < qos_count; i++) + writel(qos_data[i].val, (uintptr_t)qos_data[i].reg); +} +#endif arch/arm/mach-k3/common.h +0
-0@@ -45,3 +45,11 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size); struct ti_sci_handle *get_ti_sci_handle(void); void do_board_detect(void);void
ti_secure_image_check_binary(void **p_image, size_t *p_size);arch/arm/mach-k3/common.h +8
-0+ +#if (IS_ENABLED (CONFIG_K3_QOS )) +void setup_qos (void ); +#else +static inline void setup_qos (void ) +{ +} +#endif arch/arm/mach-k3/include/mach/hardware.h +0
-1@@ -30,7 +30,6 @@ #ifdef CONFIG_SOC_K3_AM62A7 #include "am62a_hardware.h" -#include "am62a_qos.h" #endif /* Assuming these addresses and definitions stay common across K3devices */
arch/arm/mach-k3/include/mach/hardware.h +0
-7@@ -97,12 +96,4 @@ struct rom_extended_boot_data { u32 num_components; }; -struct k3_qos_data { - u32 reg; - u32 val; -}; - -extern struct k3_qos_data am62a_qos_data[]; -extern u32 am62a_qos_count; - #endif /* _ASM_ARCH_HARDWARE_H_ */arch/arm/mach-k3/include/mach/k3-qos.h new file +5
-0@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Quality of Service (QoS) Configuration Header File +* +* Copyright (C) 2024 Texas Instruments Incorporated - arch/arm/mach-k3/include/mach/k3-qos.h new file +16
-0+#ifndef _K3_QOS_H_ +#define _K3_QOS_H_ + +#include <linux/kernel.h> + +struct k3_qos_data { + u32 reg; + u32 val; +}; + +#if (IS_ENABLED (CONFIG_K3_QOS )) +extern struct k3_qos_data qos_data[]; +extern u32 qos_count; +#endif + +#endif /* _K3_QOS_H_ */ arch/arm/mach-k3/r5/am62ax/Makefile +0
-0@@ -4,4 +4,4 @@obj-y += clk-data.o
obj-y += dev-data.oarch/arm/mach-k3/r5/am62ax/Makefile +1
-1-obj-y += am62a_qos_data.o +obj-y += am62a_qos_uboot.oarch/arm/mach-k3/r5/am62ax/am62a_qos.h renamed from arch/arm/mach-k3/include/mach/am62a_qos.h +0
-0arch/arm/mach-k3/r5/am62ax/am62a_qos_uboot.c renamed from arch/arm/mach-k3/r5/am62ax/am62a_qos_data.c +0
-0@@ -5,10 +5,11 @@ * * Copyright (C) 2022 Texas Instruments Incorporated -arch/arm/mach-k3/r5/am62ax/am62a_qos_uboot.c renamed from arch/arm/mach-k3/r5/am62ax/am62a_qos_data.c +0
-2-#include <asm/arch/hardware.h> -#include "common.h" -struct
k3_qos_dataam62a_qos_data[] = {arch/arm/mach-k3/r5/am62ax/am62a_qos_uboot.c renamed from arch/arm/mach-k3/r5/am62ax/am62a_qos_data.c +4
-0+#include <asm/arch/k3-qos.h> +#include "am62a_qos.h" + +struct k3_qos_data qos_data[] = {/*
modules_qosConfig0- 1 endpoints, 4 channels */ {
.reg =K3_DSS_UL_MAIN_0_VBUSM_DMA+0x100+0x4* 0,arch/arm/mach-k3/r5/am62ax/am62a_qos_uboot.c renamed from arch/arm/mach-k3/r5/am62ax/am62a_qos_data.c +0
-0@@ -43,4 +44,4 @@ struct k3_qos_data am62a_qos_data[] = { }, };-uint32_t
am62a_qos_count=sizeof(am62a_qos_data)/sizeof(am62a_qos_data[0]);
+u32qos_count=ARRAY_SIZE(qos_data);base-commit:
daa3100250839dd30626f7f4b7daf041f1114f1c