* [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform @ 2019-05-09 5:11 Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 2/5] powerpc/powernv: Remove dead SCOM access code Andrew Donnellan ` (5 more replies) 0 siblings, 6 replies; 13+ messages in thread From: Andrew Donnellan @ 2019-05-09 5:11 UTC (permalink / raw) To: linuxppc-dev 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. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- 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%) diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig index 850eee860cf2..938803eab0ad 100644 --- a/arch/powerpc/platforms/powernv/Kconfig +++ b/arch/powerpc/platforms/powernv/Kconfig @@ -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 diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index da2e99efbd04..4b1644150135 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -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 diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c index 22d5e1110dbb..66337d92cb63 100644 --- a/arch/powerpc/platforms/powernv/opal-xscom.c +++ b/arch/powerpc/platforms/powernv/opal-xscom.c @@ -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 diff --git a/arch/powerpc/sysdev/scom.c b/arch/powerpc/platforms/powernv/scom.c similarity index 99% rename from arch/powerpc/sysdev/scom.c rename to arch/powerpc/platforms/powernv/scom.c index a707b24a7ddb..50c019d2ef45 100644 --- a/arch/powerpc/sysdev/scom.c +++ b/arch/powerpc/platforms/powernv/scom.c @@ -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); diff --git a/arch/powerpc/include/asm/scom.h b/arch/powerpc/platforms/powernv/scom.h similarity index 95% rename from arch/powerpc/include/asm/scom.h rename to arch/powerpc/platforms/powernv/scom.h index f5cde45b1161..b14fe0edf95b 100644 --- a/arch/powerpc/include/asm/scom.h +++ b/arch/powerpc/platforms/powernv/scom.h @@ -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 */ diff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig index e0dbec780fe9..7808d279ff1d 100644 --- a/arch/powerpc/sysdev/Kconfig +++ b/arch/powerpc/sysdev/Kconfig @@ -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 diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile index aaf23283ba0c..35d52d1d2fc0 100644 --- a/arch/powerpc/sysdev/Makefile +++ b/arch/powerpc/sysdev/Makefile @@ -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/ -- 2.20.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/5] powerpc/powernv: Remove dead SCOM access code 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan @ 2019-05-09 5:11 ` Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 3/5] powerpc/powernv: Get rid of old scom_controller abstraction Andrew Donnellan ` (4 subsequent siblings) 5 siblings, 0 replies; 13+ messages in thread From: Andrew Donnellan @ 2019-05-09 5:11 UTC (permalink / raw) To: linuxppc-dev 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. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- v1->v2: - new patch --- arch/powerpc/platforms/powernv/scom.c | 67 --------------------------- arch/powerpc/platforms/powernv/scom.h | 27 ----------- 2 files changed, 94 deletions(-) diff --git a/arch/powerpc/platforms/powernv/scom.c b/arch/powerpc/platforms/powernv/scom.c index 50c019d2ef45..288580e5fdfe 100644 --- a/arch/powerpc/platforms/powernv/scom.c +++ b/arch/powerpc/platforms/powernv/scom.c @@ -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 { diff --git a/arch/powerpc/platforms/powernv/scom.h b/arch/powerpc/platforms/powernv/scom.h index b14fe0edf95b..2c72f7fc8726 100644 --- a/arch/powerpc/platforms/powernv/scom.h +++ b/arch/powerpc/platforms/powernv/scom.h @@ -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 -- 2.20.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/5] powerpc/powernv: Get rid of old scom_controller abstraction 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 2/5] powerpc/powernv: Remove dead SCOM access code Andrew Donnellan @ 2019-05-09 5:11 ` Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 4/5] powerpc/powernv: Fix checkpatch warnings in opal-xscom.c Andrew Donnellan ` (3 subsequent siblings) 5 siblings, 0 replies; 13+ messages in thread From: Andrew Donnellan @ 2019-05-09 5:11 UTC (permalink / raw) To: linuxppc-dev 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. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- 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 diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index 4b1644150135..69a3aefa905b 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -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 diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c index 66337d92cb63..e16b0e346d7e 100644 --- a/arch/powerpc/platforms/powernv/opal-xscom.c +++ b/arch/powerpc/platforms/powernv/opal-xscom.c @@ -1,6 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * PowerNV LPC bus handling. + * PowerNV SCOM bus debugfs interface * + * Copyright 2010 Benjamin Herrenschmidt, IBM Corp + * <benh@kernel.crashing.org> + * and David Gibson, IBM Corporation. * Copyright 2013 IBM Corp. * * This program is free software; you can redistribute it and/or @@ -14,63 +18,13 @@ #include <linux/bug.h> #include <linux/gfp.h> #include <linux/slab.h> +#include <linux/uaccess.h> #include <asm/machdep.h> #include <asm/firmware.h> #include <asm/opal.h> - -#include "scom.h" - -/* - * We could probably fit that inside the scom_map_t - * which is a void* after all but it's really too ugly - * so let's kmalloc it for now - */ -struct opal_scom_map { - uint32_t chip; - uint64_t addr; -}; - -static scom_map_t opal_scom_map(struct device_node *dev, u64 reg, u64 count) -{ - struct opal_scom_map *m; - const __be32 *gcid; - - if (!of_get_property(dev, "scom-controller", NULL)) { - pr_err("%s: device %pOF is not a SCOM controller\n", - __func__, dev); - return SCOM_MAP_INVALID; - } - gcid = of_get_property(dev, "ibm,chip-id", NULL); - if (!gcid) { - pr_err("%s: device %pOF has no ibm,chip-id\n", - __func__, dev); - return SCOM_MAP_INVALID; - } - m = kmalloc(sizeof(*m), GFP_KERNEL); - if (!m) - return NULL; - m->chip = be32_to_cpup(gcid); - m->addr = reg; - - return (scom_map_t)m; -} - -static void opal_scom_unmap(scom_map_t map) -{ - kfree(map); -} - -static int opal_xscom_err_xlate(int64_t rc) -{ - switch(rc) { - case 0: - return 0; - /* Add more translations if necessary */ - default: - return -EIO; - } -} +#include <asm/debugfs.h> +#include <asm/prom.h> static u64 opal_scom_unmangle(u64 addr) { @@ -103,39 +57,154 @@ static u64 opal_scom_unmangle(u64 addr) return addr; } -static int opal_scom_read(scom_map_t map, u64 reg, u64 *value) +static int opal_scom_read(uint32_t chip, uint64_t addr, u64 reg, u64 *value) { - struct opal_scom_map *m = map; int64_t rc; __be64 v; - reg = opal_scom_unmangle(m->addr + reg); - rc = opal_xscom_read(m->chip, reg, (__be64 *)__pa(&v)); + reg = opal_scom_unmangle(addr + reg); + rc = opal_xscom_read(chip, reg, (__be64 *)__pa(&v)); + if (rc) { + *value = 0xfffffffffffffffful; + return -EIO; + } *value = be64_to_cpu(v); - return opal_xscom_err_xlate(rc); + return 0; } -static int opal_scom_write(scom_map_t map, u64 reg, u64 value) +static int opal_scom_write(uint32_t chip, uint64_t addr, u64 reg, u64 value) { - struct opal_scom_map *m = map; int64_t rc; - reg = opal_scom_unmangle(m->addr + reg); - rc = opal_xscom_write(m->chip, reg, value); - return opal_xscom_err_xlate(rc); + reg = opal_scom_unmangle(addr + reg); + rc = opal_xscom_write(chip, reg, value); + if (rc) + return -EIO; + return 0; +} + +struct scom_debug_entry { + u32 chip; + struct debugfs_blob_wrapper path; + char name[16]; +}; + +static ssize_t scom_debug_read(struct file *filp, 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; + u64 reg, reg_base, reg_cnt, val; + int rc; + + if (off < 0 || (off & 7) || (count & 7)) + return -EINVAL; + reg_base = off >> 3; + reg_cnt = count >> 3; + + for (reg = 0; reg < reg_cnt; reg++) { + rc = opal_scom_read(ent->chip, reg_base, reg, &val); + if (!rc) + rc = put_user(val, ubuf64); + if (rc) { + if (!done) + done = rc; + break; + } + ubuf64++; + *ppos += 8; + done += 8; + } + return done; +} + +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; + u64 reg, reg_base, reg_cnt, val; + int rc; + + if (off < 0 || (off & 7) || (count & 7)) + return -EINVAL; + reg_base = off >> 3; + reg_cnt = count >> 3; + + for (reg = 0; reg < reg_cnt; reg++) { + rc = get_user(val, ubuf64); + if (!rc) + rc = opal_scom_write(ent->chip, reg_base, reg, val); + if (rc) { + if (!done) + done = rc; + break; + } + ubuf64++; + done += 8; + } + return done; } -static const struct scom_controller opal_scom_controller = { - .map = opal_scom_map, - .unmap = opal_scom_unmap, - .read = opal_scom_read, - .write = opal_scom_write +static const struct file_operations scom_debug_fops = { + .read = scom_debug_read, + .write = scom_debug_write, + .open = simple_open, + .llseek = default_llseek, }; -static int opal_xscom_init(void) +static int scom_debug_init_one(struct dentry *root, struct device_node *dn, + int chip) { - if (firmware_has_feature(FW_FEATURE_OPAL)) - scom_init(&opal_scom_controller); + struct scom_debug_entry *ent; + struct dentry *dir; + + ent = kzalloc(sizeof(*ent), GFP_KERNEL); + if (!ent) + return -ENOMEM; + + ent->chip = chip; + snprintf(ent->name, 16, "%08x", chip); + ent->path.data = (void*)kasprintf(GFP_KERNEL, "%pOF", dn); + ent->path.size = strlen((char *)ent->path.data); + + dir = debugfs_create_dir(ent->name, root); + if (!dir) { + kfree(ent->path.data); + kfree(ent); + return -1; + } + + debugfs_create_blob("devspec", 0400, dir, &ent->path); + debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops); + return 0; } -machine_arch_initcall(powernv, opal_xscom_init); + +static int scom_debug_init(void) +{ + struct device_node *dn; + struct dentry *root; + int chip, rc; + + if (!firmware_has_feature(FW_FEATURE_OPAL)) + return 0; + + root = debugfs_create_dir("scom", powerpc_debugfs_root); + if (!root) + return -1; + + rc = 0; + for_each_node_with_property(dn, "scom-controller") { + chip = of_get_ibm_chip_id(dn); + WARN_ON(chip == -1); + rc |= scom_debug_init_one(root, dn, chip); + } + + return rc; +} +device_initcall(scom_debug_init); diff --git a/arch/powerpc/platforms/powernv/scom.c b/arch/powerpc/platforms/powernv/scom.c deleted file mode 100644 index 288580e5fdfe..000000000000 --- a/arch/powerpc/platforms/powernv/scom.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2010 Benjamin Herrenschmidt, IBM Corp - * <benh@kernel.crashing.org> - * and David Gibson, IBM Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/export.h> -#include <asm/debugfs.h> -#include <asm/prom.h> -#include <linux/uaccess.h> - -#include "scom.h" - -const struct scom_controller *scom_controller; - -#ifdef CONFIG_SCOM_DEBUGFS -struct scom_debug_entry { - struct device_node *dn; - struct debugfs_blob_wrapper path; - char name[16]; -}; - -static ssize_t scom_debug_read(struct file *filp, 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; - u64 reg, reg_cnt, val; - scom_map_t map; - int rc; - - if (off < 0 || (off & 7) || (count & 7)) - return -EINVAL; - reg = off >> 3; - reg_cnt = count >> 3; - - map = scom_map(ent->dn, reg, reg_cnt); - if (!scom_map_ok(map)) - return -ENXIO; - - for (reg = 0; reg < reg_cnt; reg++) { - rc = scom_read(map, reg, &val); - if (!rc) - rc = put_user(val, ubuf64); - if (rc) { - if (!done) - done = rc; - break; - } - ubuf64++; - *ppos += 8; - done += 8; - } - scom_unmap(map); - return done; -} - -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; - u64 reg, reg_cnt, val; - scom_map_t map; - int rc; - - if (off < 0 || (off & 7) || (count & 7)) - return -EINVAL; - reg = off >> 3; - reg_cnt = count >> 3; - - map = scom_map(ent->dn, reg, reg_cnt); - if (!scom_map_ok(map)) - return -ENXIO; - - for (reg = 0; reg < reg_cnt; reg++) { - rc = get_user(val, ubuf64); - if (!rc) - rc = scom_write(map, reg, val); - if (rc) { - if (!done) - done = rc; - break; - } - ubuf64++; - done += 8; - } - scom_unmap(map); - return done; -} - -static const struct file_operations scom_debug_fops = { - .read = scom_debug_read, - .write = scom_debug_write, - .open = simple_open, - .llseek = default_llseek, -}; - -static int scom_debug_init_one(struct dentry *root, struct device_node *dn, - int i) -{ - struct scom_debug_entry *ent; - struct dentry *dir; - - ent = kzalloc(sizeof(*ent), GFP_KERNEL); - if (!ent) - return -ENOMEM; - - ent->dn = of_node_get(dn); - snprintf(ent->name, 16, "%08x", i); - ent->path.data = (void*)kasprintf(GFP_KERNEL, "%pOF", dn); - ent->path.size = strlen((char *)ent->path.data); - - dir = debugfs_create_dir(ent->name, root); - if (!dir) { - of_node_put(dn); - kfree(ent->path.data); - kfree(ent); - return -1; - } - - debugfs_create_blob("devspec", 0400, dir, &ent->path); - debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops); - - return 0; -} - -static int scom_debug_init(void) -{ - struct device_node *dn; - struct dentry *root; - int i, rc; - - root = debugfs_create_dir("scom", powerpc_debugfs_root); - if (!root) - return -1; - - i = rc = 0; - for_each_node_with_property(dn, "scom-controller") { - int id = of_get_ibm_chip_id(dn); - if (id == -1) - id = i; - rc |= scom_debug_init_one(root, dn, id); - i++; - } - - return rc; -} -device_initcall(scom_debug_init); -#endif /* CONFIG_SCOM_DEBUGFS */ diff --git a/arch/powerpc/platforms/powernv/scom.h b/arch/powerpc/platforms/powernv/scom.h deleted file mode 100644 index 2c72f7fc8726..000000000000 --- a/arch/powerpc/platforms/powernv/scom.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2010 Benjamin Herrenschmidt, IBM Corp - * <benh@kernel.crashing.org> - * and David Gibson, IBM Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _SCOM_H -#define _SCOM_H - -/* - * The SCOM bus is a sideband bus used for accessing various internal - * registers of the processor or the chipset. The implementation details - * differ between processors and platforms, and the access method as - * well. - * - * This API allows to "map" ranges of SCOM register numbers associated - * with a given SCOM controller. The later must be represented by a - * device node, though some implementations might support NULL if there - * is no possible ambiguity - * - * Then, scom_read/scom_write can be used to accesses registers inside - * that range. The argument passed is a register number relative to - * the beginning of the range mapped. - */ - -typedef void *scom_map_t; - -/* Value for an invalid SCOM map */ -#define SCOM_MAP_INVALID (NULL) - -/* The scom_controller data structure is what the platform passes - * to the core code in scom_init, it provides the actual implementation - * of all the SCOM functions - */ -struct scom_controller { - scom_map_t (*map)(struct device_node *ctrl_dev, u64 reg, u64 count); - void (*unmap)(scom_map_t map); - - int (*read)(scom_map_t map, u64 reg, u64 *value); - int (*write)(scom_map_t map, u64 reg, u64 value); -}; - -extern const struct scom_controller *scom_controller; - -/** - * scom_init - Initialize the SCOM backend, called by the platform - * @controller: The platform SCOM controller - */ -static inline void scom_init(const struct scom_controller *controller) -{ - scom_controller = controller; -} - -/** - * scom_map_ok - Test is a SCOM mapping is successful - * @map: The result of scom_map to test - */ -static inline int scom_map_ok(scom_map_t map) -{ - return map != SCOM_MAP_INVALID; -} - -/** - * scom_map - Map a block of SCOM registers - * @ctrl_dev: Device node of the SCOM controller - * some implementations allow NULL here - * @reg: first SCOM register to map - * @count: Number of SCOM registers to map - */ - -static inline scom_map_t scom_map(struct device_node *ctrl_dev, - u64 reg, u64 count) -{ - return scom_controller->map(ctrl_dev, reg, count); -} - -/** - * scom_unmap - Unmap a block of SCOM registers - * @map: Result of scom_map is to be unmapped - */ -static inline void scom_unmap(scom_map_t map) -{ - if (scom_map_ok(map)) - scom_controller->unmap(map); -} - -/** - * scom_read - Read a SCOM register - * @map: Result of scom_map - * @reg: Register index within that map - * @value: Updated with the value read - * - * Returns 0 (success) or a negative error code - */ -static inline int scom_read(scom_map_t map, u64 reg, u64 *value) -{ - int rc; - - rc = scom_controller->read(map, reg, value); - if (rc) - *value = 0xfffffffffffffffful; - return rc; -} - -/** - * scom_write - Write to a SCOM register - * @map: Result of scom_map - * @reg: Register index within that map - * @value: Value to write - * - * Returns 0 (success) or a negative error code - */ -static inline int scom_write(scom_map_t map, u64 reg, u64 value) -{ - return scom_controller->write(map, reg, value); -} - - -#endif /* _SCOM_H */ -- 2.20.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/5] powerpc/powernv: Fix checkpatch warnings in opal-xscom.c 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 2/5] powerpc/powernv: Remove dead SCOM access code Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 3/5] powerpc/powernv: Get rid of old scom_controller abstraction Andrew Donnellan @ 2019-05-09 5:11 ` Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig Andrew Donnellan ` (2 subsequent siblings) 5 siblings, 0 replies; 13+ messages in thread From: Andrew Donnellan @ 2019-05-09 5:11 UTC (permalink / raw) To: linuxppc-dev Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- v1->v2: - new patch --- arch/powerpc/platforms/powernv/opal-xscom.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c index e16b0e346d7e..d9607376822c 100644 --- a/arch/powerpc/platforms/powernv/opal-xscom.c +++ b/arch/powerpc/platforms/powernv/opal-xscom.c @@ -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); -- 2.20.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan ` (2 preceding siblings ...) 2019-05-09 5:11 ` [PATCH v2 4/5] powerpc/powernv: Fix checkpatch warnings in opal-xscom.c Andrew Donnellan @ 2019-05-09 5:11 ` Andrew Donnellan 2019-05-09 5:37 ` Nicholas Piggin 2019-06-04 2:01 ` [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan 2019-08-10 10:20 ` Michael Ellerman 5 siblings, 1 reply; 13+ messages in thread From: Andrew Donnellan @ 2019-05-09 5:11 UTC (permalink / raw) To: linuxppc-dev 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. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- v1->v2: - new patch --- arch/powerpc/configs/powernv_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig index ef2ef98d3f28..d5a6608cb2e0 100644 --- a/arch/powerpc/configs/powernv_defconfig +++ b/arch/powerpc/configs/powernv_defconfig @@ -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 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig 2019-05-09 5:11 ` [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig Andrew Donnellan @ 2019-05-09 5:37 ` Nicholas Piggin 2019-05-09 5:53 ` Oliver 2019-05-09 5:54 ` Andrew Donnellan 0 siblings, 2 replies; 13+ messages in thread From: Nicholas Piggin @ 2019-05-09 5:37 UTC (permalink / raw) To: Andrew Donnellan, linuxppc-dev Andrew Donnellan's on May 9, 2019 3:11 pm: > 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? > > Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> > --- > v1->v2: > - new patch > --- > arch/powerpc/configs/powernv_defconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig > index ef2ef98d3f28..d5a6608cb2e0 100644 > --- a/arch/powerpc/configs/powernv_defconfig > +++ b/arch/powerpc/configs/powernv_defconfig > @@ -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 > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig 2019-05-09 5:37 ` Nicholas Piggin @ 2019-05-09 5:53 ` Oliver 2019-05-09 5:54 ` Andrew Donnellan 1 sibling, 0 replies; 13+ messages in thread From: Oliver @ 2019-05-09 5:53 UTC (permalink / raw) To: Nicholas Piggin; +Cc: linuxppc-dev, Andrew Donnellan On Thu, May 9, 2019 at 3:38 PM Nicholas Piggin <npiggin@gmail.com> wrote: > > Andrew Donnellan's on May 9, 2019 3:11 pm: > > 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? Yeah... If you're building powernv_defconfig then the odds are pretty high that you'll want scom access. > > > > > Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> > > --- > > v1->v2: > > - new patch > > --- > > arch/powerpc/configs/powernv_defconfig | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig > > index ef2ef98d3f28..d5a6608cb2e0 100644 > > --- a/arch/powerpc/configs/powernv_defconfig > > +++ b/arch/powerpc/configs/powernv_defconfig > > @@ -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 > > > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig 2019-05-09 5:37 ` Nicholas Piggin 2019-05-09 5:53 ` Oliver @ 2019-05-09 5:54 ` Andrew Donnellan 2019-07-31 1:45 ` Andrew Donnellan 1 sibling, 1 reply; 13+ messages in thread From: Andrew Donnellan @ 2019-05-09 5:54 UTC (permalink / raw) To: Nicholas Piggin, linuxppc-dev On 9/5/19 3:37 pm, Nicholas Piggin wrote: > Andrew Donnellan's on May 9, 2019 3:11 pm: >> 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? 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 > >> >> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> >> --- >> v1->v2: >> - new patch >> --- >> arch/powerpc/configs/powernv_defconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig >> index ef2ef98d3f28..d5a6608cb2e0 100644 >> --- a/arch/powerpc/configs/powernv_defconfig >> +++ b/arch/powerpc/configs/powernv_defconfig >> @@ -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 >> >> > -- Andrew Donnellan OzLabs, ADL Canberra ajd@linux.ibm.com IBM Australia Limited ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig 2019-05-09 5:54 ` Andrew Donnellan @ 2019-07-31 1:45 ` Andrew Donnellan 2019-07-31 12:00 ` Michael Ellerman 0 siblings, 1 reply; 13+ messages in thread From: Andrew Donnellan @ 2019-07-31 1:45 UTC (permalink / raw) To: Nicholas Piggin, linuxppc-dev On 9/5/19 3:54 pm, Andrew Donnellan wrote: > On 9/5/19 3:37 pm, Nicholas Piggin wrote: >> Andrew Donnellan's on May 9, 2019 3:11 pm: >>> 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? > > 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 > > Andrew > > >> >>> >>> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> >>> --- >>> v1->v2: >>> - new patch >>> --- >>> arch/powerpc/configs/powernv_defconfig | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/arch/powerpc/configs/powernv_defconfig >>> b/arch/powerpc/configs/powernv_defconfig >>> index ef2ef98d3f28..d5a6608cb2e0 100644 >>> --- a/arch/powerpc/configs/powernv_defconfig >>> +++ b/arch/powerpc/configs/powernv_defconfig >>> @@ -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 >>> >>> >> > -- Andrew Donnellan OzLabs, ADL Canberra ajd@linux.ibm.com IBM Australia Limited ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig 2019-07-31 1:45 ` Andrew Donnellan @ 2019-07-31 12:00 ` Michael Ellerman 0 siblings, 0 replies; 13+ messages in thread From: Michael Ellerman @ 2019-07-31 12:00 UTC (permalink / raw) To: Andrew Donnellan, Nicholas Piggin, linuxppc-dev Andrew Donnellan <ajd@linux.ibm.com> writes: > On 9/5/19 3:54 pm, Andrew Donnellan wrote: >> On 9/5/19 3:37 pm, Nicholas Piggin wrote: >>> Andrew Donnellan's on May 9, 2019 3:11 pm: >>>> 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? >> >> 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. 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan ` (3 preceding siblings ...) 2019-05-09 5:11 ` [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig Andrew Donnellan @ 2019-06-04 2:01 ` Andrew Donnellan 2019-07-31 11:37 ` Michael Ellerman 2019-08-10 10:20 ` Michael Ellerman 5 siblings, 1 reply; 13+ messages in thread From: Andrew Donnellan @ 2019-06-04 2:01 UTC (permalink / raw) To: linuxppc-dev On 9/5/19 3:11 pm, Andrew Donnellan wrote: > 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 > > Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> > --- > 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%) > > diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig > index 850eee860cf2..938803eab0ad 100644 > --- a/arch/powerpc/platforms/powernv/Kconfig > +++ b/arch/powerpc/platforms/powernv/Kconfig > @@ -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 > diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile > index da2e99efbd04..4b1644150135 100644 > --- a/arch/powerpc/platforms/powernv/Makefile > +++ b/arch/powerpc/platforms/powernv/Makefile > @@ -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 > diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c > index 22d5e1110dbb..66337d92cb63 100644 > --- a/arch/powerpc/platforms/powernv/opal-xscom.c > +++ b/arch/powerpc/platforms/powernv/opal-xscom.c > @@ -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 > diff --git a/arch/powerpc/sysdev/scom.c b/arch/powerpc/platforms/powernv/scom.c > similarity index 99% > rename from arch/powerpc/sysdev/scom.c > rename to arch/powerpc/platforms/powernv/scom.c > index a707b24a7ddb..50c019d2ef45 100644 > --- a/arch/powerpc/sysdev/scom.c > +++ b/arch/powerpc/platforms/powernv/scom.c > @@ -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); > > diff --git a/arch/powerpc/include/asm/scom.h b/arch/powerpc/platforms/powernv/scom.h > similarity index 95% > rename from arch/powerpc/include/asm/scom.h > rename to arch/powerpc/platforms/powernv/scom.h > index f5cde45b1161..b14fe0edf95b 100644 > --- a/arch/powerpc/include/asm/scom.h > +++ b/arch/powerpc/platforms/powernv/scom.h > @@ -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 */ > diff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig > index e0dbec780fe9..7808d279ff1d 100644 > --- a/arch/powerpc/sysdev/Kconfig > +++ b/arch/powerpc/sysdev/Kconfig > @@ -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 > > diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile > index aaf23283ba0c..35d52d1d2fc0 100644 > --- a/arch/powerpc/sysdev/Makefile > +++ b/arch/powerpc/sysdev/Makefile > @@ -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/ > -- Andrew Donnellan OzLabs, ADL Canberra ajd@linux.ibm.com IBM Australia Limited ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform 2019-06-04 2:01 ` [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan @ 2019-07-31 11:37 ` Michael Ellerman 0 siblings, 0 replies; 13+ messages in thread From: Michael Ellerman @ 2019-07-31 11:37 UTC (permalink / raw) To: Andrew Donnellan, linuxppc-dev Andrew Donnellan <ajd@linux.ibm.com> writes: > On 9/5/19 3:11 pm, Andrew Donnellan wrote: >> 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? Yes, done. cheers ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan ` (4 preceding siblings ...) 2019-06-04 2:01 ` [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan @ 2019-08-10 10:20 ` Michael Ellerman 5 siblings, 0 replies; 13+ messages in thread From: Michael Ellerman @ 2019-08-10 10:20 UTC (permalink / raw) To: Andrew Donnellan, linuxppc-dev On Thu, 2019-05-09 at 05:11:15 UTC, Andrew Donnellan wrote: > 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. > > Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Series applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/08a456aa643776757e07adfdebe7f7681117d144 cheers ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-08-10 10:33 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-09 5:11 [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 2/5] powerpc/powernv: Remove dead SCOM access code Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 3/5] powerpc/powernv: Get rid of old scom_controller abstraction Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 4/5] powerpc/powernv: Fix checkpatch warnings in opal-xscom.c Andrew Donnellan 2019-05-09 5:11 ` [PATCH v2 5/5] powerpc/configs: Disable SCOM_DEBUGFS in powernv_defconfig Andrew Donnellan 2019-05-09 5:37 ` Nicholas Piggin 2019-05-09 5:53 ` Oliver 2019-05-09 5:54 ` Andrew Donnellan 2019-07-31 1:45 ` Andrew Donnellan 2019-07-31 12:00 ` Michael Ellerman 2019-06-04 2:01 ` [PATCH v2 1/5] powerpc/powernv: Move SCOM access code into powernv platform Andrew Donnellan 2019-07-31 11:37 ` Michael Ellerman 2019-08-10 10:20 ` Michael Ellerman
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.