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

arm64/sme: Expose SMIDR through sysfs

We currently expose MIDR and REVID to userspace through sysfs to enable it
to make decisions based on the specific implementation. Since SME supports
implementations where streaming mode is provided by a separate hardware
unit called a SMCU it provides a similar ID register SMIDR. Expose it to
userspace via sysfs when the system supports SME along with the other ID
registers.

Since we disable the SME priority mapping feature if it is supported by
hardware we currently mask out the SMPS bit which reports that it is
supported.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220607132857.1358361-1-broonie@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Mark Brown and committed by
Will Deacon
d69d5649 a111daf0

+25 -2
+2 -1
Documentation/ABI/testing/sysfs-devices-system-cpu
··· 493 493 /sys/devices/system/cpu/cpuX/regs/identification/ 494 494 /sys/devices/system/cpu/cpuX/regs/identification/midr_el1 495 495 /sys/devices/system/cpu/cpuX/regs/identification/revidr_el1 496 + /sys/devices/system/cpu/cpuX/regs/identification/smidr_el1 496 497 Date: June 2016 497 498 Contact: Linux ARM Kernel Mailing list <linux-arm-kernel@lists.infradead.org> 498 499 Description: AArch64 CPU registers 499 500 500 501 'identification' directory exposes the CPU ID registers for 501 - identifying model and revision of the CPU. 502 + identifying model and revision of the CPU and SMCU. 502 503 503 504 What: /sys/devices/system/cpu/aarch32_el0 504 505 Date: May 2021
+1
arch/arm64/include/asm/cpu.h
··· 46 46 u64 reg_midr; 47 47 u64 reg_revidr; 48 48 u64 reg_gmid; 49 + u64 reg_smidr; 49 50 50 51 u64 reg_id_aa64dfr0; 51 52 u64 reg_id_aa64dfr1;
+22 -1
arch/arm64/kernel/cpuinfo.c
··· 267 267 268 268 CPUREGS_ATTR_RO(midr_el1, midr); 269 269 CPUREGS_ATTR_RO(revidr_el1, revidr); 270 + CPUREGS_ATTR_RO(smidr_el1, smidr); 270 271 271 272 static struct attribute *cpuregs_id_attrs[] = { 272 273 &cpuregs_attr_midr_el1.attr, ··· 277 276 278 277 static const struct attribute_group cpuregs_attr_group = { 279 278 .attrs = cpuregs_id_attrs, 279 + .name = "identification" 280 + }; 281 + 282 + static struct attribute *sme_cpuregs_id_attrs[] = { 283 + &cpuregs_attr_smidr_el1.attr, 284 + NULL 285 + }; 286 + 287 + static const struct attribute_group sme_cpuregs_attr_group = { 288 + .attrs = sme_cpuregs_id_attrs, 280 289 .name = "identification" 281 290 }; 282 291 ··· 307 296 rc = sysfs_create_group(&info->kobj, &cpuregs_attr_group); 308 297 if (rc) 309 298 kobject_del(&info->kobj); 299 + if (system_supports_sme()) 300 + rc = sysfs_merge_group(&info->kobj, &sme_cpuregs_attr_group); 310 301 out: 311 302 return rc; 312 303 } ··· 436 423 info->reg_zcr = read_zcr_features(); 437 424 438 425 if (IS_ENABLED(CONFIG_ARM64_SME) && 439 - id_aa64pfr1_sme(info->reg_id_aa64pfr1)) 426 + id_aa64pfr1_sme(info->reg_id_aa64pfr1)) { 440 427 info->reg_smcr = read_smcr_features(); 428 + 429 + /* 430 + * We mask out SMPS since even if the hardware 431 + * supports priorities the kernel does not at present 432 + * and we block access to them. 433 + */ 434 + info->reg_smidr = read_cpuid(SMIDR_EL1) & ~SMIDR_EL1_SMPS; 435 + } 441 436 442 437 cpuinfo_detect_icache_policy(info); 443 438 }