irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4
Subsystems (4)
PATCH v3 1/1 irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4
The T241 platform suffers from the T241-FABRIC-4 erratum which causes unexpected behavior in the GIC when multiple transactions are received simultaneously from different sources. This hardware issue impacts NVIDIA server platforms that use more than two T241 chips interconnected. Each chip has support for 320 {E}SPIs.
This issue occurs when multiple packets from different GICs are incorrectly interleaved at the target chip. The erratum text below specifies exactly what can cause multiple transfer packets susceptible to interleaving and GIC state corruption. GIC state corruption can lead to a range of problems, including kernel panics, and unexpected behavior.
From the erratum text:
"In some cases, inter-socket AXI4 Stream packets with multiple transfers, may be interleaved by the fabric when presented to ARM Generic Interrupt Controller. GIC expects all transfers of a packet to be delivered without any interleaving.
The following GICv3 commands may result in multiple transfer packets over inter-socket AXI4 Stream interface:
- Register reads from GICD_I* and GICD_N*
- Register writes to 64-bit GICD registers other than GICD_IROUTERn*
- ITS command MOVALL
Multiple commands in GICv4+ utilize multiple transfer packets, including VMOVP, VMOVI, VMAPP, and 64-bit register accesses."
This issue impacts system configurations with more than 2 sockets, that require multi-transfer packets to be sent over inter-socket AXI4 Stream interface between GIC instances on different sockets. GICv4 cannot be supported. GICv3 SW model can only be supported with the workaround. Single and Dual socket configurations are not impacted by this issue and support GICv3 and GICv4."
Writing to the chip alias region of the GICD_In{E} registers except GICD_ICENABLERn has an equivalent effect as writing to the global distributor. The SPI interrupt deactivate path is not impacted by the erratum.
To fix this problem, implement a workaround that ensures read accesses to the GICD_In{E} registers are directed to the chip that owns the SPI, and disables GICv4.x features for KVM. To simplify code changes, the gic_configure_irq() function uses the same alias region for both read and write operations to GICD_ICFGR.
---
Changes since v2:
- Add accessors for the SOC-ID version & revision
- Include "linux/bitfield.h" and "linux/bits.h" in irq-gic-v3.c
Changes since v1:
- Use SMCCC SOC-ID API for detecting the T241 chip
- Implement Marc's suggestions
- Edit commit text
Documentation/arm64/silicon-errata.rst | 2 + drivers/firmware/smccc/smccc.c | 26 ++++++ drivers/firmware/smccc/soc_id.c | 28 ++---- drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-gic-v3.c | 115 +++++++++++++++++++++++-- include/linux/arm-smccc.h | 18 ++++ 6 files changed, 158 insertions(+), 32 deletions(-)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -170,6 +170,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | NVIDIA | Carmel Core | N/A | NVIDIA_CARMEL_CNP_ERRATUM | +----------------+-----------------+-----------------+-----------------------------+ +| NVIDIA | T241 GICv3/4.x | T241-FABRIC-4 | N/A | ++----------------+-----------------+-----------------+-----------------------------+ +----------------+-----------------+-----------------+-----------------------------+ | Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | +----------------+-----------------+-----------------+-----------------------------+
drivers/firmware/smccc/smccc.c +26 -0
@@ -17,9 +17,13 @@ static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE;bool __ro_after_init smccc_trng_available = false;u64 __ro_after_init smccc_has_sve_hint = false; +s32 __ro_after_init smccc_soc_id_version =SMCCC_RET_NOT_SUPPORTED ; +s32 __ro_after_init smccc_soc_id_revision =SMCCC_RET_NOT_SUPPORTED ;void __init arm_smccc_version_init (u32 version,enum arm_smccc_conduit conduit) { +struct arm_smccc_res res; + smccc_version = version; smccc_conduit = conduit;
@@ -27,6 +31,18 @@ void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit)if (IS_ENABLED (CONFIG_ARM64_SVE ) && smccc_version >=ARM_SMCCC_VERSION_1_3 ) smccc_has_sve_hint = true; + +if ((smccc_version >=ARM_SMCCC_VERSION_1_2 ) && + (smccc_conduit !=SMCCC_CONDUIT_NONE )) { +arm_smccc_1_1_invoke (ARM_SMCCC_ARCH_FEATURES_FUNC_ID , +ARM_SMCCC_ARCH_SOC_ID , &res); +if ((s32 )res.a0 >=0 ) { +arm_smccc_1_1_invoke (ARM_SMCCC_ARCH_SOC_ID ,0 , &res); + smccc_soc_id_version = (s32 )res.a0; +arm_smccc_1_1_invoke (ARM_SMCCC_ARCH_SOC_ID ,1 , &res); + smccc_soc_id_revision = (s32 )res.a0; + } + } }enum arm_smccc_conduit arm_smccc_1_1_get_conduit (void )
@@ -44,6 +60,16 @@ u32 arm_smccc_get_version(void) }EXPORT_SYMBOL_GPL (arm_smccc_get_version); +s32 arm_smccc_get_soc_id_version (void ) +{ +return smccc_soc_id_version; +} + +s32 arm_smccc_get_soc_id_revision (void ) +{ +return smccc_soc_id_revision; +} +static int __init smccc_devices_init (void ) {struct platform_device *pdev;
drivers/firmware/smccc/soc_id.c +5 -23
@@ -42,41 +42,23 @@ static int __init smccc_soc_init(void)if (arm_smccc_get_version () <ARM_SMCCC_VERSION_1_2 )return 0 ; -if (arm_smccc_1_1_get_conduit () ==SMCCC_CONDUIT_NONE ) { -pr_err ("%s: invalid SMCCC conduit\n" , __func__); -return -EOPNOTSUPP ; - } - -arm_smccc_1_1_invoke (ARM_SMCCC_ARCH_FEATURES_FUNC_ID , -ARM_SMCCC_ARCH_SOC_ID , &res); - -if ((int )res.a0 ==SMCCC_RET_NOT_SUPPORTED ) { + soc_id_version =arm_smccc_get_soc_id_version (); +if (soc_id_version ==SMCCC_RET_NOT_SUPPORTED ) {pr_info ("ARCH_SOC_ID not implemented, skipping ....\n" );return 0 ; } -if ((int )res.a0 <0 ) { -pr_info ("ARCH_FEATURES(ARCH_SOC_ID) returned error: %lx\n" , - res.a0); -return -EINVAL ; - } - -arm_smccc_1_1_invoke (ARM_SMCCC_ARCH_SOC_ID ,0 , &res); -if ((int )res.a0 <0 ) { +if (soc_id_version <0 ) {pr_err ("ARCH_SOC_ID(0) returned error: %lx\n" , res.a0);return -EINVAL ; } - soc_id_version = res.a0; - -arm_smccc_1_1_invoke (ARM_SMCCC_ARCH_SOC_ID ,1 , &res); -if ((int )res.a0 <0 ) { + soc_id_rev =arm_smccc_get_soc_id_revision (); +if (soc_id_rev <0 ) {pr_err ("ARCH_SOC_ID(1) returned error: %lx\n" , res.a0);return -EINVAL ; } - soc_id_rev = res.a0; - soc_dev_attr =kzalloc (sizeof (*soc_dev_attr),GFP_KERNEL );if (!soc_dev_attr)return -ENOMEM ;
drivers/irqchip/Kconfig +1 -0
@@ -35,6 +35,7 @@ config ARM_GIC_V3 select IRQ_DOMAIN_HIERARCHY select PARTITION_PERCPU select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP + select HAVE_ARM_SMCCC_DISCOVERY config ARM_GIC_V3_ITS bool
drivers/irqchip/irq-gic-v3.c +106 -9
207 lines not on this page · raw message
include/linux/arm-smccc.h +18 -0
@@ -226,6 +226,24 @@ void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit);extern u64 smccc_has_sve_hint; +/** +* arm_smccc_get_soc_id_version() +* +* Returns the SOC ID version. +* +* When ARM_SMCCC_ARCH_SOC_ID is not present, returns SMCCC_RET_NOT_SUPPORTED. +*/ +s32 arm_smccc_get_soc_id_version (void ); + +/** +* arm_smccc_get_soc_id_revision() +* +* Returns the SOC ID revision. +* +* When ARM_SMCCC_ARCH_SOC_ID is not present, returns SMCCC_RET_NOT_SUPPORTED. +*/ +s32 arm_smccc_get_soc_id_revision (void ); +/** * struct arm_smccc_res - Result from SMC/HVC call * @a0-a3 result values from registers 0 to 3
Signature · 1 line
2.25.1
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Shanker,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tip/irq/core]
[also build test ERROR on arm64/for-next/core soc/for-next linus/master v6.3-rc2 next-20230317] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Shanker-Donthineni/irqchip-gicv3-Workaround-for-NVIDIA-erratum-T241-FABRIC-4/20230318-003214 patch link: https://lore.kernel.org/r/20230317162636.851085-1-sdonthineni%40nvidia.com patch subject: [PATCH v3] irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4 config: arm-defconfig (https://download.01.org/0day-ci/archive/20230318/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/27a88c95568fc0cfe4537989de4d5e28fe4174c9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shanker-Donthineni/irqchip-gicv3-Workaround-for-NVIDIA-erratum-T241-FABRIC-4/20230318-003214 git checkout 27a88c95568fc0cfe4537989de4d5e28fe4174c9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/bits.h:6,
from include/linux/ioport.h:13,
from include/linux/acpi.h:12,
from drivers/irqchip/irq-gic-v3.c:9:
drivers/irqchip/irq-gic-v3.c: In function 'gic_enable_quirk_nvidia_t241':
>> include/linux/compiler_types.h:358:45: error: call to '__compiletime_assert_251' declared with attribute error: FIELD_GET: type of reg too small for mask
358 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
7 | #define BIT(nr) (UL(1) << (nr))
| ^~
include/linux/compiler_types.h:346:9: note: in expansion of macro '__compiletime_assert'
346 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:358:9: note: in expansion of macro '_compiletime_assert'
358 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:71:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
71 | BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:128:17: note: in expansion of macro '__BF_FIELD_CHECK'
128 | __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \
| ^~~~~~~~~~~~~~~~
drivers/irqchip/irq-gic-v3.c:1781:35: note: in expansion of macro 'FIELD_GET'
1781 | chip_bmask |= BIT(FIELD_GET(T241_CHIPN_MASK,
| ^~~~~~~~~vim +/__compiletime_assert_251 +358 include/linux/compiler_types.h
eb5c2d4b45e3d2 Will Deacon 2020-07-21 344 eb5c2d4b45e3d2 Will Deacon 2020-07-21 345 #define _compiletime_assert(condition, msg, prefix, suffix) \ eb5c2d4b45e3d2 Will Deacon 2020-07-21 346 __compiletime_assert(condition, msg, prefix, suffix) eb5c2d4b45e3d2 Will Deacon 2020-07-21 347 eb5c2d4b45e3d2 Will Deacon 2020-07-21 348 /** eb5c2d4b45e3d2 Will Deacon 2020-07-21 349 * compiletime_assert - break build and emit msg if condition is false eb5c2d4b45e3d2 Will Deacon 2020-07-21 350 * @condition: a compile-time constant condition to check eb5c2d4b45e3d2 Will Deacon 2020-07-21 351 * @msg: a message to emit if condition is false eb5c2d4b45e3d2 Will Deacon 2020-07-21 352 * eb5c2d4b45e3d2 Will Deacon 2020-07-21 353 * In tradition of POSIX assert, this macro will break the build if the eb5c2d4b45e3d2 Will Deacon 2020-07-21 354 * supplied condition is *false*, emitting the supplied error message if the eb5c2d4b45e3d2 Will Deacon 2020-07-21 355 * compiler has support to do so. eb5c2d4b45e3d2 Will Deacon 2020-07-21 356 */ eb5c2d4b45e3d2 Will Deacon 2020-07-21 357 #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21 @358 _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)eb5c2d4b45e3d2 Will Deacon 2020-07-21 359
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Hi Marc,
Quoted 10 lines · Shanker Donthineni
#define
T241_CHIPN_MASKGENMASK_ULL(45, 44)drivers/irqchip/irq-gic-v3.c +9
-0+#define T241_CHIP_GICDA_OFFSET 0x1580000 +#define SMCCC_SOC_ID_T241 0x036b0241 + +static bool gic_enable_quirk_nvidia_t241 (void *data) +{ +s32 soc_id =arm_smccc_get_soc_id_version (); +unsigned long chip_bmask =0 ; +phys_addr_t phys; +u32 i;
drivers/irqchip/irq-gic-v3.c static bool gic_enable_quirk_hip06_07(void *data) · line 1776
Quoted 10 lines
drivers/irqchip/irq-gic-v3.c +10
-0+ +/* Check JEP106 code for NVIDIA T241 chip (036b:0241) */ +if ((soc_id <0 ) || (soc_id !=SMCCC_SOC_ID_T241 )) +return false; + +/* Find the chips based on GICR regions PHYS addr */ +for (i =0 ; i < gic_data.nr_redist_regions; i++) { + chip_bmask |=BIT (FIELD_GET (T241_CHIPN_MASK , + gic_data.redist_regions[i].phys_base)); + }
Apologies for the oversight on my part, I failed to address the build issue for the 32-bit architecture and mistakenly submitted an incorrect patch.
Please ignore this patch and review v4 patch.
Correct change:
for (i = 0; i < gic_data.nr_redist_regions; i++) {
chip_bmask |= BIT(FIELD_GET(T241_CHIPN_MASK,- gic_data.redist_regions[i].phys_base));
+ (u64)gic_data.redist_regions[i].phys_base));
-Shaker