Skip to content

Commit d69d564

Browse files
brooniewilldeacon
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent a111daf commit d69d564

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,13 @@ What: /sys/devices/system/cpu/cpuX/regs/
493493
/sys/devices/system/cpu/cpuX/regs/identification/
494494
/sys/devices/system/cpu/cpuX/regs/identification/midr_el1
495495
/sys/devices/system/cpu/cpuX/regs/identification/revidr_el1
496+
/sys/devices/system/cpu/cpuX/regs/identification/smidr_el1
496497
Date: June 2016
497498
Contact: Linux ARM Kernel Mailing list <[email protected]>
498499
Description: AArch64 CPU registers
499500

500501
'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.
502503

503504
What: /sys/devices/system/cpu/aarch32_el0
504505
Date: May 2021

arch/arm64/include/asm/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct cpuinfo_arm64 {
4646
u64 reg_midr;
4747
u64 reg_revidr;
4848
u64 reg_gmid;
49+
u64 reg_smidr;
4950

5051
u64 reg_id_aa64dfr0;
5152
u64 reg_id_aa64dfr1;

arch/arm64/kernel/cpuinfo.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ static struct kobj_type cpuregs_kobj_type = {
267267

268268
CPUREGS_ATTR_RO(midr_el1, midr);
269269
CPUREGS_ATTR_RO(revidr_el1, revidr);
270+
CPUREGS_ATTR_RO(smidr_el1, smidr);
270271

271272
static struct attribute *cpuregs_id_attrs[] = {
272273
&cpuregs_attr_midr_el1.attr,
@@ -279,6 +280,16 @@ static const struct attribute_group cpuregs_attr_group = {
279280
.name = "identification"
280281
};
281282

283+
static struct attribute *sme_cpuregs_id_attrs[] = {
284+
&cpuregs_attr_smidr_el1.attr,
285+
NULL
286+
};
287+
288+
static const struct attribute_group sme_cpuregs_attr_group = {
289+
.attrs = sme_cpuregs_id_attrs,
290+
.name = "identification"
291+
};
292+
282293
static int cpuid_cpu_online(unsigned int cpu)
283294
{
284295
int rc;
@@ -296,6 +307,8 @@ static int cpuid_cpu_online(unsigned int cpu)
296307
rc = sysfs_create_group(&info->kobj, &cpuregs_attr_group);
297308
if (rc)
298309
kobject_del(&info->kobj);
310+
if (system_supports_sme())
311+
rc = sysfs_merge_group(&info->kobj, &sme_cpuregs_attr_group);
299312
out:
300313
return rc;
301314
}
@@ -423,9 +436,17 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
423436
info->reg_zcr = read_zcr_features();
424437

425438
if (IS_ENABLED(CONFIG_ARM64_SME) &&
426-
id_aa64pfr1_sme(info->reg_id_aa64pfr1))
439+
id_aa64pfr1_sme(info->reg_id_aa64pfr1)) {
427440
info->reg_smcr = read_smcr_features();
428441

442+
/*
443+
* We mask out SMPS since even if the hardware
444+
* supports priorities the kernel does not at present
445+
* and we block access to them.
446+
*/
447+
info->reg_smidr = read_cpuid(SMIDR_EL1) & ~SMIDR_EL1_SMPS;
448+
}
449+
429450
cpuinfo_detect_icache_policy(info);
430451
}
431452

0 commit comments

Comments
 (0)