Skip to contentSkip to conversation

powerpc/sysfs: Expose MMCR2 spr in sysfs

PATCH In review Madhavan Srinivasan 2 participants 2 messages Jun 25, 2017 – Jun 26, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/sysfs: Expose MMCR2 spr in sysfs

Monitor Mode Control Register 2 (MMCR2) is a 64-bit register that contains 9-bit control fields for controlling the operation of PMC1 - PMC6. Patch to expose the MMCR2 spr in sysfs.

---
 arch/powerpc/kernel/sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/powerpc/kernel/sysfs.c +8 -0
index 4437c70c7c2b..587eb3a7b5da 100644
@@ -482,6 +482,7 @@ SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
 SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
 
 SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
+SYSFS_PMCSETUP(mmcr2, SPRN_MMCR2);
 SYSFS_SPRSETUP(purr, SPRN_PURR);
 SYSFS_SPRSETUP(spurr, SPRN_SPURR);
 SYSFS_SPRSETUP(pir, SPRN_PIR);
@@ -492,6 +493,7 @@ SYSFS_SPRSETUP(pir, SPRN_PIR);
   Lets be conservative and default to pseries.
 */
 static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
+static DEVICE_ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2);
 static DEVICE_ATTR(spurr, 0400, show_spurr, NULL);
 static DEVICE_ATTR(purr, 0400, show_purr, store_purr);
 static DEVICE_ATTR(pir, 0400, show_pir, NULL);
@@ -760,6 +762,9 @@ static int register_cpu_online(unsigned int cpu)
 	if (cpu_has_feature(CPU_FTR_MMCRA))
 		device_create_file(s, &dev_attr_mmcra);
 
+	if (cpu_has_feature(CPU_FTR_ARCH_207S))
+		device_create_file(s, &dev_attr_mmcr2);
+
 	if (cpu_has_feature(CPU_FTR_PURR)) {
 		if (!firmware_has_feature(FW_FEATURE_LPAR))
 			add_write_permission_dev_attr(&dev_attr_purr);
@@ -845,6 +850,9 @@ static int unregister_cpu_online(unsigned int cpu)
 	if (cpu_has_feature(CPU_FTR_MMCRA))
 		device_remove_file(s, &dev_attr_mmcra);
 
+	if (cpu_has_feature(CPU_FTR_ARCH_207S))
+		device_remove_file(s, &dev_attr_mmcr2);
+
 	if (cpu_has_feature(CPU_FTR_PURR))
 		device_remove_file(s, &dev_attr_purr);
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 15 lines · Madhavan Srinivasan

Monitor Mode Control Register 2 (MMCR2) is a 64-bit register that contains 9-bit control fields for controlling the operation of PMC1 - PMC6. Patch to expose the MMCR2 spr in sysfs.

---
 arch/powerpc/kernel/sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/powerpc/kernel/sysfs.c +0 -0
index 4437c70c7c2b..587eb3a7b5da 100644

arch/powerpc/kernel/sysfs.c SYSFS_PMCSETUP(pmc7, SPRN_PMC7); · line 485

Quoted 4 lines
arch/powerpc/kernel/sysfs.c +1 -0
@@ -482,6 +482,7 @@ SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
 SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
 
 SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
+SYSFS_PMCSETUP(mmcr2, SPRN_MMCR2);

We already have it under an #ifdef:

#ifdef HAS_PPC_PMC_G4
SYSFS_PMCSETUP(mmcr2, SPRN_MMCR2);
#endif

Can you reuse that somehow, or rework the #ifdefs.

cheers