Skip to contentSkip to conversation

powerpc/powernv: Move SCOM access code into powernv platform

PATCH In review Andrew Donnellan 5 participants 13 messages May 9, 2019 – Aug 10, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 powerpc/powernv: Move SCOM access code into powernv platform

The powernv platform is the only one that directly accesses SCOMs. Move the support code to platforms/powernv, and get rid of the PPC_SCOM Kconfig option, as SCOM support is always selected when compiling for powernv.

This also means that the Kconfig item for CONFIG_SCOM_DEBUGFS will actually show up in menuconfig, as previously it was the only labelled option in sysdev/Kconfig and wasn't actually in a menu.

---
v1->v2:
- move scom.h as well (mpe)
- add all the other patches in this series

---
 arch/powerpc/platforms/powernv/Kconfig              |  5 ++++-
 arch/powerpc/platforms/powernv/Makefile             |  2 +-
 arch/powerpc/platforms/powernv/opal-xscom.c         |  3 ++-
 arch/powerpc/{sysdev => platforms/powernv}/scom.c   |  3 ++-
 .../{include/asm => platforms/powernv}/scom.h       | 13 +++----------
 arch/powerpc/sysdev/Kconfig                         |  7 -------
 arch/powerpc/sysdev/Makefile                        |  2 --
 7 files changed, 12 insertions(+), 23 deletions(-)
 rename arch/powerpc/{sysdev => platforms/powernv}/scom.c (99%)
 rename arch/powerpc/{include/asm => platforms/powernv}/scom.h (95%)
arch/powerpc/platforms/powernv/Kconfig +4 -1
index 850eee860cf2..938803eab0ad 100644
@@ -12,7 +12,6 @@ config PPC_POWERNV
 	select EPAPR_BOOT
 	select PPC_INDIRECT_PIO
 	select PPC_UDBG_16550
-	select PPC_SCOM
 	select ARCH_RANDOM
 	select CPU_FREQ
 	select PPC_DOORBELL
@@ -47,3 +46,7 @@ config PPC_VAS
 	  VAS adapters are found in POWER9 based systems.
 
 	  If unsure, say N.
+
+config SCOM_DEBUGFS
+	bool "Expose SCOM controllers via debugfs"
+	depends on DEBUG_FS
arch/powerpc/platforms/powernv/Makefile +1 -1
index da2e99efbd04..4b1644150135 100644
@@ -4,12 +4,12 @@ obj-y			+= idle.o opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y			+= rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
 obj-y			+= opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
 obj-y			+= opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o
+obj-y			+= opal-xscom.o scom.o
 
 obj-$(CONFIG_SMP)	+= smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)	+= pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o
 obj-$(CONFIG_CXL_BASE)	+= pci-cxl.o
 obj-$(CONFIG_EEH)	+= eeh-powernv.o
-obj-$(CONFIG_PPC_SCOM)	+= opal-xscom.o
 obj-$(CONFIG_MEMORY_FAILURE)	+= opal-memory-errors.o
 obj-$(CONFIG_OPAL_PRD)	+= opal-prd.o
 obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
arch/powerpc/platforms/powernv/opal-xscom.c +2 -1
index 22d5e1110dbb..66337d92cb63 100644
@@ -18,7 +18,8 @@
 #include <asm/machdep.h>
 #include <asm/firmware.h>
 #include <asm/opal.h>
-#include <asm/scom.h>
+
+#include "scom.h"
 
 /*
  * We could probably fit that inside the scom_map_t
arch/powerpc/platforms/powernv/scom.c renamed from arch/powerpc/sysdev/scom.c +2 -1
similarity index 99%
rename from arch/powerpc/sysdev/scom.c
rename to arch/powerpc/platforms/powernv/scom.c
index a707b24a7ddb..50c019d2ef45 100644
@@ -23,9 +23,10 @@
 #include <linux/export.h>
 #include <asm/debugfs.h>
 #include <asm/prom.h>
-#include <asm/scom.h>
 #include <linux/uaccess.h>
 
+#include "scom.h"
+
 const struct scom_controller *scom_controller;
 EXPORT_SYMBOL_GPL(scom_controller);
 
arch/powerpc/platforms/powernv/scom.h renamed from arch/powerpc/include/asm/scom.h +3 -10
similarity index 95%
rename from arch/powerpc/include/asm/scom.h
rename to arch/powerpc/platforms/powernv/scom.h
index f5cde45b1161..b14fe0edf95b 100644
@@ -18,12 +18,8 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#ifndef _ASM_POWERPC_SCOM_H
-#define _ASM_POWERPC_SCOM_H
-
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
-#ifdef CONFIG_PPC_SCOM
+#ifndef _SCOM_H
+#define _SCOM_H
 
 /*
  * The SCOM bus is a sideband bus used for accessing various internal
@@ -161,7 +157,4 @@ static inline int scom_write(scom_map_t map, u64 reg, u64 value)
 }
 
 
-#endif /* CONFIG_PPC_SCOM */
-#endif /* __ASSEMBLY__ */
-#endif /* __KERNEL__ */
-#endif /* _ASM_POWERPC_SCOM_H */
+#endif /* _SCOM_H */
arch/powerpc/sysdev/Kconfig +0 -7
index e0dbec780fe9..7808d279ff1d 100644
@@ -28,13 +28,6 @@ config PPC_MSI_BITMAP
 source "arch/powerpc/sysdev/xics/Kconfig"
 source "arch/powerpc/sysdev/xive/Kconfig"
 
-config PPC_SCOM
-	bool
-
-config SCOM_DEBUGFS
-	bool "Expose SCOM controllers via debugfs"
-	depends on PPC_SCOM && DEBUG_FS
-
 config GE_FPGA
 	bool
 
arch/powerpc/sysdev/Makefile +0 -2
index aaf23283ba0c..35d52d1d2fc0 100644
@@ -51,8 +51,6 @@ ifdef CONFIG_SUSPEND
 obj-$(CONFIG_PPC_BOOK3S_32)	+= 6xx-suspend.o
 endif
 
-obj-$(CONFIG_PPC_SCOM)		+= scom.o
-
 obj-$(CONFIG_PPC_EARLY_DEBUG_MEMCONS)	+= udbg_memcons.o
 
 obj-$(CONFIG_PPC_XICS)		+= xics/
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 2/5 powerpc/powernv: Remove dead SCOM access code

Nothing is using scom_map_device() or scom_find_parent(). Remove them.

Also don't export scom_controller, there are no other users of it.

---
v1->v2:
- new patch

---
 arch/powerpc/platforms/powernv/scom.c | 67 ---------------------------
 arch/powerpc/platforms/powernv/scom.h | 27 -----------
 2 files changed, 94 deletions(-)
arch/powerpc/platforms/powernv/scom.c +0 -67
index 50c019d2ef45..288580e5fdfe 100644
@@ -28,73 +28,6 @@
 #include "scom.h"
 
 const struct scom_controller *scom_controller;
-EXPORT_SYMBOL_GPL(scom_controller);
-
-struct device_node *scom_find_parent(struct device_node *node)
-{
-	struct device_node *par, *tmp;
-	const u32 *p;
-
-	for (par = of_node_get(node); par;) {
-		if (of_get_property(par, "scom-controller", NULL))
-			break;
-		p = of_get_property(par, "scom-parent", NULL);
-		tmp = par;
-		if (p == NULL)
-			par = of_get_parent(par);
-		else
-			par = of_find_node_by_phandle(*p);
-		of_node_put(tmp);
-	}
-	return par;
-}
-EXPORT_SYMBOL_GPL(scom_find_parent);
-
-scom_map_t scom_map_device(struct device_node *dev, int index)
-{
-	struct device_node *parent;
-	unsigned int cells, size;
-	const __be32 *prop, *sprop;
-	u64 reg, cnt;
-	scom_map_t ret;
-
-	parent = scom_find_parent(dev);
-
-	if (parent == NULL)
-		return NULL;
-
-	/*
-	 * We support "scom-reg" properties for adding scom registers
-	 * to a random device-tree node with an explicit scom-parent
-	 *
-	 * We also support the simple "reg" property if the device is
-	 * a direct child of a scom controller.
-	 *
-	 * In case both exist, "scom-reg" takes precedence.
-	 */
-	prop = of_get_property(dev, "scom-reg", &size);
-	sprop = of_get_property(parent, "#scom-cells", NULL);
-	if (!prop && parent == dev->parent) {
-		prop = of_get_property(dev, "reg", &size);
-		sprop = of_get_property(parent, "#address-cells", NULL);
-	}
-	if (!prop)
-		return NULL;
-	cells = sprop ? be32_to_cpup(sprop) : 1;
-	size >>= 2;
-
-	if (index >= (size / (2*cells)))
-		return NULL;
-
-	reg = of_read_number(&prop[index * cells * 2], cells);
-	cnt = of_read_number(&prop[index * cells * 2 + cells], cells);
-
-	ret = scom_map(parent, reg, cnt);
-	of_node_put(parent);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(scom_map_device);
 
 #ifdef CONFIG_SCOM_DEBUGFS
 struct scom_debug_entry {
arch/powerpc/platforms/powernv/scom.h +0 -27
index b14fe0edf95b..2c72f7fc8726 100644
@@ -88,33 +88,6 @@ static inline scom_map_t scom_map(struct device_node *ctrl_dev,
 	return scom_controller->map(ctrl_dev, reg, count);
 }
 
-/**
- * scom_find_parent - Find the SCOM controller for a device
- * @dev: OF node of the device
- *
- * This is not meant for general usage, but in combination with
- * scom_map() allows to map registers not represented by the
- * device own scom-reg property. Useful for applying HW workarounds
- * on things not properly represented in the device-tree for example.
- */
-struct device_node *scom_find_parent(struct device_node *dev);
-
-
-/**
- * scom_map_device - Map a device's block of SCOM registers
- * @dev: OF node of the device
- * @index: Register bank index (index in "scom-reg" property)
- *
- * This function will use the device-tree binding for SCOM which
- * is to follow "scom-parent" properties until it finds a node with
- * a "scom-controller" property to find the controller. It will then
- * use the "scom-reg" property which is made of reg/count pairs,
- * each of them having a size defined by the controller's #scom-cells
- * property
- */
-extern scom_map_t scom_map_device(struct device_node *dev, int index);
-
-
 /**
  * scom_unmap - Unmap a block of SCOM registers
  * @map: Result of scom_map is to be unmapped
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 3/5 powerpc/powernv: Get rid of old scom_controller abstraction

In reply to Andrew Donnellan

Once upon a time, the SCOM access code was used by the WSP platform as well as powernv. Thus it made sense to have a generic SCOM access interface to abstract between different platforms.

Now that it's just powernv, with no other platforms currently on the horizon, let's rip out scom_controller and make everything much simpler and more direct.

While we're here, fix up the comment block at the top and add a SPDX header.

---
v1->v2:
- new patch

---
 arch/powerpc/platforms/powernv/Makefile     |   2 +-
 arch/powerpc/platforms/powernv/opal-xscom.c | 215 +++++++++++++-------
 arch/powerpc/platforms/powernv/scom.c       | 170 ----------------
 arch/powerpc/platforms/powernv/scom.h       | 133 ------------
 4 files changed, 143 insertions(+), 377 deletions(-)
 delete mode 100644 arch/powerpc/platforms/powernv/scom.c
 delete mode 100644 arch/powerpc/platforms/powernv/scom.h
arch/powerpc/platforms/powernv/Makefile +1 -1
index 4b1644150135..69a3aefa905b 100644
@@ -4,7 +4,6 @@ obj-y			+= idle.o opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y			+= rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
 obj-y			+= opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
 obj-y			+= opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o
-obj-y			+= opal-xscom.o scom.o
 
 obj-$(CONFIG_SMP)	+= smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)	+= pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o
@@ -16,3 +15,4 @@ obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
 obj-$(CONFIG_PPC_MEMTRACE)	+= memtrace.o
 obj-$(CONFIG_PPC_VAS)	+= vas.o vas-window.o vas-debug.o
 obj-$(CONFIG_OCXL_BASE)	+= ocxl.o
+obj-$(CONFIG_SCOM_DEBUGFS) += opal-xscom.o
arch/powerpc/platforms/powernv/opal-xscom.c +142 -73

250 lines not on this page · raw message

arch/powerpc/platforms/powernv/scom.c deleted +0 -170

170 lines not on this page · raw message

arch/powerpc/platforms/powernv/scom.h deleted +0 -133

133 lines not on this page · raw message

Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 4/5 powerpc/powernv: Fix checkpatch warnings in opal-xscom.c

In reply to Andrew Donnellan

---
v1->v2:
- new patch

---
 arch/powerpc/platforms/powernv/opal-xscom.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/opal-xscom.c +4 -4
index e16b0e346d7e..d9607376822c 100644
@@ -95,7 +95,7 @@ static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
 	struct scom_debug_entry *ent = filp->private_data;
 	u64 __user *ubuf64 = (u64 __user *)ubuf;
 	loff_t off = *ppos;
-	ssize_t done = 0; 
+	ssize_t done = 0;
 	u64 reg, reg_base, reg_cnt, val;
 	int rc;
 
@@ -120,13 +120,13 @@ static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
 	return done;
 }
 
-static ssize_t scom_debug_write(struct file* filp, const char __user *ubuf,
+static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
 				size_t count, loff_t *ppos)
 {
 	struct scom_debug_entry *ent = filp->private_data;
 	u64 __user *ubuf64 = (u64 __user *)ubuf;
 	loff_t off = *ppos;
-	ssize_t done = 0; 
+	ssize_t done = 0;
 	u64 reg, reg_base, reg_cnt, val;
 	int rc;
 
@@ -169,7 +169,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
 
 	ent->chip = chip;
 	snprintf(ent->name, 16, "%08x", chip);
-	ent->path.data = (void*)kasprintf(GFP_KERNEL, "%pOF", dn);
+	ent->path.data = (void *)kasprintf(GFP_KERNEL, "%pOF", dn);
 	ent->path.size = strlen((char *)ent->path.data);
 
 	dir = debugfs_create_dir(ent->name, root);
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 5/5 powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig

In reply to Andrew Donnellan

SCOM_DEBUGFS is really not needed for anything other than low-level hardware debugging.

opal-prd uses its own interface (/dev/prd) for SCOM access, so it doesn't need SCOM_DEBUGFS.

At some point in the future we'll introduce a debug config fragment where this can go instead.

---
v1->v2:
- new patch

---
 arch/powerpc/configs/powernv_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/configs/powernv_defconfig +1 -1
index ef2ef98d3f28..d5a6608cb2e0 100644
@@ -38,7 +38,7 @@ CONFIG_MODULE_UNLOAD=y
 CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_PARTITION_ADVANCED=y
-CONFIG_SCOM_DEBUGFS=y
+# CONFIG_SCOM_DEBUGFS is not set
 CONFIG_OPAL_PRD=y
 CONFIG_PPC_MEMTRACE=y
 # CONFIG_PPC_PSERIES is not set
Signature · 1 line
2.20.1
#5 lore raw

Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig

Andrew Donnellan's on May 9, 2019 3:11 pm:

Quoted 8 lines

SCOM_DEBUGFS is really not needed for anything other than low-level hardware debugging.

opal-prd uses its own interface (/dev/prd) for SCOM access, so it doesn't need SCOM_DEBUGFS.

At some point in the future we'll introduce a debug config fragment where this can go instead.

That doesn't really explain why you want to disable it. It is useful for low level hardware debugging, I added it.

obscurity^Wsecurity?

Quoted 26 lines

---
v1->v2:
- new patch

---
 arch/powerpc/configs/powernv_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/configs/powernv_defconfig +1 -1
index ef2ef98d3f28..d5a6608cb2e0 100644
@@ -38,7 +38,7 @@ CONFIG_MODULE_UNLOAD=y
 CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_PARTITION_ADVANCED=y
-CONFIG_SCOM_DEBUGFS=y
+# CONFIG_SCOM_DEBUGFS is not set
 CONFIG_OPAL_PRD=y
 CONFIG_PPC_MEMTRACE=y
 # CONFIG_PPC_PSERIES is not set
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig

Quoted 8 lines · Nicholas Piggin

Andrew Donnellan's on May 9, 2019 3:11 pm:

Quoted 6 lines

SCOM_DEBUGFS is really not needed for anything other than low-level hardware debugging.

opal-prd uses its own interface (/dev/prd) for SCOM access, so it doesn't need SCOM_DEBUGFS.

Quoted 7 lines
Quoted 2 lines

At some point in the future we'll introduce a debug config fragment where this can go instead.

That doesn't really explain why you want to disable it. It is useful for low level hardware debugging, I added it.

obscurity^Wsecurity?

Yeah... If you're building powernv_defconfig then the odds are pretty high that you'll want scom access.

Quoted 27 lines
Quoted 27 lines

---
v1->v2:
- new patch

---
 arch/powerpc/configs/powernv_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/configs/powernv_defconfig +1 -2
index ef2ef98d3f28..d5a6608cb2e0 100644
@@ -38,7 +38,7 @@ CONFIG_MODULE_UNLOAD=y
 CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_PARTITION_ADVANCED=y
-CONFIG_SCOM_DEBUGFS=y
+# CONFIG_SCOM_DEBUGFS is not set
 CONFIG_OPAL_PRD=y
 CONFIG_PPC_MEMTRACE=y
 # CONFIG_PPC_PSERIES is not set
--

2.20.1

#7 lore raw

Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig

In reply to Nicholas Piggin
Quoted 7 lines · Nicholas Piggin

Andrew Donnellan's on May 9, 2019 3:11 pm:

Quoted 6 lines

SCOM_DEBUGFS is really not needed for anything other than low-level hardware debugging.

opal-prd uses its own interface (/dev/prd) for SCOM access, so it doesn't need SCOM_DEBUGFS.

Quoted 7 lines
Quoted 2 lines

At some point in the future we'll introduce a debug config fragment where this can go instead.

That doesn't really explain why you want to disable it. It is useful for low level hardware debugging, I added it.

obscurity^Wsecurity?

Mostly just a general feeling that it's not something we need to have by default. Security-wise, PRD still provides SCOM access, though we are going to look at how we can further lock that down. Shrinks the build by only a few kilobytes...

mpe said he's planning on adding a debug.config where we can shift stuff like this, and if/when we do that I would like to see this moved there, but perhaps this patch can wait until then. I'll let mpe decide.

Andrew

Quoted 28 lines
Quoted 27 lines

---
v1->v2:
- new patch

---
  arch/powerpc/configs/powernv_defconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/configs/powernv_defconfig +1 -1
index ef2ef98d3f28..d5a6608cb2e0 100644
@@ -38,7 +38,7 @@ CONFIG_MODULE_UNLOAD=y
  CONFIG_MODVERSIONS=y
  CONFIG_MODULE_SRCVERSION_ALL=y
  CONFIG_PARTITION_ADVANCED=y
-CONFIG_SCOM_DEBUGFS=y
+# CONFIG_SCOM_DEBUGFS is not set
  CONFIG_OPAL_PRD=y
  CONFIG_PPC_MEMTRACE=y
  # CONFIG_PPC_PSERIES is not set
Signature · 1 line
2.20.1
Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]             IBM Australia Limited
#8 lore raw

Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig

Quoted 11 lines · Andrew Donnellan
Quoted 10 lines · Nicholas Piggin

Andrew Donnellan's on May 9, 2019 3:11 pm:

Quoted 8 lines

SCOM_DEBUGFS is really not needed for anything other than low-level hardware debugging.

opal-prd uses its own interface (/dev/prd) for SCOM access, so it doesn't need SCOM_DEBUGFS.

At some point in the future we'll introduce a debug config fragment where this can go instead.

Quoted 9 lines
Quoted 4 lines

That doesn't really explain why you want to disable it. It is useful for low level hardware debugging, I added it.

obscurity^Wsecurity?

Mostly just a general feeling that it's not something we need to have by default. Security-wise, PRD still provides SCOM access, though we are going to look at how we can further lock that down. Shrinks the build by only a few kilobytes...

mpe said he's planning on adding a debug.config where we can shift stuff like this, and if/when we do that I would like to see this moved there, but perhaps this patch can wait until then. I'll let mpe decide.

mpe do you have thoughts on this? I would like to see at least the rest of this series merged.

Andrew

Quoted 33 lines

Andrew

Quoted 28 lines
Quoted 27 lines

---
v1->v2:
- new patch
---
  arch/powerpc/configs/powernv_defconfig | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/configs/powernv_defconfig +0 -0
index ef2ef98d3f28..d5a6608cb2e0 100644
@@ -38,7 +38,7 @@ CONFIG_MODULE_UNLOAD=y

  CONFIG_MODVERSIONS=y
  CONFIG_MODULE_SRCVERSION_ALL=y
  CONFIG_PARTITION_ADVANCED=y

arch/powerpc/configs/powernv_defconfig +1 -1
-CONFIG_SCOM_DEBUGFS=y
+# CONFIG_SCOM_DEBUGFS is not set

  CONFIG_OPAL_PRD=y
  CONFIG_PPC_MEMTRACE=y
  # CONFIG_PPC_PSERIES is not set

Signature · 1 line
2.20.1
Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]             IBM Australia Limited
#9 lore raw

Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig

Quoted 24 lines · Andrew Donnellan
Quoted 23 lines · Andrew Donnellan
Quoted 8 lines · Nicholas Piggin

Andrew Donnellan's on May 9, 2019 3:11 pm:

Quoted 7 lines

SCOM_DEBUGFS is really not needed for anything other than low-level hardware debugging.

opal-prd uses its own interface (/dev/prd) for SCOM access, so it doesn't
need SCOM_DEBUGFS.

Quoted 8 lines
Quoted 3 lines

At some point in the future we'll introduce a debug config fragment where
this can go instead.

That doesn't really explain why you want to disable it. It is useful for low level hardware debugging, I added it.

obscurity^Wsecurity?

Mostly just a general feeling that it's not something we need to have by default. Security-wise, PRD still provides SCOM access, though we are going to look at how we can further lock that down. Shrinks the build by only a few kilobytes...

Quoted 6 lines
Quoted 3 lines

mpe said he's planning on adding a debug.config where we can shift stuff like this, and if/when we do that I would like to see this moved there, but perhaps this patch can wait until then. I'll let mpe decide.

mpe do you have thoughts on this? I would like to see at least the rest of this series merged.

I think it should be off by default, it may be true that root can attack/break the system in many other ways, but providing unrestricted SCOM access is a pretty big opening.

This is similar to strict /dev/mem IMO, which "everyone" agrees is a good idea these days.

It's pretty trivial for folks doing development to turn it on in their local trees, and I would also welcome a debug.config fragment that enables it.

So I'll take the whole series.

cheers

#10 lore raw
In reply to Andrew Donnellan
Quoted 7 lines · Andrew Donnellan

The powernv platform is the only one that directly accesses SCOMs. Move the support code to platforms/powernv, and get rid of the PPC_SCOM Kconfig option, as SCOM support is always selected when compiling for powernv.

This also means that the Kconfig item for CONFIG_SCOM_DEBUGFS will actually show up in menuconfig, as previously it was the only labelled option in sysdev/Kconfig and wasn't actually in a menu.

As I've just realised, this isn't actually correct - the option does indeed show up... in the root menu, where I've just been trained to ignore it, and where you won't get a menu location if you try to search for it using / in menuconfig.

I think moving it to the platform menu is obviously a better location. mpe would you be able to fix up the commit message in merge?

Andrew

Quoted 152 lines

---
v1->v2:
- move scom.h as well (mpe)
- add all the other patches in this series

---
  arch/powerpc/platforms/powernv/Kconfig              |  5 ++++-
  arch/powerpc/platforms/powernv/Makefile             |  2 +-
  arch/powerpc/platforms/powernv/opal-xscom.c         |  3 ++-
  arch/powerpc/{sysdev => platforms/powernv}/scom.c   |  3 ++-
  .../{include/asm => platforms/powernv}/scom.h       | 13 +++----------
  arch/powerpc/sysdev/Kconfig                         |  7 -------
  arch/powerpc/sysdev/Makefile                        |  2 --
  7 files changed, 12 insertions(+), 23 deletions(-)

rename arch/powerpc/{sysdev => platforms/powernv}/scom.c (99%) rename arch/powerpc/{include/asm => platforms/powernv}/scom.h (95%)

arch/powerpc/platforms/powernv/Kconfig +4 -1
index 850eee860cf2..938803eab0ad 100644
@@ -12,7 +12,6 @@ config PPC_POWERNV
  	select EPAPR_BOOT
  	select PPC_INDIRECT_PIO
  	select PPC_UDBG_16550
-	select PPC_SCOM
  	select ARCH_RANDOM
  	select CPU_FREQ
  	select PPC_DOORBELL
@@ -47,3 +46,7 @@ config PPC_VAS
  	  VAS adapters are found in POWER9 based systems.
 
  	  If unsure, say N.
+
+config SCOM_DEBUGFS
+	bool "Expose SCOM controllers via debugfs"
+	depends on DEBUG_FS
arch/powerpc/platforms/powernv/Makefile +1 -1
index da2e99efbd04..4b1644150135 100644
@@ -4,12 +4,12 @@ obj-y			+= idle.o opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
  obj-y			+= rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
  obj-y			+= opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
  obj-y			+= opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o
+obj-y			+= opal-xscom.o scom.o
 
  obj-$(CONFIG_SMP)	+= smp.o subcore.o subcore-asm.o
  obj-$(CONFIG_PCI)	+= pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o
  obj-$(CONFIG_CXL_BASE)	+= pci-cxl.o
  obj-$(CONFIG_EEH)	+= eeh-powernv.o
-obj-$(CONFIG_PPC_SCOM)	+= opal-xscom.o
  obj-$(CONFIG_MEMORY_FAILURE)	+= opal-memory-errors.o
  obj-$(CONFIG_OPAL_PRD)	+= opal-prd.o
  obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
arch/powerpc/platforms/powernv/opal-xscom.c +2 -1
index 22d5e1110dbb..66337d92cb63 100644
@@ -18,7 +18,8 @@
  #include <asm/machdep.h>
  #include <asm/firmware.h>
  #include <asm/opal.h>
-#include <asm/scom.h>
+
+#include "scom.h"
 
  /*
   * We could probably fit that inside the scom_map_t
arch/powerpc/platforms/powernv/scom.c renamed from arch/powerpc/sysdev/scom.c +2 -1
similarity index 99%
rename from arch/powerpc/sysdev/scom.c
rename to arch/powerpc/platforms/powernv/scom.c
index a707b24a7ddb..50c019d2ef45 100644
@@ -23,9 +23,10 @@
  #include <linux/export.h>
  #include <asm/debugfs.h>
  #include <asm/prom.h>
-#include <asm/scom.h>
  #include <linux/uaccess.h>
 
+#include "scom.h"
+
  const struct scom_controller *scom_controller;
  EXPORT_SYMBOL_GPL(scom_controller);
 
arch/powerpc/platforms/powernv/scom.h renamed from arch/powerpc/include/asm/scom.h +3 -10
similarity index 95%
rename from arch/powerpc/include/asm/scom.h
rename to arch/powerpc/platforms/powernv/scom.h
index f5cde45b1161..b14fe0edf95b 100644
@@ -18,12 +18,8 @@
   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   */
 
-#ifndef _ASM_POWERPC_SCOM_H
-#define _ASM_POWERPC_SCOM_H
-
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
-#ifdef CONFIG_PPC_SCOM
+#ifndef _SCOM_H
+#define _SCOM_H
 
  /*
   * The SCOM bus is a sideband bus used for accessing various internal
@@ -161,7 +157,4 @@ static inline int scom_write(scom_map_t map, u64 reg, u64 value)
  }
 
 
-#endif /* CONFIG_PPC_SCOM */
-#endif /* __ASSEMBLY__ */
-#endif /* __KERNEL__ */
-#endif /* _ASM_POWERPC_SCOM_H */
+#endif /* _SCOM_H */
arch/powerpc/sysdev/Kconfig +0 -7
index e0dbec780fe9..7808d279ff1d 100644
@@ -28,13 +28,6 @@ config PPC_MSI_BITMAP
  source "arch/powerpc/sysdev/xics/Kconfig"
  source "arch/powerpc/sysdev/xive/Kconfig"
 
-config PPC_SCOM
-	bool
-
-config SCOM_DEBUGFS
-	bool "Expose SCOM controllers via debugfs"
-	depends on PPC_SCOM && DEBUG_FS
-
  config GE_FPGA
  	bool
 
arch/powerpc/sysdev/Makefile +0 -2
index aaf23283ba0c..35d52d1d2fc0 100644
@@ -51,8 +51,6 @@ ifdef CONFIG_SUSPEND
  obj-$(CONFIG_PPC_BOOK3S_32)	+= 6xx-suspend.o
  endif
 
-obj-$(CONFIG_PPC_SCOM)		+= scom.o
-
  obj-$(CONFIG_PPC_EARLY_DEBUG_MEMCONS)	+= udbg_memcons.o
 
  obj-$(CONFIG_PPC_XICS)		+= xics/
Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]             IBM Australia Limited
#11 lore raw
Quoted 9 lines · Andrew Donnellan
Quoted 7 lines · Andrew Donnellan

The powernv platform is the only one that directly accesses SCOMs. Move the support code to platforms/powernv, and get rid of the PPC_SCOM Kconfig option, as SCOM support is always selected when compiling for powernv.

This also means that the Kconfig item for CONFIG_SCOM_DEBUGFS will actually show up in menuconfig, as previously it was the only labelled option in sysdev/Kconfig and wasn't actually in a menu.

Quoted 7 lines

As I've just realised, this isn't actually correct - the option does indeed show up... in the root menu, where I've just been trained to ignore it, and where you won't get a menu location if you try to search for it using / in menuconfig.

I think moving it to the platform menu is obviously a better location. mpe would you be able to fix up the commit message in merge?

Yes, done.

cheers

#12 lore raw
In reply to Andrew Donnellan
Quoted 9 lines · Andrew Donnellan

The powernv platform is the only one that directly accesses SCOMs. Move the support code to platforms/powernv, and get rid of the PPC_SCOM Kconfig option, as SCOM support is always selected when compiling for powernv.

This also means that the Kconfig item for CONFIG_SCOM_DEBUGFS will actually show up in menuconfig, as previously it was the only labelled option in sysdev/Kconfig and wasn't actually in a menu.

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/08a456aa643776757e07adfdebe7f7681117d144

cheers