Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARC: allow userspace DSP applications to use AGU extensions

To be able to run DSP-enabled userspace applications with AGU
(address generation unit) extensions we additionally need to
save and restore following registers at context switch:
* AGU_AP*
* AGU_OS*
* AGU_MOD*

Reviewed-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

authored by

Eugeniy Paltsev and committed by
Vineet Gupta
f09d3174 7321e2ea

+66
+9
arch/arc/Kconfig
··· 445 445 help 446 446 DSP extension presence in HW, support save / restore DSP registers to 447 447 run DSP-enabled userspace applications 448 + 449 + config ARC_DSP_AGU_USERSPACE 450 + bool "Support DSP with AGU for userspace apps" 451 + select ARC_HAS_ACCL_REGS 452 + select ARC_DSP_HANDLED 453 + select ARC_DSP_SAVE_RESTORE_REGS 454 + help 455 + DSP and AGU extensions presence in HW, support save / restore DSP 456 + and AGU registers to run DSP-enabled userspace applications 448 457 endchoice 449 458 450 459 config ARC_IRQ_NO_AUTOSAVE
+12
arch/arc/include/asm/arcregs.h
··· 132 132 #define ARC_AUX_DSP_CTRL 0x59F 133 133 #define ARC_AUX_DSP_FFT_CTRL 0x59E 134 134 135 + #define ARC_AUX_AGU_BUILD 0xCC 136 + #define ARC_AUX_AGU_AP0 0x5C0 137 + #define ARC_AUX_AGU_AP1 0x5C1 138 + #define ARC_AUX_AGU_AP2 0x5C2 139 + #define ARC_AUX_AGU_AP3 0x5C3 140 + #define ARC_AUX_AGU_OS0 0x5D0 141 + #define ARC_AUX_AGU_OS1 0x5D1 142 + #define ARC_AUX_AGU_MOD0 0x5E0 143 + #define ARC_AUX_AGU_MOD1 0x5E1 144 + #define ARC_AUX_AGU_MOD2 0x5E2 145 + #define ARC_AUX_AGU_MOD3 0x5E3 146 + 135 147 #ifndef __ASSEMBLY__ 136 148 137 149 #include <soc/arc/aux.h>
+10
arch/arc/include/asm/asserts.h
··· 10 10 /* Helpers to sanitize config options. */ 11 11 12 12 void chk_opt_strict(char *opt_name, bool hw_exists, bool opt_ena); 13 + void chk_opt_weak(char *opt_name, bool hw_exists, bool opt_ena); 13 14 14 15 /* 15 16 * Check required config option: ··· 20 19 #define CHK_OPT_STRICT(opt_name, hw_exists) \ 21 20 ({ \ 22 21 chk_opt_strict(#opt_name, hw_exists, IS_ENABLED(opt_name)); \ 22 + }) 23 + 24 + /* 25 + * Check optional config option: 26 + * - panic in case of OPT enabled but corresponding HW absent. 27 + */ 28 + #define CHK_OPT_WEAK(opt_name, hw_exists) \ 29 + ({ \ 30 + chk_opt_weak(#opt_name, hw_exists, IS_ENABLED(opt_name)); \ 23 31 }) 24 32 25 33 #endif /* __ASM_ARC_ASSERTS_H */
+24
arch/arc/include/asm/dsp-impl.h
··· 103 103 104 104 DSP_AUX_SAVE_RESTORE(saveto, readfrom, DSP_BFLY0); 105 105 DSP_AUX_SAVE_RESTORE(saveto, readfrom, DSP_FFT_CTRL); 106 + 107 + #ifdef CONFIG_ARC_DSP_AGU_USERSPACE 108 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_AP0); 109 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_AP1); 110 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_AP2); 111 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_AP3); 112 + 113 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_OS0); 114 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_OS1); 115 + 116 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_MOD0); 117 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_MOD1); 118 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_MOD2); 119 + DSP_AUX_SAVE_RESTORE(saveto, readfrom, AGU_MOD3); 120 + #endif /* CONFIG_ARC_DSP_AGU_USERSPACE */ 106 121 } 107 122 108 123 #else /* !CONFIG_ARC_DSP_SAVE_RESTORE_REGS */ ··· 132 117 return !!bcr.ver; 133 118 } 134 119 120 + static inline bool agu_exist(void) 121 + { 122 + struct bcr_generic bcr; 123 + 124 + READ_BCR(ARC_AUX_AGU_BUILD, bcr); 125 + return !!bcr.ver; 126 + } 127 + 135 128 static inline void dsp_config_check(void) 136 129 { 137 130 CHK_OPT_STRICT(CONFIG_ARC_DSP_HANDLED, dsp_exist()); 131 + CHK_OPT_WEAK(CONFIG_ARC_DSP_AGU_USERSPACE, agu_exist()); 138 132 } 139 133 140 134 #endif /* __ASEMBLY__ */
+5
arch/arc/include/asm/dsp.h
··· 17 17 */ 18 18 struct dsp_callee_regs { 19 19 unsigned long ACC0_GLO, ACC0_GHI, DSP_BFLY0, DSP_FFT_CTRL; 20 + #ifdef CONFIG_ARC_DSP_AGU_USERSPACE 21 + unsigned long AGU_AP0, AGU_AP1, AGU_AP2, AGU_AP3; 22 + unsigned long AGU_OS0, AGU_OS1; 23 + unsigned long AGU_MOD0, AGU_MOD1, AGU_MOD2, AGU_MOD3; 24 + #endif 20 25 }; 21 26 22 27 #endif /* !__ASSEMBLY__ */
+6
arch/arc/kernel/setup.c
··· 399 399 panic("Disable %s, hardware NOT present\n", opt_name); 400 400 } 401 401 402 + void chk_opt_weak(char *opt_name, bool hw_exists, bool opt_ena) 403 + { 404 + if (!hw_exists && opt_ena) 405 + panic("Disable %s, hardware NOT present\n", opt_name); 406 + } 407 + 402 408 static void arc_chk_core_config(void) 403 409 { 404 410 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];