* [RFC 03/15] PCI: move pci_scan_root_bus into callers
From: Arnd Bergmann @ 2018-08-17 10:26 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas
Cc: linux-kernel, Christoph Hellwig, Lorenzo Pieralisi,
Benjamin Herrenschmidt, linuxppc-dev, linux-acpi, Arnd Bergmann
In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de>
There are only six remaining callers of the old pci_scan_root_bus()
interface. Since we want to expose the pci_host_bridge structure
everywhere and discourage users from calling the old interfaces, let's
move the implementation into the respective callsites.
While this duplicates the source code, it makes the object code smaller
for almost all users by avoiding the global implementation, and it allows
further cleanup of the callers.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/ia64/sn/kernel/io_init.c | 27 +++++++++++++++++++++++++++
arch/microblaze/pci/pci-common.c | 27 +++++++++++++++++++++++++++
arch/s390/pci/pci.c | 27 +++++++++++++++++++++++++++
arch/x86/pci/common.c | 27 +++++++++++++++++++++++++++
arch/xtensa/kernel/pci.c | 27 +++++++++++++++++++++++++++
drivers/pci/probe.c | 28 ----------------------------
drivers/pci/xen-pcifront.c | 27 +++++++++++++++++++++++++++
include/linux/pci.h | 3 ---
8 files changed, 162 insertions(+), 31 deletions(-)
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index d63809a6adfa..e768702a7b45 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -213,6 +213,33 @@ sn_io_slot_fixup(struct pci_dev *dev)
}
EXPORT_SYMBOL(sn_io_slot_fixup);
+static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+ struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ list_splice_init(resources, &bridge->windows);
+ bridge->dev.parent = parent;
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err_out;
+
+ return bridge->bus;
+
+err_out:
+ kfree(bridge);
+ return NULL;
+}
+
/*
* sn_pci_controller_fixup() - This routine sets up a bus's resources
* consistent with the Linux PCI abstraction layer.
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index f34346d56095..302071385e1b 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -977,6 +977,33 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
(unsigned long)hose->io_base_virt - _IO_BASE);
}
+static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+ struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ list_splice_init(resources, &bridge->windows);
+ bridge->dev.parent = parent;
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err_out;
+
+ return bridge->bus;
+
+err_out:
+ kfree(bridge);
+ return NULL;
+}
+
static void pcibios_scan_phb(struct pci_controller *hose)
{
LIST_HEAD(resources);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 9f6f392a4461..b21205f131ce 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -786,6 +786,33 @@ void pcibios_remove_bus(struct pci_bus *bus)
kfree(zdev);
}
+static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+ struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ list_splice_init(resources, &bridge->windows);
+ bridge->dev.parent = parent;
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err_out;
+
+ return bridge->bus;
+
+err_out:
+ kfree(bridge);
+ return NULL;
+}
+
static int zpci_scan_bus(struct zpci_dev *zdev)
{
LIST_HEAD(resources);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index d4ec117c1142..e740d9aa4024 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -453,6 +453,33 @@ void __init dmi_check_pciprobe(void)
dmi_check_system(pciprobe_dmi_table);
}
+static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+ struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ list_splice_init(resources, &bridge->windows);
+ bridge->dev.parent = parent;
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err_out;
+
+ return bridge->bus;
+
+err_out:
+ kfree(bridge);
+ return NULL;
+}
+
void pcibios_scan_root(int busnum)
{
struct pci_bus *bus;
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 21f13e9aabe1..5a8fd67e6c5e 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -116,6 +116,33 @@ static void __init pci_controller_apertures(struct pci_controller *pci_ctrl,
}
}
+static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+ struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ list_splice_init(resources, &bridge->windows);
+ bridge->dev.parent = parent;
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err_out;
+
+ return bridge->bus;
+
+err_out:
+ kfree(bridge);
+ return NULL;
+}
+
static int __init pcibios_init(void)
{
struct pci_controller *pci_ctrl;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 12c3aa63c34d..cf169742c03e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3050,34 +3050,6 @@ int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge)
}
EXPORT_SYMBOL(pci_scan_root_bus_bridge);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
- struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
- struct pci_host_bridge *bridge;
- int error;
-
- bridge = pci_alloc_host_bridge(0);
- if (!bridge)
- return NULL;
-
- list_splice_init(resources, &bridge->windows);
- bridge->dev.parent = parent;
- bridge->sysdata = sysdata;
- bridge->busnr = bus;
- bridge->ops = ops;
-
- error = pci_scan_root_bus_bridge(bridge);
- if (error < 0)
- goto err_out;
-
- return bridge->bus;
-
-err_out:
- kfree(bridge);
- return NULL;
-}
-EXPORT_SYMBOL(pci_scan_root_bus);
-
/**
* pci_rescan_bus_bridge_resize - Scan a PCI bus for devices
* @bridge: PCI bridge for the bus to scan
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index eba6e33147a2..24070e1c5f22 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -443,6 +443,33 @@ static int pcifront_scan_bus(struct pcifront_device *pdev,
return 0;
}
+static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+ struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ list_splice_init(resources, &bridge->windows);
+ bridge->dev.parent = parent;
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err_out;
+
+ return bridge->bus;
+
+err_out:
+ kfree(bridge);
+ return NULL;
+}
+
static int pcifront_scan_root(struct pcifront_device *pdev,
unsigned int domain, unsigned int bus)
{
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d77ce35a2b33..d226e06fb5e5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -912,9 +912,6 @@ int pci_host_probe(struct pci_host_bridge *bridge);
int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
- struct pci_ops *ops, void *sysdata,
- struct list_head *resources);
int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge);
struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
int busnr);
--
2.18.0
^ permalink raw reply related
* [RFC 14/15] PCI: make pcibios_root_bridge_prepare a callback
From: Arnd Bergmann @ 2018-08-17 10:26 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas
Cc: linux-kernel, Christoph Hellwig, Lorenzo Pieralisi,
Benjamin Herrenschmidt, linuxppc-dev, linux-acpi, Arnd Bergmann
In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de>
pcibios_root_bridge_prepare() is always used as a per host bridge
function, not per architecture.
Making it a callback in the pci_host_bridge instead lets the host
bridge implementation easily override it, and avoids the checks
in the architecture for which host bridge implementation is being
used.
Alternatively, we could probably just call the pcibios_root_bridge_prepare
after alloc_pci_host_bridge() here and get rid of it as a generic
interface altogether, but doing that has a slightly higher chance
of breaking something subtle.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm64/kernel/pci.c | 18 ++++++++----------
arch/ia64/pci/pci.c | 15 ++++-----------
arch/powerpc/kernel/pci-common.c | 9 +--------
arch/x86/pci/acpi.c | 15 ++++-----------
drivers/acpi/pci_root.c | 1 +
drivers/pci/probe.c | 28 ++++++++++++++++------------
include/linux/acpi.h | 2 ++
include/linux/pci.h | 3 +--
8 files changed, 37 insertions(+), 54 deletions(-)
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 3d196c68e362..8958a7c32a9f 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -71,19 +71,17 @@ int acpi_pci_bus_find_domain_nr(struct pci_bus *bus)
return root->segment;
}
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge)
{
- if (!acpi_disabled) {
- struct pci_config_window *cfg = bridge->bus->sysdata;
- struct acpi_device *adev = to_acpi_device(cfg->parent);
- struct device *bus_dev = &bridge->bus->dev;
+ struct pci_config_window *cfg = bridge->bus->sysdata;
+ struct acpi_device *adev = to_acpi_device(cfg->parent);
+ struct device *bus_dev = &bridge->bus->dev;
- ACPI_COMPANION_SET(&bridge->dev, adev);
- set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev)));
+ ACPI_COMPANION_SET(&bridge->dev, adev);
+ set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev)));
- /* Try to assign the IRQ number when probing a new device */
- bridge->alloc_irq = acpi_pci_irq_enable;
- }
+ /* Try to assign the IRQ number when probing a new device */
+ bridge->alloc_irq = acpi_pci_irq_enable;
return 0;
}
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 7ccc64d5fe3e..511b8a058d80 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -308,18 +308,11 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
&info->common, &info->controller);
}
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge)
{
- /*
- * We pass NULL as parent to pci_create_root_bus(), so if it is not NULL
- * here, pci_create_root_bus() has been called by someone else and
- * sysdata is likely to be different from what we expect. Let it go in
- * that case.
- */
- if (!bridge->dev.parent) {
- struct pci_controller *controller = bridge->bus->sysdata;
- ACPI_COMPANION_SET(&bridge->dev, controller->companion);
- }
+ struct pci_controller *controller = bridge->bus->sysdata;
+ ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+
return 0;
}
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index afc9598e4349..5e5c6dd7ebe8 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -771,14 +771,6 @@ int pci_proc_domain(struct pci_bus *bus)
return 1;
}
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
- if (ppc_md.pcibios_root_bridge_prepare)
- return ppc_md.pcibios_root_bridge_prepare(bridge);
-
- return 0;
-}
-
/* This header fixup will do the resource fixup for all devices as they are
* probed, but not for bridge ranges
*/
@@ -1612,6 +1604,7 @@ void pcibios_scan_phb(struct pci_controller *hose)
pci_add_resource(&bridge->windows, &hose->busn);
bridge->bus_add_device = ppc_md->pcibios_bus_add_device;
+ bridge->prepare = ppc_md->pcibios_root_bridge_prepare;
bridge->dev.parent = hose->parent;
bridge->sysdata = hose;
bridge->busnr = hose->first_busno;
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 5559dcaddd5e..041b2003707c 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -382,18 +382,11 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
return bus;
}
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge)
{
- /*
- * We pass NULL as parent to pci_create_root_bus(), so if it is not NULL
- * here, pci_create_root_bus() has been called by someone else and
- * sysdata is likely to be different from what we expect. Let it go in
- * that case.
- */
- if (!bridge->dev.parent) {
- struct pci_sysdata *sd = bridge->bus->sysdata;
- ACPI_COMPANION_SET(&bridge->dev, sd->companion);
- }
+ struct pci_sysdata *sd = bridge->bus->sysdata;
+ ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+
return 0;
}
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 5f73de3b67c8..5da0f70c4e65 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -910,6 +910,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
bridge->sysdata = sysdata;
bridge->busnr = busnum;
bridge->ops = ops->pci_ops;
+ bridge->prepare = acpi_pci_root_bridge_prepare;
pci_set_host_bridge_release(bridge, acpi_pci_root_release_info,
info);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index eaedb4fe143a..f493d7e299e6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -762,6 +762,22 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus)
dev_set_msi_domain(&bus->dev, d);
}
+/**
+ * pcibios_root_bridge_prepare - Platform-specific host bridge setup
+ * @bridge: Host bridge to set up
+ *
+ * Host bridge drivers can do some last minute fixups on the bridge
+ * here. Usually this should be done before calling pci_register_host_bridge
+ * though, so this hook can be removed.
+ */
+static int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+{
+ if (bridge->prepare)
+ return bridge->prepare(bridge);
+
+ return 0;
+}
+
/*
* pci_register_host_bridge() - Register a host bridge without scanning
*
@@ -2889,18 +2905,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
}
EXPORT_SYMBOL_GPL(pci_scan_child_bus);
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup
- * @bridge: Host bridge to set up
- *
- * Default empty implementation. Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
- return 0;
-}
-
void __weak pcibios_add_bus(struct pci_bus *bus)
{
}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 9967ba2e0b31..62c0278a7614 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -336,12 +336,14 @@ extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
void acpi_unregister_gsi (u32 gsi);
struct pci_dev;
+struct pci_host_bridge;
int acpi_pci_irq_enable (struct pci_dev *dev);
void acpi_penalize_isa_irq(int irq, int active);
bool acpi_isa_irq_available(int irq);
void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
void acpi_pci_irq_disable (struct pci_dev *dev);
+int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge);
extern int ec_read(u8 addr, u8 *val);
extern int ec_write(u8 addr, u8 val);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 1296d9fcc5da..24216daef6f8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -472,6 +472,7 @@ struct pci_host_bridge {
void *sysdata;
int busnr;
struct list_head windows; /* resource_entry */
+ int (*prepare)(struct pci_host_bridge *bridge);
u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */
int (*map_irq)(const struct pci_dev *, u8, u8);
void (*release_fn)(struct pci_host_bridge *);
@@ -518,8 +519,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
void (*release_fn)(struct pci_host_bridge *),
void *release_data);
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
/*
* The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
* to P2P or CardBus bridge windows) go in a table. Additional ones (for
--
2.18.0
^ permalink raw reply related
* [RFC 11/15] PCI: hyperv: convert to pci_scan_root_bus_bridge
From: Arnd Bergmann @ 2018-08-17 10:26 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas
Cc: linux-kernel, Christoph Hellwig, Lorenzo Pieralisi,
Benjamin Herrenschmidt, linuxppc-dev, linux-acpi, Arnd Bergmann
In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de>
create_root_hv_pci_bus() uses a rather generic method of probing the host
bridge, which can be simplified by just calling pci_scan_root_bus_bridge()
after setting up the pci_host_bridge structure.
Since we can no longer assign hbus->pci_bus in the middle, I just remove
that member completely and use the pci_host_bridge instead.
Ideally we'd convert it to pci_host_probe() for simplicity, but
that is a bit different and I could not easily test it. Using
pci_scan_root_bus_bridge should not change the behavior at all.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/pci/controller/pci-hyperv.c | 75 +++++++++++------------------
1 file changed, 28 insertions(+), 47 deletions(-)
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index df7cddea8e30..49586aefa38b 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -443,7 +443,7 @@ struct hv_pcibus_device {
struct resource *high_mmio_res;
struct completion *survey_event;
struct completion remove_event;
- struct pci_bus *pci_bus;
+ struct pci_host_bridge *bridge;
spinlock_t config_lock; /* Avoid two threads writing index page */
spinlock_t device_list_lock; /* Protect lists below */
void __iomem *cfg_addr;
@@ -1457,34 +1457,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus)
spin_unlock_irqrestore(&hbus->device_list_lock, flags);
}
-static struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
- struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
- int error;
- struct pci_host_bridge *bridge;
-
- bridge = pci_alloc_host_bridge(0);
- if (!bridge)
- return NULL;
-
- bridge->dev.parent = parent;
-
- list_splice_init(resources, &bridge->windows);
- bridge->sysdata = sysdata;
- bridge->busnr = bus;
- bridge->ops = ops;
-
- error = pci_register_host_bridge(bridge);
- if (error < 0)
- goto err_out;
-
- return bridge->bus;
-
-err_out:
- kfree(bridge);
- return NULL;
-}
-
/**
* create_root_hv_pci_bus() - Expose a new root PCI bus
* @hbus: Root PCI bus, as understood by this driver
@@ -1493,25 +1465,34 @@ static struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
*/
static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)
{
- /* Register the device */
- hbus->pci_bus = pci_create_root_bus(&hbus->hdev->device,
- 0, /* bus number is always zero */
- &hv_pcifront_ops,
- &hbus->sysdata,
- &hbus->resources_for_children);
- if (!hbus->pci_bus)
- return -ENODEV;
+ struct pci_host_bridge *bridge;
+ int ret;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return -ENOMEM;
- hbus->pci_bus->msi = &hbus->msi_chip;
- hbus->pci_bus->msi->dev = &hbus->hdev->device;
+ hbus->bridge = bridge;
+ bridge->dev.parent = &hbus->hdev->device;
+ list_splice_init(&hbus->resources_for_children, &bridge->windows);
+ bridge->sysdata = &hbus->sysdata;
+ bridge->ops = &hv_pcifront_ops;
+ bridge->msi = &hbus->msi_chip;
+ bridge->msi->dev = &hbus->hdev->device;
pci_lock_rescan_remove();
- pci_scan_child_bus(hbus->pci_bus);
- pci_bus_assign_resources(hbus->pci_bus);
- pci_bus_add_devices(hbus->pci_bus);
- pci_unlock_rescan_remove();
+ /* ideally we should use pci_host_probe here */
+ ret = pci_scan_root_bus_bridge(bridge);
+ if (ret < 0) {
+ pci_free_host_bridge(bridge);
+ goto error;
+ }
+ pci_bus_assign_resources(bridge->bus);
+ pci_bus_add_devices(bridge->bus);
hbus->state = hv_pcibus_installed;
- return 0;
+error:
+ pci_unlock_rescan_remove();
+ return ret;
}
struct q_res_req_compl {
@@ -1769,7 +1750,7 @@ static void pci_devices_present_work(struct work_struct *work)
* because there may have been changes.
*/
pci_lock_rescan_remove();
- pci_scan_child_bus(hbus->pci_bus);
+ pci_scan_child_bus(hbus->bridge->bus);
pci_unlock_rescan_remove();
break;
@@ -2669,8 +2650,8 @@ static int hv_pci_remove(struct hv_device *hdev)
if (hbus->state == hv_pcibus_installed) {
/* Remove the bus from PCI's point of view. */
pci_lock_rescan_remove();
- pci_stop_root_bus(hbus->pci_bus);
- pci_remove_root_bus(hbus->pci_bus);
+ pci_stop_root_bus(hbus->bridge->bus);
+ pci_remove_root_bus(hbus->bridge->bus);
pci_unlock_rescan_remove();
hbus->state = hv_pcibus_removed;
}
--
2.18.0
^ permalink raw reply related
* [RFC 07/15] PCI/ACPI: clean up acpi_pci_root_create()
From: Arnd Bergmann @ 2018-08-17 10:26 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas
Cc: linux-kernel, Christoph Hellwig, Lorenzo Pieralisi,
Benjamin Herrenschmidt, linuxppc-dev, linux-acpi, Arnd Bergmann
In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de>
The acpi_pci_create_root_bus() can be fully integrated into
acpi_pci_root_create(), improving a few things:
* We can call pci_scan_root_bus_bridge(), which registers and
scans the bridge in one step.
* After a failure in pci_register_host_bridge(), we correctly
clean up the resources.
* The bridge settings (release function, flags, operations etc)
can get set up before registering the bridge.
* Further cleanup would be possible, removing duplication between
pci_host_bridge and some ACPI structures.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/acpi/pci_root.c | 68 +++++++++++++++--------------------------
1 file changed, 24 insertions(+), 44 deletions(-)
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 85dbcf47015b..5f73de3b67c8 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -873,34 +873,6 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge)
__acpi_pci_root_release_info(bridge->release_data);
}
-static struct pci_bus *acpi_pci_create_root_bus(struct device *parent, int bus,
- struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
- int error;
- struct pci_host_bridge *bridge;
-
- bridge = pci_alloc_host_bridge(0);
- if (!bridge)
- return NULL;
-
- bridge->dev.parent = parent;
-
- list_splice_init(resources, &bridge->windows);
- bridge->sysdata = sysdata;
- bridge->busnr = bus;
- bridge->ops = ops;
-
- error = pci_register_host_bridge(bridge);
- if (error < 0)
- goto err_out;
-
- return bridge->bus;
-
-err_out:
- kfree(bridge);
- return NULL;
-}
-
struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
struct acpi_pci_root_ops *ops,
struct acpi_pci_root_info *info,
@@ -909,8 +881,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
int ret, busnum = root->secondary.start;
struct acpi_device *device = root->device;
int node = acpi_get_node(device->handle);
- struct pci_bus *bus;
- struct pci_host_bridge *host_bridge;
+ struct pci_host_bridge *bridge;
info->root = root;
info->bridge = device;
@@ -930,30 +901,39 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
pci_acpi_root_add_resources(info);
pci_add_resource(&info->resources, &root->secondary);
- bus = acpi_pci_create_root_bus(NULL, busnum, ops->pci_ops,
- sysdata, &info->resources);
- if (!bus)
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
goto out_release_info;
- host_bridge = to_pci_host_bridge(bus->bridge);
+ list_splice_init(&info->resources, &bridge->windows);
+ bridge->sysdata = sysdata;
+ bridge->busnr = busnum;
+ bridge->ops = ops->pci_ops;
+ pci_set_host_bridge_release(bridge, acpi_pci_root_release_info,
+ info);
+
if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
- host_bridge->native_pcie_hotplug = 0;
+ bridge->native_pcie_hotplug = 0;
if (!(root->osc_control_set & OSC_PCI_SHPC_NATIVE_HP_CONTROL))
- host_bridge->native_shpc_hotplug = 0;
+ bridge->native_shpc_hotplug = 0;
if (!(root->osc_control_set & OSC_PCI_EXPRESS_AER_CONTROL))
- host_bridge->native_aer = 0;
+ bridge->native_aer = 0;
if (!(root->osc_control_set & OSC_PCI_EXPRESS_PME_CONTROL))
- host_bridge->native_pme = 0;
+ bridge->native_pme = 0;
if (!(root->osc_control_set & OSC_PCI_EXPRESS_LTR_CONTROL))
- host_bridge->native_ltr = 0;
+ bridge->native_ltr = 0;
+
+ ret = pci_scan_root_bus_bridge(bridge);
+ if (ret < 0)
+ goto out_release_bridge;
- pci_scan_child_bus(bus);
- pci_set_host_bridge_release(host_bridge, acpi_pci_root_release_info,
- info);
if (node != NUMA_NO_NODE)
- dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node);
- return bus;
+ dev_printk(KERN_DEBUG, &bridge->bus->dev, "on NUMA node %d\n", node);
+ return bridge->bus;
+out_release_bridge:
+ pci_free_host_bridge(bridge);
out_release_info:
__acpi_pci_root_release_info(info);
return NULL;
--
2.18.0
^ permalink raw reply related
* [RFC 08/15] x86: PCI: clean up pcibios_scan_root()
From: Arnd Bergmann @ 2018-08-17 10:26 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas
Cc: linux-kernel, Christoph Hellwig, Lorenzo Pieralisi,
Benjamin Herrenschmidt, linuxppc-dev, linux-acpi, Arnd Bergmann
In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de>
pcibios_scan_root() is now just a wrapper around pci_scan_root_bus(),
and merging the two into one makes it shorter and more readable.
We can also take advantage of pci_alloc_host_bridge() doing the
allocation of the sysdata for us, which helps if we ever want to
allow hot-unplugging the host bridge itself.
We might be able to simplify it further using pci_host_probe(),
but I wasn't sure about the resource registration there.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/x86/pci/common.c | 53 ++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 36 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index e740d9aa4024..920d0885434c 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -453,54 +453,35 @@ void __init dmi_check_pciprobe(void)
dmi_check_system(pciprobe_dmi_table);
}
-static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
- struct pci_ops *ops, void *sysdata, struct list_head *resources)
+void pcibios_scan_root(int busnum)
{
+ struct pci_sysdata *sd;
struct pci_host_bridge *bridge;
int error;
- bridge = pci_alloc_host_bridge(0);
- if (!bridge)
- return NULL;
+ bridge = pci_alloc_host_bridge(sizeof(sd));
+ if (!bridge) {
+ printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum);
+ return;
+ }
+ sd = pci_host_bridge_priv(bridge);
- list_splice_init(resources, &bridge->windows);
- bridge->dev.parent = parent;
- bridge->sysdata = sysdata;
- bridge->busnr = bus;
- bridge->ops = ops;
+ sd->node = x86_pci_root_bus_node(busnum);
+ x86_pci_root_bus_resources(busnum, &bridge->windows);
+ bridge->sysdata = sd;
+ bridge->busnr = busnum;
+ bridge->ops = &pci_root_ops;
+ printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
error = pci_scan_root_bus_bridge(bridge);
if (error < 0)
goto err_out;
- return bridge->bus;
+ pci_bus_add_devices(bridge->bus);
+ return;
err_out:
- kfree(bridge);
- return NULL;
-}
-
-void pcibios_scan_root(int busnum)
-{
- struct pci_bus *bus;
- struct pci_sysdata *sd;
- LIST_HEAD(resources);
-
- sd = kzalloc(sizeof(*sd), GFP_KERNEL);
- if (!sd) {
- printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum);
- return;
- }
- sd->node = x86_pci_root_bus_node(busnum);
- x86_pci_root_bus_resources(busnum, &resources);
- printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
- bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
- if (!bus) {
- pci_free_resource_list(&resources);
- kfree(sd);
- return;
- }
- pci_bus_add_devices(bus);
+ pci_free_host_bridge(bridge);
}
void __init pcibios_set_cache_line_size(void)
--
2.18.0
^ permalink raw reply related
* [RFC 02/15] PCI: move pci_scan_bus into callers
From: Arnd Bergmann @ 2018-08-17 10:26 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas
Cc: linux-kernel, Christoph Hellwig, Lorenzo Pieralisi,
Benjamin Herrenschmidt, linuxppc-dev, linux-acpi, Arnd Bergmann
In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de>
There are only two remaining callers of the old pci_scan_bus()
interface. Since we want to expose the pci_host_bridge structure
everywhere and discourage users from calling the old interfaces,
let's move the implementation into the respective callsites.
While this duplicates the source code, it makes the object code
smaller for all users by avoiding the global implementation,
and it allows further cleanup of the two callers.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/sparc/kernel/pcic.c | 35 ++++++++++++++++++++++++++++++
drivers/pci/hotplug/ibmphp_core.c | 35 ++++++++++++++++++++++++++++++
drivers/pci/probe.c | 36 -------------------------------
include/linux/pci.h | 1 -
4 files changed, 70 insertions(+), 37 deletions(-)
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index ee4c9a9a171c..0197b80fe590 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -387,6 +387,41 @@ int __init pcic_probe(void)
return 0;
}
+static struct resource busn_resource = {
+ .name = "PCI busn",
+ .start = 0,
+ .end = 255,
+ .flags = IORESOURCE_BUS,
+};
+
+static struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+ void *sysdata)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ pci_add_resource(&bridge->windows, &ioport_resource);
+ pci_add_resource(&bridge->windows, &iomem_resource);
+ pci_add_resource(&bridge->windows, &busn_resource);
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err;
+
+ return bridge->bus;
+
+err_res:
+ pci_free_host_bridge(bridge);
+ return NULL;
+}
+
static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
{
struct linux_pbm_info *pbm = &pcic->pbm;
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 4ea57e9019f1..d35463ee96ba 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -717,6 +717,41 @@ static void ibm_unconfigure_device(struct pci_func *func)
pci_unlock_rescan_remove();
}
+static struct resource busn_resource = {
+ .name = "pci busn",
+ .start = 0,
+ .end = 255,
+ .flags = IORESOURCE_BUS,
+};
+
+static struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+ void *sysdata)
+{
+ struct pci_host_bridge *bridge;
+ int error;
+
+ bridge = pci_alloc_host_bridge(0);
+ if (!bridge)
+ return NULL;
+
+ pci_add_resource(&bridge->windows, &ioport_resource);
+ pci_add_resource(&bridge->windows, &iomem_resource);
+ pci_add_resource(&bridge->windows, &busn_resource);
+ bridge->sysdata = sysdata;
+ bridge->busnr = bus;
+ bridge->ops = ops;
+
+ error = pci_scan_root_bus_bridge(bridge);
+ if (error < 0)
+ goto err;
+
+ return bridge->bus;
+
+err:
+ pci_free_host_bridge(bridge);
+ return NULL;
+}
+
/*
* The following function is to fix kernel bug regarding
* getting bus entries, here we manually add those primary
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b0f666271245..12c3aa63c34d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3078,42 +3078,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
}
EXPORT_SYMBOL(pci_scan_root_bus);
-static struct resource busn_resource = {
- .name = "PCI busn",
- .start = 0,
- .end = 255,
- .flags = IORESOURCE_BUS,
-};
-
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
- void *sysdata)
-{
- struct pci_host_bridge *bridge;
- int error;
-
- bridge = pci_alloc_host_bridge(0);
- if (!bridge)
- goto err;
-
- pci_add_resource(&bridge->windows, &ioport_resource);
- pci_add_resource(&bridge->windows, &iomem_resource);
- pci_add_resource(&bridge->windows, &busn_resource);
- bridge->sysdata = sysdata;
- bridge->busnr = bus;
- bridge->ops = ops;
-
- error = pci_scan_root_bus_bridge(bridge);
- if (error < 0)
- goto err;
-
- return bridge->bus;
-
-err:
- pci_free_host_bridge(bridge);
- return NULL;
-}
-EXPORT_SYMBOL(pci_scan_bus);
-
/**
* pci_rescan_bus_bridge_resize - Scan a PCI bus for devices
* @bridge: PCI bridge for the bus to scan
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e72ca8dd6241..d77ce35a2b33 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -905,7 +905,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
void pcibios_scan_specific_bus(int busn);
struct pci_bus *pci_find_bus(int domain, int busnr);
void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
struct pci_ops *ops, void *sysdata,
struct list_head *resources);
--
2.18.0
^ permalink raw reply related
* Re: [PATCH] powerpc64/ftrace: Include ftrace.h needed for enable/disable calls
From: Naveen N. Rao @ 2018-08-17 10:25 UTC (permalink / raw)
To: Luke Dashjr, Ingo Molnar, Paul Mackerras, Steven Rostedt
Cc: kvm-ppc, linuxppc-dev, Michael Ellerman
In-Reply-To: <201808162136.27788.luke@dashjr.org>
Luke Dashjr wrote:
> this_cpu_disable_ftrace and this_cpu_enable_ftrace are inlines in ftrace.=
h
> Without it included, the build fails.
I'm unable to reproduce this. Can you share your .config and the build=20
environment?
>=20
> Fixes: a4bc64d305af ("powerpc64/ftrace: Disable ftrace during kvm entry/e=
xit")
> Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
> Cc: stable@vger.kernel.org
> ---
> arch/powerpc/kvm/book3s_hv.c | 1 +
> 1 file changed, 1 insertion(+)
>=20
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index ee4a8854985e..15c2c64291f4 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -46,6 +46,7 @@
> #include <linux/compiler.h>
> #include <linux/of.h>
>=20
> +#include <asm/ftrace.h>
> #include <asm/reg.h>
> #include <asm/ppc-opcode.h>
> #include <asm/asm-prototypes.h>
In any case, this change itself looks alright to me. So:
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Thanks,
Naveen
=
^ permalink raw reply
* Re: [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: Greg Kroah-Hartman @ 2018-08-17 10:06 UTC (permalink / raw)
To: David Hildenbrand
Cc: Rafael J. Wysocki, Michal Hocko, Benjamin Herrenschmidt,
Heiko Carstens, Linux Memory Management List, Paul Mackerras,
linux-s390, sthemmin, Pavel Tatashin, ACPI Devel Maling List,
David Rientjes, xen-devel, Len Brown, haiyangz, Dan Williams,
Andrew Morton, Vlastimil Babka, osalvador, Rafael J. Wysocki,
Linux Kernel Mailing List, Martin Schwidefsky, devel,
Vitaly Kuznetsov, linuxppc-dev
In-Reply-To: <42df9062-f647-3ad6-5a07-be2b99531119@redhat.com>
On Fri, Aug 17, 2018 at 11:41:24AM +0200, David Hildenbrand wrote:
> On 17.08.2018 11:03, Rafael J. Wysocki wrote:
> > On Fri, Aug 17, 2018 at 10:56 AM David Hildenbrand <david@redhat.com> wrote:
> >>
> >> On 17.08.2018 10:41, Greg Kroah-Hartman wrote:
> >>> On Fri, Aug 17, 2018 at 09:59:00AM +0200, David Hildenbrand wrote:
> >>>> From: Vitaly Kuznetsov <vkuznets@redhat.com>
> >>>>
> >>>> Well require to call add_memory()/add_memory_resource() with
> >>>> device_hotplug_lock held, to avoid a lock inversion. Allow external modules
> >>>> (e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
> >>>> lock device hotplug.
> >>>>
> >>>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> >>>> [modify patch description]
> >>>> Signed-off-by: David Hildenbrand <david@redhat.com>
> >>>> ---
> >>>> drivers/base/core.c | 2 ++
> >>>> 1 file changed, 2 insertions(+)
> >>>>
> >>>> diff --git a/drivers/base/core.c b/drivers/base/core.c
> >>>> index 04bbcd779e11..9010b9e942b5 100644
> >>>> --- a/drivers/base/core.c
> >>>> +++ b/drivers/base/core.c
> >>>> @@ -700,11 +700,13 @@ void lock_device_hotplug(void)
> >>>> {
> >>>> mutex_lock(&device_hotplug_lock);
> >>>> }
> >>>> +EXPORT_SYMBOL_GPL(lock_device_hotplug);
> >>>>
> >>>> void unlock_device_hotplug(void)
> >>>> {
> >>>> mutex_unlock(&device_hotplug_lock);
> >>>> }
> >>>> +EXPORT_SYMBOL_GPL(unlock_device_hotplug);
> >>>
> >>> If these are going to be "global" symbols, let's properly name them.
> >>> device_hotplug_lock/unlock would be better. But I am _really_ nervous
> >>> about letting stuff outside of the driver core mess with this, as people
> >>> better know what they are doing.
> >>
> >> The only "problem" is that we have kernel modules (for paravirtualized
> >> devices) that call add_memory(). This is Hyper-V right now, but we might
> >> have other ones in the future. Without them we would not have to export
> >> it. We might also get kernel modules that want to call remove_memory() -
> >> which will require the device_hotplug_lock as of now.
> >>
> >> What we could do is
> >>
> >> a) add_memory() -> _add_memory() and don't export it
> >> b) add_memory() takes the device_hotplug_lock and calls _add_memory() .
> >> We export that one.
> >> c) Use add_memory() in external modules only
> >>
> >> Similar wrapper would be needed e.g. for remove_memory() later on.
> >
> > That would be safer IMO, as it would prevent developers from using
> > add_memory() without the lock, say.
> >
> > If the lock is always going to be required for add_memory(), make it
> > hard (or event impossible) to use the latter without it.
> >
>
> If there are no objections, I'll go into that direction. But I'll wait
> for more comments regarding the general concept first.
It is the middle of the merge window, and maintainers are really busy
right now. I doubt you will get many review comments just yet...
^ permalink raw reply
* Re: [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: David Hildenbrand @ 2018-08-17 9:41 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Greg Kroah-Hartman, Linux Kernel Mailing List,
Linux Memory Management List, linuxppc-dev,
ACPI Devel Maling List, devel, linux-s390, xen-devel,
Andrew Morton, Michal Hocko, Vlastimil Babka, Dan Williams,
Pavel Tatashin, osalvador, Vitaly Kuznetsov, Martin Schwidefsky,
Heiko Carstens, kys, haiyangz, sthemmin, Benjamin Herrenschmidt,
Paul Mackerras, Rafael J. Wysocki, Len Brown, David Rientjes
In-Reply-To: <CAJZ5v0gkYV8o2Eq+EcGT=OP1tQGPGVVe3n9VGD6z7KAVVqhv9w@mail.gmail.com>
On 17.08.2018 11:03, Rafael J. Wysocki wrote:
> On Fri, Aug 17, 2018 at 10:56 AM David Hildenbrand <david@redhat.com> wrote:
>>
>> On 17.08.2018 10:41, Greg Kroah-Hartman wrote:
>>> On Fri, Aug 17, 2018 at 09:59:00AM +0200, David Hildenbrand wrote:
>>>> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>>>>
>>>> Well require to call add_memory()/add_memory_resource() with
>>>> device_hotplug_lock held, to avoid a lock inversion. Allow external modules
>>>> (e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
>>>> lock device hotplug.
>>>>
>>>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>>> [modify patch description]
>>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>>> ---
>>>> drivers/base/core.c | 2 ++
>>>> 1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>>>> index 04bbcd779e11..9010b9e942b5 100644
>>>> --- a/drivers/base/core.c
>>>> +++ b/drivers/base/core.c
>>>> @@ -700,11 +700,13 @@ void lock_device_hotplug(void)
>>>> {
>>>> mutex_lock(&device_hotplug_lock);
>>>> }
>>>> +EXPORT_SYMBOL_GPL(lock_device_hotplug);
>>>>
>>>> void unlock_device_hotplug(void)
>>>> {
>>>> mutex_unlock(&device_hotplug_lock);
>>>> }
>>>> +EXPORT_SYMBOL_GPL(unlock_device_hotplug);
>>>
>>> If these are going to be "global" symbols, let's properly name them.
>>> device_hotplug_lock/unlock would be better. But I am _really_ nervous
>>> about letting stuff outside of the driver core mess with this, as people
>>> better know what they are doing.
>>
>> The only "problem" is that we have kernel modules (for paravirtualized
>> devices) that call add_memory(). This is Hyper-V right now, but we might
>> have other ones in the future. Without them we would not have to export
>> it. We might also get kernel modules that want to call remove_memory() -
>> which will require the device_hotplug_lock as of now.
>>
>> What we could do is
>>
>> a) add_memory() -> _add_memory() and don't export it
>> b) add_memory() takes the device_hotplug_lock and calls _add_memory() .
>> We export that one.
>> c) Use add_memory() in external modules only
>>
>> Similar wrapper would be needed e.g. for remove_memory() later on.
>
> That would be safer IMO, as it would prevent developers from using
> add_memory() without the lock, say.
>
> If the lock is always going to be required for add_memory(), make it
> hard (or event impossible) to use the latter without it.
>
If there are no objections, I'll go into that direction. But I'll wait
for more comments regarding the general concept first.
Thanks!
--
Thanks,
David / dhildenb
^ permalink raw reply
* [PATCH] poewrpc/mce: Fix SLB rebolting during MCE recovery path.
From: Mahesh J Salgaonkar @ 2018-08-17 9:21 UTC (permalink / raw)
To: linuxppc-dev, Michael Ellerman
Cc: Nicholas Piggin, Nicholas Piggin, Aneesh Kumar K.V
From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
With the powrpc next commit e7e81847478 (poewrpc/mce: Fix SLB rebolting
during MCE recovery path.), the SLB error recovery is broken. The
commit missed a crucial change of OR-ing index value to RB[52-63] which
selects the SLB entry while rebolting. This patch fixes that.
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/mm/slb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index 0b095fa54049..6dd9913425bc 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -101,9 +101,12 @@ void __slb_restore_bolted_realmode(void)
/* No isync needed because realmode. */
for (index = 0; index < SLB_NUM_BOLTED; index++) {
+ unsigned long rb = be64_to_cpu(p->save_area[index].esid);
+
+ rb = (rb & ~0xFFFul) | index;
asm volatile("slbmte %0,%1" :
: "r" (be64_to_cpu(p->save_area[index].vsid)),
- "r" (be64_to_cpu(p->save_area[index].esid)));
+ "r" (rb));
}
}
^ permalink raw reply related
* Re: [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: Rafael J. Wysocki @ 2018-08-17 9:03 UTC (permalink / raw)
To: David Hildenbrand
Cc: Greg Kroah-Hartman, Linux Kernel Mailing List,
Linux Memory Management List, linuxppc-dev,
ACPI Devel Maling List, devel, linux-s390, xen-devel,
Andrew Morton, Michal Hocko, Vlastimil Babka, Dan Williams,
Pavel Tatashin, osalvador, Vitaly Kuznetsov, Martin Schwidefsky,
Heiko Carstens, kys, haiyangz, sthemmin, Benjamin Herrenschmidt,
Paul Mackerras, Rafael J. Wysocki, Len Brown, David Rientjes
In-Reply-To: <5a5d73e9-e4aa-ffed-a2e3-8aef64e61923@redhat.com>
On Fri, Aug 17, 2018 at 10:56 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 17.08.2018 10:41, Greg Kroah-Hartman wrote:
> > On Fri, Aug 17, 2018 at 09:59:00AM +0200, David Hildenbrand wrote:
> >> From: Vitaly Kuznetsov <vkuznets@redhat.com>
> >>
> >> Well require to call add_memory()/add_memory_resource() with
> >> device_hotplug_lock held, to avoid a lock inversion. Allow external modules
> >> (e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
> >> lock device hotplug.
> >>
> >> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> >> [modify patch description]
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >> ---
> >> drivers/base/core.c | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >> diff --git a/drivers/base/core.c b/drivers/base/core.c
> >> index 04bbcd779e11..9010b9e942b5 100644
> >> --- a/drivers/base/core.c
> >> +++ b/drivers/base/core.c
> >> @@ -700,11 +700,13 @@ void lock_device_hotplug(void)
> >> {
> >> mutex_lock(&device_hotplug_lock);
> >> }
> >> +EXPORT_SYMBOL_GPL(lock_device_hotplug);
> >>
> >> void unlock_device_hotplug(void)
> >> {
> >> mutex_unlock(&device_hotplug_lock);
> >> }
> >> +EXPORT_SYMBOL_GPL(unlock_device_hotplug);
> >
> > If these are going to be "global" symbols, let's properly name them.
> > device_hotplug_lock/unlock would be better. But I am _really_ nervous
> > about letting stuff outside of the driver core mess with this, as people
> > better know what they are doing.
>
> The only "problem" is that we have kernel modules (for paravirtualized
> devices) that call add_memory(). This is Hyper-V right now, but we might
> have other ones in the future. Without them we would not have to export
> it. We might also get kernel modules that want to call remove_memory() -
> which will require the device_hotplug_lock as of now.
>
> What we could do is
>
> a) add_memory() -> _add_memory() and don't export it
> b) add_memory() takes the device_hotplug_lock and calls _add_memory() .
> We export that one.
> c) Use add_memory() in external modules only
>
> Similar wrapper would be needed e.g. for remove_memory() later on.
That would be safer IMO, as it would prevent developers from using
add_memory() without the lock, say.
If the lock is always going to be required for add_memory(), make it
hard (or event impossible) to use the latter without it.
^ permalink raw reply
* Re: [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: Rafael J. Wysocki @ 2018-08-17 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: David Hildenbrand, Linux Kernel Mailing List,
Linux Memory Management List, linuxppc-dev,
ACPI Devel Maling List, devel, linux-s390, xen-devel,
Andrew Morton, Michal Hocko, Vlastimil Babka, Dan Williams,
Pavel Tatashin, osalvador, Vitaly Kuznetsov, Martin Schwidefsky,
Heiko Carstens, kys, haiyangz, sthemmin, Benjamin Herrenschmidt,
Paul Mackerras, Rafael J. Wysocki, Len Brown, David Rientjes
In-Reply-To: <20180817084146.GB14725@kroah.com>
On Fri, Aug 17, 2018 at 10:41 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Aug 17, 2018 at 09:59:00AM +0200, David Hildenbrand wrote:
> > From: Vitaly Kuznetsov <vkuznets@redhat.com>
> >
> > Well require to call add_memory()/add_memory_resource() with
> > device_hotplug_lock held, to avoid a lock inversion. Allow external modules
> > (e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
> > lock device hotplug.
> >
> > Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> > [modify patch description]
> > Signed-off-by: David Hildenbrand <david@redhat.com>
> > ---
> > drivers/base/core.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index 04bbcd779e11..9010b9e942b5 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -700,11 +700,13 @@ void lock_device_hotplug(void)
> > {
> > mutex_lock(&device_hotplug_lock);
> > }
> > +EXPORT_SYMBOL_GPL(lock_device_hotplug);
> >
> > void unlock_device_hotplug(void)
> > {
> > mutex_unlock(&device_hotplug_lock);
> > }
> > +EXPORT_SYMBOL_GPL(unlock_device_hotplug);
>
> If these are going to be "global" symbols, let's properly name them.
> device_hotplug_lock/unlock would be better.
Well, device_hotplug_lock is the name of the lock itself. :-)
> But I am _really_ nervous about letting stuff outside of the driver core mess
> with this, as people better know what they are doing.
>
> Can't we just "lock" the memory stuff instead? Why does the entirety of
> the driver core need to be messed with here?
Because, in general, memory hotplug and hotplug of devices are not
independent. CPUs and memory may only be possible to take away
together and that may be the case for other devices too (say, it
wouldn't be a good idea to access a memory block that has just gone
away from a device, for DMA and the like). That's why
device_hotplug_lock was introduced in the first place.
That said I agree that exporting this to drivers doesn't feel particularly safe.
^ permalink raw reply
* Re: [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: David Hildenbrand @ 2018-08-17 8:56 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, linux-mm, linuxppc-dev, linux-acpi, devel,
linux-s390, xen-devel, Andrew Morton, Michal Hocko,
Vlastimil Babka, Dan Williams, Pavel Tatashin, Oscar Salvador,
Vitaly Kuznetsov, Martin Schwidefsky, Heiko Carstens,
K . Y . Srinivasan, Haiyang Zhang, Stephen Hemminger,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J . Wysocki,
Len Brown, David Rientjes
In-Reply-To: <20180817084146.GB14725@kroah.com>
On 17.08.2018 10:41, Greg Kroah-Hartman wrote:
> On Fri, Aug 17, 2018 at 09:59:00AM +0200, David Hildenbrand wrote:
>> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>>
>> Well require to call add_memory()/add_memory_resource() with
>> device_hotplug_lock held, to avoid a lock inversion. Allow external modules
>> (e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
>> lock device hotplug.
>>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> [modify patch description]
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>> drivers/base/core.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 04bbcd779e11..9010b9e942b5 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -700,11 +700,13 @@ void lock_device_hotplug(void)
>> {
>> mutex_lock(&device_hotplug_lock);
>> }
>> +EXPORT_SYMBOL_GPL(lock_device_hotplug);
>>
>> void unlock_device_hotplug(void)
>> {
>> mutex_unlock(&device_hotplug_lock);
>> }
>> +EXPORT_SYMBOL_GPL(unlock_device_hotplug);
>
> If these are going to be "global" symbols, let's properly name them.
> device_hotplug_lock/unlock would be better. But I am _really_ nervous
> about letting stuff outside of the driver core mess with this, as people
> better know what they are doing.
The only "problem" is that we have kernel modules (for paravirtualized
devices) that call add_memory(). This is Hyper-V right now, but we might
have other ones in the future. Without them we would not have to export
it. We might also get kernel modules that want to call remove_memory() -
which will require the device_hotplug_lock as of now.
What we could do is
a) add_memory() -> _add_memory() and don't export it
b) add_memory() takes the device_hotplug_lock and calls _add_memory() .
We export that one.
c) Use add_memory() in external modules only
Similar wrapper would be needed e.g. for remove_memory() later on.
>
> Can't we just "lock" the memory stuff instead? Why does the entirety of
> the driver core need to be messed with here?
The main problem is that add_memory() will first take the
mem_hotplug_lock, to later on create and attach the memory block devices
(to a bus without any drivers) via bus_probe_device(). Here, we will
take the device_lock() of these devices.
Setting a device online from user space (.online = true) will first take
the device_hotplug_lock, then the device_lock(), and _right now_ not the
mem_hotplug_lock (see cover letter/patch 2).
We have to take mem_hotplug_lock here, but doing it down in e.g.
online_pages() will right now create the possibility for a lock
inversion. So one alternative is to take the mem_hotplug_lock in core.c
before calling device_online()/device_offline(). But this feels very wrong.
Thanks!
>
> thanks,
>
> greg k-h
>
--
Thanks,
David / dhildenb
^ permalink raw reply
* Re: [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: Greg Kroah-Hartman @ 2018-08-17 8:41 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-kernel, linux-mm, linuxppc-dev, linux-acpi, devel,
linux-s390, xen-devel, Andrew Morton, Michal Hocko,
Vlastimil Babka, Dan Williams, Pavel Tatashin, Oscar Salvador,
Vitaly Kuznetsov, Martin Schwidefsky, Heiko Carstens,
K . Y . Srinivasan, Haiyang Zhang, Stephen Hemminger,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J . Wysocki,
Len Brown, David Rientjes
In-Reply-To: <20180817075901.4608-2-david@redhat.com>
On Fri, Aug 17, 2018 at 09:59:00AM +0200, David Hildenbrand wrote:
> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> Well require to call add_memory()/add_memory_resource() with
> device_hotplug_lock held, to avoid a lock inversion. Allow external modules
> (e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
> lock device hotplug.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> [modify patch description]
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> drivers/base/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 04bbcd779e11..9010b9e942b5 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -700,11 +700,13 @@ void lock_device_hotplug(void)
> {
> mutex_lock(&device_hotplug_lock);
> }
> +EXPORT_SYMBOL_GPL(lock_device_hotplug);
>
> void unlock_device_hotplug(void)
> {
> mutex_unlock(&device_hotplug_lock);
> }
> +EXPORT_SYMBOL_GPL(unlock_device_hotplug);
If these are going to be "global" symbols, let's properly name them.
device_hotplug_lock/unlock would be better. But I am _really_ nervous
about letting stuff outside of the driver core mess with this, as people
better know what they are doing.
Can't we just "lock" the memory stuff instead? Why does the entirety of
the driver core need to be messed with here?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH RFC 2/2] mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock
From: David Hildenbrand @ 2018-08-17 8:27 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux Kernel Mailing List, Linux Memory Management List,
linuxppc-dev, ACPI Devel Maling List, devel, linux-s390,
xen-devel, Andrew Morton, Michal Hocko, Vlastimil Babka,
Dan Williams, Pavel Tatashin, osalvador, Vitaly Kuznetsov,
Martin Schwidefsky, Heiko Carstens, kys, haiyangz, sthemmin,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J. Wysocki,
Len Brown, Greg Kroah-Hartman, David Rientjes
In-Reply-To: <CAJZ5v0jpx_XOmkSkMiSxcECxNHGXPGZHtgqRy_Q7iKnf-C55pg@mail.gmail.com>
On 17.08.2018 10:20, Rafael J. Wysocki wrote:
> On Fri, Aug 17, 2018 at 9:59 AM David Hildenbrand <david@redhat.com> wrote:
>>
>> There seem to be some problems as result of 30467e0b3be ("mm, hotplug:
>> fix concurrent memory hot-add deadlock"), which tried to fix a possible
>> lock inversion reported and discussed in [1] due to the two locks
>> a) device_lock()
>> b) mem_hotplug_lock
>>
>> While add_memory() first takes b), followed by a) during
>> bus_probe_device(), onlining of memory from user space first took b),
>> followed by a), exposing a possible deadlock.
>>
>> In [1], and it was decided to not make use of device_hotplug_lock, but
>> rather to enforce a locking order. Looking at 1., this order is not always
>> satisfied when calling device_online() - essentially we simply don't take
>> one of both locks anymore - and fixing this would require us to
>> take the mem_hotplug_lock in core driver code (online_store()), which
>> sounds wrong.
>>
>> The problems I spotted related to this:
>>
>> 1. Memory block device attributes: While .state first calls
>> mem_hotplug_begin() and the calls device_online() - which takes
>> device_lock() - .online does no longer call mem_hotplug_begin(), so
>> effectively calls online_pages() without mem_hotplug_lock. onlining/
>> offlining of pages is no longer serialised across different devices.
>>
>> 2. device_online() should be called under device_hotplug_lock, however
>> onlining memory during add_memory() does not take care of that. (I
>> didn't follow how strictly this is needed, but there seems to be a
>> reason because it is documented at device_online() and
>> device_offline()).
>>
>> In addition, I think there is also something wrong about the locking in
>>
>> 3. arch/powerpc/platforms/powernv/memtrace.c calls offline_pages()
>> (and device_online()) without locks. This was introduced after
>> 30467e0b3be. And skimming over the code, I assume it could need some
>> more care in regards to locking.
>>
>> ACPI code already holds the device_hotplug_lock, and as we are
>> effectively hotplugging memory block devices, requiring to hold that
>> lock does not sound too wrong, although not chosen in [1], as
>> "I don't think resolving a locking dependency is appropriate by
>> just serializing them with another lock."
>> I think this is the cleanest solution.
>>
>> Requiring add_memory()/add_memory_resource() to be called under
>> device_hotplug_lock fixes 2., taking the mem_hotplug_lock in
>> online_pages/offline_pages() fixes 1. and 3.
>>
>> Fixup all callers of add_memory/add_memory_resource to hold the lock if
>> not already done.
>>
>> So this is essentially a revert of 30467e0b3be, implementation of what
>> was suggested in [1] by Vitaly, applied to the current tree.
>>
>> [1] http://driverdev.linuxdriverproject.org/pipermail/ driverdev-devel/
>> 2015-February/065324.html
>>
>> This patch is partly based on a patch by Vitaly Kuznetsov.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>> arch/powerpc/platforms/powernv/memtrace.c | 3 ++
>> drivers/acpi/acpi_memhotplug.c | 1 +
>> drivers/base/memory.c | 18 +++++-----
>> drivers/hv/hv_balloon.c | 4 +++
>> drivers/s390/char/sclp_cmd.c | 3 ++
>> drivers/xen/balloon.c | 3 ++
>> mm/memory_hotplug.c | 42 ++++++++++++++++++-----
>> 7 files changed, 55 insertions(+), 19 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
>> index 51dc398ae3f7..4c2737a33020 100644
>> --- a/arch/powerpc/platforms/powernv/memtrace.c
>> +++ b/arch/powerpc/platforms/powernv/memtrace.c
>> @@ -206,6 +206,8 @@ static int memtrace_online(void)
>> int i, ret = 0;
>> struct memtrace_entry *ent;
>>
>> + /* add_memory() requires device_hotplug_lock */
>> + lock_device_hotplug();
>> for (i = memtrace_array_nr - 1; i >= 0; i--) {
>> ent = &memtrace_array[i];
>>
>> @@ -244,6 +246,7 @@ static int memtrace_online(void)
>> pr_info("Added trace memory back to node %d\n", ent->nid);
>> ent->size = ent->start = ent->nid = -1;
>> }
>> + unlock_device_hotplug();
>> if (ret)
>> return ret;
>>
>> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
>> index 6b0d3ef7309c..e7a4c7900967 100644
>> --- a/drivers/acpi/acpi_memhotplug.c
>> +++ b/drivers/acpi/acpi_memhotplug.c
>> @@ -228,6 +228,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
>> if (node < 0)
>> node = memory_add_physaddr_to_nid(info->start_addr);
>>
>> + /* we already hold the device_hotplug lock at this point */
>> result = add_memory(node, info->start_addr, info->length);
>>
>> /*
>
> A very minor nit here: I would say "device_hotplug_lock is already
> held at this point" in the comment (I sort of don't like to say "we"
> in code comments as it is not particularly clear what group of people
> is represented by that and the lock is actually called
> device_hotplug_lock).
Easy to fix, thanks!
>
> Otherwise the approach is fine by me.
>
> BTW, the reason why device_hotplug_lock is acquired by the ACPI memory
> hotplug is because it generally needs to be synchronized with respect
> CPU hot-remove and similar. I believe that this may be the case in
> non-ACPI setups as well.
Yes, and that lock is the reason why we didn't have real problems with
ACPI memory hotplug in this respect so far. (as user triggered
online/offline also takes that lock already)
>
> Thanks,
> Rafael
>
--
Thanks,
David / dhildenb
^ permalink raw reply
* Re: [PATCH RFC 2/2] mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock
From: Rafael J. Wysocki @ 2018-08-17 8:20 UTC (permalink / raw)
To: David Hildenbrand
Cc: Linux Kernel Mailing List, Linux Memory Management List,
linuxppc-dev, ACPI Devel Maling List, devel, linux-s390,
xen-devel, Andrew Morton, Michal Hocko, Vlastimil Babka,
Dan Williams, Pavel Tatashin, osalvador, Vitaly Kuznetsov,
Martin Schwidefsky, Heiko Carstens, kys, haiyangz, sthemmin,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J. Wysocki,
Len Brown, Greg Kroah-Hartman, David Rientjes
In-Reply-To: <20180817075901.4608-3-david@redhat.com>
On Fri, Aug 17, 2018 at 9:59 AM David Hildenbrand <david@redhat.com> wrote:
>
> There seem to be some problems as result of 30467e0b3be ("mm, hotplug:
> fix concurrent memory hot-add deadlock"), which tried to fix a possible
> lock inversion reported and discussed in [1] due to the two locks
> a) device_lock()
> b) mem_hotplug_lock
>
> While add_memory() first takes b), followed by a) during
> bus_probe_device(), onlining of memory from user space first took b),
> followed by a), exposing a possible deadlock.
>
> In [1], and it was decided to not make use of device_hotplug_lock, but
> rather to enforce a locking order. Looking at 1., this order is not always
> satisfied when calling device_online() - essentially we simply don't take
> one of both locks anymore - and fixing this would require us to
> take the mem_hotplug_lock in core driver code (online_store()), which
> sounds wrong.
>
> The problems I spotted related to this:
>
> 1. Memory block device attributes: While .state first calls
> mem_hotplug_begin() and the calls device_online() - which takes
> device_lock() - .online does no longer call mem_hotplug_begin(), so
> effectively calls online_pages() without mem_hotplug_lock. onlining/
> offlining of pages is no longer serialised across different devices.
>
> 2. device_online() should be called under device_hotplug_lock, however
> onlining memory during add_memory() does not take care of that. (I
> didn't follow how strictly this is needed, but there seems to be a
> reason because it is documented at device_online() and
> device_offline()).
>
> In addition, I think there is also something wrong about the locking in
>
> 3. arch/powerpc/platforms/powernv/memtrace.c calls offline_pages()
> (and device_online()) without locks. This was introduced after
> 30467e0b3be. And skimming over the code, I assume it could need some
> more care in regards to locking.
>
> ACPI code already holds the device_hotplug_lock, and as we are
> effectively hotplugging memory block devices, requiring to hold that
> lock does not sound too wrong, although not chosen in [1], as
> "I don't think resolving a locking dependency is appropriate by
> just serializing them with another lock."
> I think this is the cleanest solution.
>
> Requiring add_memory()/add_memory_resource() to be called under
> device_hotplug_lock fixes 2., taking the mem_hotplug_lock in
> online_pages/offline_pages() fixes 1. and 3.
>
> Fixup all callers of add_memory/add_memory_resource to hold the lock if
> not already done.
>
> So this is essentially a revert of 30467e0b3be, implementation of what
> was suggested in [1] by Vitaly, applied to the current tree.
>
> [1] http://driverdev.linuxdriverproject.org/pipermail/ driverdev-devel/
> 2015-February/065324.html
>
> This patch is partly based on a patch by Vitaly Kuznetsov.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> arch/powerpc/platforms/powernv/memtrace.c | 3 ++
> drivers/acpi/acpi_memhotplug.c | 1 +
> drivers/base/memory.c | 18 +++++-----
> drivers/hv/hv_balloon.c | 4 +++
> drivers/s390/char/sclp_cmd.c | 3 ++
> drivers/xen/balloon.c | 3 ++
> mm/memory_hotplug.c | 42 ++++++++++++++++++-----
> 7 files changed, 55 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
> index 51dc398ae3f7..4c2737a33020 100644
> --- a/arch/powerpc/platforms/powernv/memtrace.c
> +++ b/arch/powerpc/platforms/powernv/memtrace.c
> @@ -206,6 +206,8 @@ static int memtrace_online(void)
> int i, ret = 0;
> struct memtrace_entry *ent;
>
> + /* add_memory() requires device_hotplug_lock */
> + lock_device_hotplug();
> for (i = memtrace_array_nr - 1; i >= 0; i--) {
> ent = &memtrace_array[i];
>
> @@ -244,6 +246,7 @@ static int memtrace_online(void)
> pr_info("Added trace memory back to node %d\n", ent->nid);
> ent->size = ent->start = ent->nid = -1;
> }
> + unlock_device_hotplug();
> if (ret)
> return ret;
>
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 6b0d3ef7309c..e7a4c7900967 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -228,6 +228,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
> if (node < 0)
> node = memory_add_physaddr_to_nid(info->start_addr);
>
> + /* we already hold the device_hotplug lock at this point */
> result = add_memory(node, info->start_addr, info->length);
>
> /*
A very minor nit here: I would say "device_hotplug_lock is already
held at this point" in the comment (I sort of don't like to say "we"
in code comments as it is not particularly clear what group of people
is represented by that and the lock is actually called
device_hotplug_lock).
Otherwise the approach is fine by me.
BTW, the reason why device_hotplug_lock is acquired by the ACPI memory
hotplug is because it generally needs to be synchronized with respect
CPU hot-remove and similar. I believe that this may be the case in
non-ACPI setups as well.
Thanks,
Rafael
^ permalink raw reply
* [PATCH RFC 2/2] mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock
From: David Hildenbrand @ 2018-08-17 7:59 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linuxppc-dev, linux-acpi, devel, linux-s390, xen-devel,
Andrew Morton, Michal Hocko, Vlastimil Babka, Dan Williams,
Pavel Tatashin, Oscar Salvador, Vitaly Kuznetsov,
Martin Schwidefsky, Heiko Carstens, David Hildenbrand,
K . Y . Srinivasan, Haiyang Zhang, Stephen Hemminger,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J . Wysocki,
Len Brown, Greg Kroah-Hartman, David Rientjes
In-Reply-To: <20180817075901.4608-1-david@redhat.com>
There seem to be some problems as result of 30467e0b3be ("mm, hotplug:
fix concurrent memory hot-add deadlock"), which tried to fix a possible
lock inversion reported and discussed in [1] due to the two locks
a) device_lock()
b) mem_hotplug_lock
While add_memory() first takes b), followed by a) during
bus_probe_device(), onlining of memory from user space first took b),
followed by a), exposing a possible deadlock.
In [1], and it was decided to not make use of device_hotplug_lock, but
rather to enforce a locking order. Looking at 1., this order is not always
satisfied when calling device_online() - essentially we simply don't take
one of both locks anymore - and fixing this would require us to
take the mem_hotplug_lock in core driver code (online_store()), which
sounds wrong.
The problems I spotted related to this:
1. Memory block device attributes: While .state first calls
mem_hotplug_begin() and the calls device_online() - which takes
device_lock() - .online does no longer call mem_hotplug_begin(), so
effectively calls online_pages() without mem_hotplug_lock. onlining/
offlining of pages is no longer serialised across different devices.
2. device_online() should be called under device_hotplug_lock, however
onlining memory during add_memory() does not take care of that. (I
didn't follow how strictly this is needed, but there seems to be a
reason because it is documented at device_online() and
device_offline()).
In addition, I think there is also something wrong about the locking in
3. arch/powerpc/platforms/powernv/memtrace.c calls offline_pages()
(and device_online()) without locks. This was introduced after
30467e0b3be. And skimming over the code, I assume it could need some
more care in regards to locking.
ACPI code already holds the device_hotplug_lock, and as we are
effectively hotplugging memory block devices, requiring to hold that
lock does not sound too wrong, although not chosen in [1], as
"I don't think resolving a locking dependency is appropriate by
just serializing them with another lock."
I think this is the cleanest solution.
Requiring add_memory()/add_memory_resource() to be called under
device_hotplug_lock fixes 2., taking the mem_hotplug_lock in
online_pages/offline_pages() fixes 1. and 3.
Fixup all callers of add_memory/add_memory_resource to hold the lock if
not already done.
So this is essentially a revert of 30467e0b3be, implementation of what
was suggested in [1] by Vitaly, applied to the current tree.
[1] http://driverdev.linuxdriverproject.org/pipermail/ driverdev-devel/
2015-February/065324.html
This patch is partly based on a patch by Vitaly Kuznetsov.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
arch/powerpc/platforms/powernv/memtrace.c | 3 ++
drivers/acpi/acpi_memhotplug.c | 1 +
drivers/base/memory.c | 18 +++++-----
drivers/hv/hv_balloon.c | 4 +++
drivers/s390/char/sclp_cmd.c | 3 ++
drivers/xen/balloon.c | 3 ++
mm/memory_hotplug.c | 42 ++++++++++++++++++-----
7 files changed, 55 insertions(+), 19 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 51dc398ae3f7..4c2737a33020 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -206,6 +206,8 @@ static int memtrace_online(void)
int i, ret = 0;
struct memtrace_entry *ent;
+ /* add_memory() requires device_hotplug_lock */
+ lock_device_hotplug();
for (i = memtrace_array_nr - 1; i >= 0; i--) {
ent = &memtrace_array[i];
@@ -244,6 +246,7 @@ static int memtrace_online(void)
pr_info("Added trace memory back to node %d\n", ent->nid);
ent->size = ent->start = ent->nid = -1;
}
+ unlock_device_hotplug();
if (ret)
return ret;
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 6b0d3ef7309c..e7a4c7900967 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -228,6 +228,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
if (node < 0)
node = memory_add_physaddr_to_nid(info->start_addr);
+ /* we already hold the device_hotplug lock at this point */
result = add_memory(node, info->start_addr, info->length);
/*
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index c8a1cb0b6136..f60507f994df 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -341,19 +341,11 @@ store_mem_state(struct device *dev,
goto err;
}
- /*
- * Memory hotplug needs to hold mem_hotplug_begin() for probe to find
- * the correct memory block to online before doing device_online(dev),
- * which will take dev->mutex. Take the lock early to prevent an
- * inversion, memory_subsys_online() callbacks will be implemented by
- * assuming it's already protected.
- */
- mem_hotplug_begin();
-
switch (online_type) {
case MMOP_ONLINE_KERNEL:
case MMOP_ONLINE_MOVABLE:
case MMOP_ONLINE_KEEP:
+ /* mem->online_type is protected by device_hotplug_lock */
mem->online_type = online_type;
ret = device_online(&mem->dev);
break;
@@ -364,7 +356,6 @@ store_mem_state(struct device *dev,
ret = -EINVAL; /* should never happen */
}
- mem_hotplug_done();
err:
unlock_device_hotplug();
@@ -522,6 +513,12 @@ memory_probe_store(struct device *dev, struct device_attribute *attr,
return -EINVAL;
nid = memory_add_physaddr_to_nid(phys_addr);
+
+ /* add_memory() requires the device_hotplug_lock */
+ ret = lock_device_hotplug_sysfs();
+ if (ret)
+ return ret;
+
ret = add_memory(nid, phys_addr,
MIN_MEMORY_BLOCK_SIZE * sections_per_block);
@@ -530,6 +527,7 @@ memory_probe_store(struct device *dev, struct device_attribute *attr,
ret = count;
out:
+ unlock_device_hotplug();
return ret;
}
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index b1b788082793..c6d0b654f109 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -735,8 +735,12 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
dm_device.ha_waiting = !memhp_auto_online;
nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn));
+
+ /* add_memory() requires the device_hotplug lock */
+ lock_device_hotplug();
ret = add_memory(nid, PFN_PHYS((start_pfn)),
(HA_CHUNK << PAGE_SHIFT));
+ unlock_device_hotplug();
if (ret) {
pr_err("hot_add memory failed error is %d\n", ret);
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index d7686a68c093..cd0cdab8fcfb 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -405,8 +405,11 @@ static void __init add_memory_merged(u16 rn)
align_to_block_size(&start, &size, block_size);
if (!size)
goto skip_add;
+ /* add_memory() requires the device_hotplug lock */
+ lock_device_hotplug();
for (addr = start; addr < start + size; addr += block_size)
add_memory(numa_pfn_to_nid(PFN_DOWN(addr)), addr, block_size);
+ unlock_device_hotplug();
skip_add:
first_rn = rn;
num = 1;
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 559e77a20a4d..df1ced4c0692 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -395,8 +395,11 @@ static enum bp_state reserve_additional_memory(void)
* callers drop the mutex before trying again.
*/
mutex_unlock(&balloon_mutex);
+ /* add_memory_resource() requires the device_hotplug lock */
+ lock_device_hotplug();
rc = add_memory_resource(nid, resource->start, resource_size(resource),
memhp_auto_online);
+ unlock_device_hotplug();
mutex_lock(&balloon_mutex);
if (rc) {
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 6a2726920ed2..492e558f791b 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -885,7 +885,6 @@ static struct zone * __meminit move_pfn_range(int online_type, int nid,
return zone;
}
-/* Must be protected by mem_hotplug_begin() or a device_lock */
int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type)
{
unsigned long flags;
@@ -897,6 +896,8 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
struct memory_notify arg;
struct memory_block *mem;
+ mem_hotplug_begin();
+
/*
* We can't use pfn_to_nid() because nid might be stored in struct page
* which is not yet initialized. Instead, we find nid from memory block.
@@ -961,6 +962,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
if (onlined_pages)
memory_notify(MEM_ONLINE, &arg);
+ mem_hotplug_done();
return 0;
failed_addition:
@@ -968,6 +970,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
(unsigned long long) pfn << PAGE_SHIFT,
(((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1);
memory_notify(MEM_CANCEL_ONLINE, &arg);
+ mem_hotplug_done();
return ret;
}
#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
@@ -1115,7 +1118,18 @@ static int online_memory_block(struct memory_block *mem, void *arg)
return device_online(&mem->dev);
}
-/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
+/*
+ * Requires device_hotplug_lock:
+ *
+ * add_memory_resource() will first take the mem_hotplug_lock and then
+ * device_lock() the created memory block device (via bus_probe_device()).
+ * However, device_online() calls device_lock() and then takes the
+ * mem_hotplug lock (via online_pages()). The device_hotplug_lock makes
+ * sure this lock inversion can never happen - and also device_online()
+ * needs it.
+ *
+ * we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG
+ */
int __ref add_memory_resource(int nid, u64 start, u64 size, bool online)
{
bool new_node = false;
@@ -1163,25 +1177,26 @@ int __ref add_memory_resource(int nid, u64 start, u64 size, bool online)
/* create new memmap entry */
firmware_map_add_hotplug(start, start + size, "System RAM");
+ /* device_online() will take the lock when calling online_pages() */
+ mem_hotplug_done();
+
/* online pages if requested */
if (online)
walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1),
NULL, online_memory_block);
- goto out;
-
+ return ret;
error:
/* rollback pgdat allocation and others */
if (new_node)
rollback_node_hotadd(nid);
memblock_remove(start, size);
-
-out:
mem_hotplug_done();
return ret;
}
EXPORT_SYMBOL_GPL(add_memory_resource);
+/* requires device_hotplug_lock, see add_memory_resource() */
int __ref add_memory(int nid, u64 start, u64 size)
{
struct resource *res;
@@ -1605,10 +1620,16 @@ static int __ref __offline_pages(unsigned long start_pfn,
return -EINVAL;
if (!IS_ALIGNED(end_pfn, pageblock_nr_pages))
return -EINVAL;
+
+ mem_hotplug_begin();
+
/* This makes hotplug much easier...and readable.
we assume this for now. .*/
- if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, &valid_end))
+ if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start,
+ &valid_end)) {
+ mem_hotplug_done();
return -EINVAL;
+ }
zone = page_zone(pfn_to_page(valid_start));
node = zone_to_nid(zone);
@@ -1617,8 +1638,10 @@ static int __ref __offline_pages(unsigned long start_pfn,
/* set above range as isolated */
ret = start_isolate_page_range(start_pfn, end_pfn,
MIGRATE_MOVABLE, true);
- if (ret)
+ if (ret) {
+ mem_hotplug_done();
return ret;
+ }
arg.start_pfn = start_pfn;
arg.nr_pages = nr_pages;
@@ -1689,6 +1712,7 @@ static int __ref __offline_pages(unsigned long start_pfn,
writeback_set_ratelimit();
memory_notify(MEM_OFFLINE, &arg);
+ mem_hotplug_done();
return 0;
failed_removal:
@@ -1698,10 +1722,10 @@ static int __ref __offline_pages(unsigned long start_pfn,
memory_notify(MEM_CANCEL_OFFLINE, &arg);
/* pushback to free area */
undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
+ mem_hotplug_done();
return ret;
}
-/* Must be protected by mem_hotplug_begin() or a device_lock */
int offline_pages(unsigned long start_pfn, unsigned long nr_pages)
{
return __offline_pages(start_pfn, start_pfn + nr_pages);
--
2.17.1
^ permalink raw reply related
* [PATCH RFC 1/2] drivers/base: export lock_device_hotplug/unlock_device_hotplug
From: David Hildenbrand @ 2018-08-17 7:59 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linuxppc-dev, linux-acpi, devel, linux-s390, xen-devel,
Andrew Morton, Michal Hocko, Vlastimil Babka, Dan Williams,
Pavel Tatashin, Oscar Salvador, Vitaly Kuznetsov,
Martin Schwidefsky, Heiko Carstens, David Hildenbrand,
K . Y . Srinivasan, Haiyang Zhang, Stephen Hemminger,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J . Wysocki,
Len Brown, Greg Kroah-Hartman, David Rientjes
In-Reply-To: <20180817075901.4608-1-david@redhat.com>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Well require to call add_memory()/add_memory_resource() with
device_hotplug_lock held, to avoid a lock inversion. Allow external modules
(e.g. hv_balloon) that make use of add_memory()/add_memory_resource() to
lock device hotplug.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
[modify patch description]
Signed-off-by: David Hildenbrand <david@redhat.com>
---
drivers/base/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 04bbcd779e11..9010b9e942b5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -700,11 +700,13 @@ void lock_device_hotplug(void)
{
mutex_lock(&device_hotplug_lock);
}
+EXPORT_SYMBOL_GPL(lock_device_hotplug);
void unlock_device_hotplug(void)
{
mutex_unlock(&device_hotplug_lock);
}
+EXPORT_SYMBOL_GPL(unlock_device_hotplug);
int lock_device_hotplug_sysfs(void)
{
--
2.17.1
^ permalink raw reply related
* [PATCH RFC 0/2] mm: online/offline_pages called w.o. mem_hotplug_lock
From: David Hildenbrand @ 2018-08-17 7:58 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linuxppc-dev, linux-acpi, devel, linux-s390, xen-devel,
Andrew Morton, Michal Hocko, Vlastimil Babka, Dan Williams,
Pavel Tatashin, Oscar Salvador, Vitaly Kuznetsov,
Martin Schwidefsky, Heiko Carstens, David Hildenbrand,
K . Y . Srinivasan, Haiyang Zhang, Stephen Hemminger,
Benjamin Herrenschmidt, Paul Mackerras, Rafael J . Wysocki,
Len Brown, Greg Kroah-Hartman, David Rientjes
Reading through the code and studying how mem_hotplug_lock is to be used,
I noticed that there are two places where we can end up calling
device_online()/device_offline() - online_pages()/offline_pages() without
the mem_hotplug_lock. And there are other places where we call
device_online()/device_offline() without the device_hotplug_lock.
While e.g.
echo "online" > /sys/devices/system/memory/memory9/state
is fine, e.g.
echo 1 > /sys/devices/system/memory/memory9/online
Will not take the mem_hotplug_lock. However the device_lock() and
device_hotplug_lock.
E.g. via memory_probe_store(), we can end up calling
add_memory()->online_pages() without the device_hotplug_lock. So we can
have concurrent callers in online_pages(). We e.g. touch in online_pages()
basically unprotected zone->present_pages then.
Looks like there is a longer history to that (see Patch #2 for details),
and fixing it to work the way it was intended is not really possible. We
would e.g. have to take the mem_hotplug_lock in device/base/core.c, which
sounds wrong.
Summary: We had a lock inversion on mem_hotplug_lock and device_lock(),
and the approach to fix it fixed one inversion, but dropped the
mem_hotplug_lock on another instance (.online).
As far as I understand from the code and from b93e0f329e24 ("mm,
memory_hotplug: get rid of zonelists_mutex"), mem_hotplug_lock is required
because we assume that
"both memory online and offline are fully serialized."
and this is not the case if we only hold the device_lock().
I propose the general rules:
1. add_memory/add_memory_resource() must only be called with
device_hotplug_lock. For now only done in ACPI code.
2. remove_memory() must only be called with device_hotplug_lock. This is
already documented and true in ACPI code.
3. device_online()/device_offline() must only be called with
device_hotplug_lock. This is already documented and true for now in core
code. Other callers (related to memory hotplug) have to be fixed up.
4. mem_hotplug_lock is taken inside of add_memory/remove_memory/
online_pages/offline_pages. For now this is only true for the first two
instances.
To me, this looks way cleaner than what we have right now (and easier to
verify). And looking at the documentation of remove_memory, using
lock_device_hotplug also for add_memory() feels natural. Second patch could
maybe split up.
But let's first hear if this is actually a problem and if there migh be
alternatives (or cleanups). Only tested with DIMM-based hotplug.
David Hildenbrand (1):
mm/memory_hotplug: fix online/offline_pages called w.o.
mem_hotplug_lock
Vitaly Kuznetsov (1):
drivers/base: export lock_device_hotplug/unlock_device_hotplug
arch/powerpc/platforms/powernv/memtrace.c | 3 ++
drivers/acpi/acpi_memhotplug.c | 1 +
drivers/base/core.c | 2 ++
drivers/base/memory.c | 18 +++++-----
drivers/hv/hv_balloon.c | 4 +++
drivers/s390/char/sclp_cmd.c | 3 ++
drivers/xen/balloon.c | 3 ++
mm/memory_hotplug.c | 42 ++++++++++++++++++-----
8 files changed, 57 insertions(+), 19 deletions(-)
--
2.17.1
^ permalink raw reply
* [PATCH v2] powerpc/powernv/pci: Work around races in PCI bridge enabling
From: Benjamin Herrenschmidt @ 2018-08-17 7:30 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Michael Ellerman
The generic code is race when multiple children of a PCI bridge try to
enable it simultaneously.
This leads to drivers trying to access a device through a not-yet-enabled
bridge, and this EEH errors under various circumstances when using parallel
driver probing.
There is work going on to fix that properly in the PCI core but it will
take some time.
x86 gets away with it because (outside of hotplug), the BIOS enables all
the bridges at boot time.
This patch does the same thing on powernv by enabling all bridges that
have child devices at boot time, thus avoiding subsequent races. It's suitable
for backporting to stable and distros, while the proper PCI fix will probably
be significantly more invasive.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: stable@vger.kernel.org
---
v2. Fix unused variables warning.
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 5bd0eb6681bc..ca720d530c6d 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3367,12 +3367,49 @@ static void pnv_pci_ioda_create_dbgfs(void)
#endif /* CONFIG_DEBUG_FS */
}
+static void pnv_pci_enable_bridge(struct pci_bus *bus)
+{
+ struct pci_dev *dev = bus->self;
+ struct pci_bus *child;
+
+ /* Empty bus ? bail */
+ if (list_empty(&bus->devices))
+ return;
+
+ /*
+ * If there's a bridge associated with that bus enable it. This works
+ * around races in the generic code if the enabling is done during
+ * parallel probing. This can be removed once those races have been
+ * fixed.
+ */
+ if (dev) {
+ int rc = pci_enable_device(dev);
+ if (rc)
+ pci_err(dev, "Error enabling bridge (%d)\n", rc);
+ pci_set_master(dev);
+ }
+
+ /* Perform the same to child busses */
+ list_for_each_entry(child, &bus->children, node)
+ pnv_pci_enable_bridge(child);
+}
+
+static void pnv_pci_enable_bridges(void)
+{
+ struct pci_controller *hose;
+
+ list_for_each_entry(hose, &hose_list, list_node)
+ pnv_pci_enable_bridge(hose->bus);
+}
+
static void pnv_pci_ioda_fixup(void)
{
pnv_pci_ioda_setup_PEs();
pnv_pci_ioda_setup_iommu_api();
pnv_pci_ioda_create_dbgfs();
+ pnv_pci_enable_bridges();
+
#ifdef CONFIG_EEH
pnv_eeh_post_init();
#endif
^ permalink raw reply related
* Re: [PATCH] powerpc/powernv/pci: Work around races in PCI bridge enabling
From: kbuild test robot @ 2018-08-17 6:58 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: kbuild-all, linuxppc-dev, Michael Ellerman
In-Reply-To: <16fa7682a17785cd2580a12fed60e237f6f98826.camel@kernel.crashing.org>
[-- Attachment #1: Type: text/plain, Size: 2028 bytes --]
Hi Benjamin,
I love your patch! Yet something to improve:
[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.18 next-20180817]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Benjamin-Herrenschmidt/powerpc-powernv-pci-Work-around-races-in-PCI-bridge-enabling/20180817-113453
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=powerpc
All errors (new ones prefixed by >>):
arch/powerpc/platforms/powernv/pci-ioda.c: In function 'pnv_pci_enable_bridges':
>> arch/powerpc/platforms/powernv/pci-ioda.c:3262:18: error: unused variable 'pdev' [-Werror=unused-variable]
struct pci_dev *pdev;
^~~~
>> arch/powerpc/platforms/powernv/pci-ioda.c:3261:18: error: unused variable 'bus' [-Werror=unused-variable]
struct pci_bus *bus;
^~~
>> arch/powerpc/platforms/powernv/pci-ioda.c:3260:18: error: unused variable 'phb' [-Werror=unused-variable]
struct pnv_phb *phb;
^~~
cc1: all warnings being treated as errors
vim +/pdev +3262 arch/powerpc/platforms/powernv/pci-ioda.c
3256
3257 static void pnv_pci_enable_bridges(void)
3258 {
3259 struct pci_controller *hose;
> 3260 struct pnv_phb *phb;
> 3261 struct pci_bus *bus;
> 3262 struct pci_dev *pdev;
3263
3264 list_for_each_entry(hose, &hose_list, list_node)
3265 pnv_pci_enable_bridge(hose->bus);
3266 }
3267
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23684 bytes --]
^ permalink raw reply
* [PATCH] powerpc/traps: Avoid rate limit messages from show unhandled signals
From: Michael Ellerman @ 2018-08-17 6:55 UTC (permalink / raw)
To: linuxppc-dev; +Cc: muriloo
In the recent commit to add an explicit ratelimit state when showing
unhandled signals, commit 35a52a10c3ac ("powerpc/traps: Use an
explicit ratelimit state for show_signal_msg()"), I put the check of
show_unhandled_signals and the ratelimit state before the call to
unhandled_signal() so as to avoid unnecessarily calling the latter
when show_unhandled_signals is false.
However that causes us to check the ratelimit state on every call, so
if we take a lot of *handled* signals that has the effect of making
the ratelimit code print warnings that callbacks have been suppressed
when they haven't.
So rearrange the code so that we check show_unhandled_signals first,
then call unhandled_signal() and finally check the ratelimit state.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/traps.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 070e96f1773a..c85adb858271 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -315,22 +315,21 @@ void user_single_step_siginfo(struct task_struct *tsk,
info->si_addr = (void __user *)regs->nip;
}
-static bool show_unhandled_signals_ratelimited(void)
+static void show_signal_msg(int signr, struct pt_regs *regs, int code,
+ unsigned long addr)
{
static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
- return show_unhandled_signals && __ratelimit(&rs);
-}
-static void show_signal_msg(int signr, struct pt_regs *regs, int code,
- unsigned long addr)
-{
- if (!show_unhandled_signals_ratelimited())
+ if (!show_unhandled_signals)
return;
if (!unhandled_signal(current, signr))
return;
+ if (!__ratelimit(&rs))
+ return;
+
pr_info("%s[%d]: %s (%d) at %lx nip %lx lr %lx code %x",
current->comm, current->pid, signame(signr), signr,
addr, regs->nip, regs->link, code);
--
2.17.1
^ permalink raw reply related
* [PATCH] powerpc/memtrace: Remove memory in chunks
From: Rashmica Gupta @ 2018-08-17 4:25 UTC (permalink / raw)
To: mpe, bsingharora, mikey, linuxppc-dev, anton; +Cc: Rashmica Gupta
When hot-removing memory release_mem_region_adjustable() splits iomem
resources if they are not the exact size of the memory being
hot-deleted. Adding this memory back to the kernel adds a new resource.
Eg a node has memory 0x0 - 0xfffffffff. Hot-removing 1GB from
0xf40000000 results in the single resource 0x0-0xfffffffff being split
into two resources: 0x0-0xf3fffffff and 0xf80000000-0xfffffffff.
When we hot-add the memory back we now have three resources:
0x0-0xf3fffffff, 0xf40000000-0xf7fffffff, and 0xf80000000-0xfffffffff.
This is an issue if we try to remove some memory that overlaps
resources. Eg when trying to remove 2GB at address 0xf40000000,
release_mem_region_adjustable() fails as it expects the chunk of memory
to be within the boundaries of a single resource. We then get the
warning: "Unable to release resource" and attempting to use memtrace
again gives us this error: "bash: echo: write error: Resource
temporarily unavailable"
This patch makes memtrace remove memory in chunks that are always the
same size from an address that is always equal to end_of_memory -
n*size, for some n. So hotremoving and hotadding memory of different
sizes will now not attempt to remove memory that spans multiple
resources.
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
---
To replicate the above issue hot-remove and hot-add memory of different
sizes a bunch of times. This does it for me on POWER8 and POWER9:
for i in `seq 1 10`; do
echo $(( $i * 268435456)) > /sys/kernel/debug/powerpc/memtrace/enable
echo '.'
done
arch/powerpc/platforms/powernv/memtrace.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 51fe0862dcab..c5749f898652 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -119,17 +119,15 @@ static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages)
walk_memory_range(start_pfn, end_pfn, (void *)MEM_OFFLINE,
change_memblock_state);
- lock_device_hotplug();
- remove_memory(nid, start_pfn << PAGE_SHIFT, nr_pages << PAGE_SHIFT);
- unlock_device_hotplug();
return true;
}
static u64 memtrace_alloc_node(u32 nid, u64 size)
{
- u64 start_pfn, end_pfn, nr_pages;
+ u64 start_pfn, end_pfn, nr_pages, pfn;
u64 base_pfn;
+ u64 bytes = memory_block_size_bytes();
if (!node_spanned_pages(nid))
return 0;
@@ -142,8 +140,20 @@ static u64 memtrace_alloc_node(u32 nid, u64 size)
end_pfn = round_down(end_pfn - nr_pages, nr_pages);
for (base_pfn = end_pfn; base_pfn > start_pfn; base_pfn -= nr_pages) {
- if (memtrace_offline_pages(nid, base_pfn, nr_pages) == true)
+ if (memtrace_offline_pages(nid, base_pfn, nr_pages) == true) {
+ /* Remove memory in memory block size chunks so that
+ * iomem resources are always split to the same size
+ * and we never try to remove memory that spans two
+ * iomem resources.
+ */
+ lock_device_hotplug();
+ end_pfn = base_pfn + nr_pages;
+ for (pfn = base_pfn; pfn < end_pfn; pfn += bytes>> PAGE_SHIFT) {
+ remove_memory(nid, pfn << PAGE_SHIFT, bytes);
+ }
+ unlock_device_hotplug();
return base_pfn << PAGE_SHIFT;
+ }
}
return 0;
--
2.14.4
^ permalink raw reply related
* [GIT PULL] Please pull powerpc/linux.git powerpc-4.19-1 tag
From: Michael Ellerman @ 2018-08-17 3:49 UTC (permalink / raw)
To: Linus Torvalds
Cc: AlexeiS, Bharat.Bhushan, aaro.koskinen, aik, akshay.adiga,
alastair, alistair, andrew.donnellan, aneesh.kumar, aneesh.kumar,
anju, arbab, arnd, benh, boqun.feng, brgl, bsingharora,
camelia.groza, christophe.leroy, cyrilbur, dan.carpenter, darren,
david, diana.craciun, eleon, elfring, fbarrat, fbarrat, fthain,
geert, geoff, gregkh, haren, hbathini, hch, j.neuschaefer, jk,
joel, jrdr.linux, keescook, leitao, linux-kernel, linux-kernel,
linux, linuxppc-dev, linuxram, mahesh, malat, maurosr, mikey,
mukesh02, muriloo, npiggin, olof, oss, paulus, rashmica.g,
rdunlap, rosattig, ruscur, sbobroff, shilpa.bhat, sparth1292,
stern, stewart, stewart, vaibhav, viresh.kumar, wei.guo.simon,
zhongjiang, willy
[-- Attachment #1: Type: text/plain, Size: 45252 bytes --]
Hi Linus,
Please pull powerpc updates for 4.19.
There's a trivial conflict in Documentation/admin-guide/kernel-parameters.txt
between our addition of nospectre_v1 and the x86 documentation for nosmt.
There's another in arch/m68k/mac/misc.c, which was coordinated with
Geert but unfortunately we still caused a conflict. The resolution is to
take the time64_t change and the CONFIG_ADB_PMU change.
The change to include/uapi/linux/pmu.h is safe and not perf related as
one would assume, the pmu there means Power Management Unit.
Finally there's the change to struct page. That was sent to linux-mm but
we couldn't tease an Ack out of anyone. Willy mentioned he wants to make
pt_mm generic in future, at which point we will happily shuffle our
field elsewhere.
cheers
The following changes since commit 021c91791a5e7e85c567452f1be3e4c2c6cb6063:
Linux 4.18-rc3 (2018-07-01 16:04:53 -0700)
are available in the git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-4.19-1
for you to fetch changes up to a2dc009afa9ae8b92305be7728676562a104cb40:
powerpc/mm/book3s/radix: Add mapping statistics (2018-08-13 16:35:05 +1000)
--------------------------------------------------------------------
powerpc updates for 4.19
Notable changes:
- A fix for a bug in our page table fragment allocator, where a page table page
could be freed and reallocated for something else while still in use, leading
to memory corruption etc. The fix reuses pt_mm in struct page (x86 only) for
a powerpc only refcount.
- Fixes to our pkey support. Several are user-visible changes, but bring us in
to line with x86 behaviour and/or fix outright bugs. Thanks to Florian Weimer
for reporting many of these.
- A series to improve the hvc driver & related OPAL console code, which have
been seen to cause hardlockups at times. The hvc driver changes in particular
have been in linux-next for ~month.
- Increase our MAX_PHYSMEM_BITS to 128TB when SPARSEMEM_VMEMMAP=y.
- Remove Power8 DD1 and Power9 DD1 support, neither chip should be in use
anywhere other than as a paper weight.
- An optimised memcmp implementation using Power7-or-later VMX instructions
- Support for barrier_nospec on some NXP CPUs.
- Support for flushing the count cache on context switch on some IBM CPUs
(controlled by firmware), as a Spectre v2 mitigation.
- A series to enhance the information we print on unhandled signals to bring it
into line with other arches, including showing the offending VMA and dumping
the instructions around the fault.
Thanks to:
Aaro Koskinen, Akshay Adiga, Alastair D'Silva, Alexey Kardashevskiy, Alexey
Spirkov, Alistair Popple, Andrew Donnellan, Aneesh Kumar K.V, Anju T Sudhakar,
Arnd Bergmann, Bartosz Golaszewski, Benjamin Herrenschmidt, Bharat Bhushan,
Bjoern Noetel, Boqun Feng, Breno Leitao, Bryant G. Ly, Camelia Groza,
Christophe Leroy, Christoph Hellwig, Cyril Bur, Dan Carpenter, Daniel Klamt,
Darren Stevens, Dave Young, David Gibson, Diana Craciun, Finn Thain, Florian
Weimer, Frederic Barrat, Gautham R. Shenoy, Geert Uytterhoeven, Geoff Levand,
Guenter Roeck, Gustavo Romero, Haren Myneni, Hari Bathini, Joel Stanley,
Jonathan Neuschäfer, Kees Cook, Madhavan Srinivasan, Mahesh Salgaonkar, Markus
Elfring, Mathieu Malaterre, Mauro S. M. Rodrigues, Michael Hanselmann, Michael
Neuling, Michael Schmitz, Mukesh Ojha, Murilo Opsfelder Araujo, Nicholas
Piggin, Parth Y Shah, Paul Mackerras, Paul Menzel, Ram Pai, Randy Dunlap,
Rashmica Gupta, Reza Arbab, Rodrigo R. Galvao, Russell Currey, Sam Bobroff,
Scott Wood, Shilpasri G Bhat, Simon Guo, Souptick Joarder, Stan Johnson,
Thiago Jung Bauermann, Tyrel Datwyler, Vaibhav Jain, Vasant Hegde, Venkat Rao
B, zhong jiang.
--------------------------------------------------------------------
Aaro Koskinen (1):
powerpc: Enable kernel XZ compression option on BOOK3S_32
Akshay Adiga (2):
powernv/cpuidle: Parse dt idle properties into global structure
powernv/cpuidle: Use parsed device tree values for cpuidle_init
Alastair D'Silva (7):
Revert "cxl: Add kernel API to allow a context to operate with relocate disabled"
Revert "cxl: Add support for interrupts on the Mellanox CX4"
Revert "cxl: Add preliminary workaround for CX4 interrupt limitation"
Revert "cxl: Add kernel APIs to get & set the max irqs per context"
Revert "cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards"
Revert "cxl: Add support for using the kernel API with a real PHB"
Revert "powerpc/powernv: Add support for the cxl kernel api on the real phb"
Alexey Kardashevskiy (8):
powerpc/powernv/ioda2: Reduce upper limit for DMA window size
powerpc/powernv/ioda2: Add 256M IOMMU page size to the default POWER8 case
powerpc/powernv: Remove useless wrapper
powerpc/powernv: Move TCE manupulation code to its own file
KVM: PPC: Make iommu_table::it_userspace big endian
powerpc/powernv: Add indirect levels to it_userspace
powerpc/powernv: Rework TCE level allocation
powerpc/powernv/ioda: Allocate indirect TCE levels on demand
Alexey Spirkov (1):
powerpc/44x: Mark mmu_init_secondary() as __init
Alistair Popple (1):
powerpc/powernv/npu: Add a debugfs setting to change ATSD threshold
Aneesh Kumar K.V (11):
powerpc/mm: Check memblock_add against MAX_PHYSMEM_BITS range
powerpc/mm: Increase MAX_PHYSMEM_BITS to 128TB with SPARSEMEM_VMEMMAP config
powerpc/mm/hash: Remove the superfluous bitwise operation when find hpte group
powerpc/mm/hash: Add hpte_get_old_v and use that instead of opencoding
powerpc/mm/hash: Reduce contention on hpte lock
powerpc/pseries: Use pr_xxx() in lpar.c
powerpc/pseries/mm: Improve error reporting on HCALL failures
powerpc/mm/tlbflush: update the mmu_gather page size while iterating address range
powerpc/powernv/idle: Fix build error
powerpc/mm/hash: Remove unnecessary do { } while(0) loop
powerpc/mm/book3s/radix: Add mapping statistics
Anju T Sudhakar (1):
powerpc/perf: Remove sched_task function defined for thread-imc
Arnd Bergmann (1):
powerpc: xmon: use ktime_get_coarse_boottime64
Bartosz Golaszewski (3):
powerpc/dts: Use 'atmel' as at24 manufacturer for pdm360ng
powerpc/dts: Use 'atmel' as at24 manufacturer for kmcent2
powerpc/dts: Use a correct at24 compatible fallback in ac14xx
Benjamin Herrenschmidt (3):
powerpc/xive: Remove now useless pr_debug statements
powerpc/xive: Remove xive_kexec_teardown_cpu()
powerpc/powernv/opal: Use standard interrupts property when available
Bharat Bhushan (1):
powerpc/mpic: Pass first free vector number to mpic_setup_error_int()
Boqun Feng (1):
powerpc/xmon: Add address lookup for percpu symbols
Breno Leitao (5):
scripts: Add ppc64le support for checkstack.pl
powerpc/pci: Remove legacy debug code
selftests/powerpc: Fix strncpy usage
selftests/powerpc: Fix typos
selftests/powerpc: Kill child processes on SIGINT
Camelia Groza (3):
powerpc/configs/dpaa: enable the Cortina PHY driver
powerpc/dts/fsl: t4240rdb: use the Cortina PHY driver compatible
powerpc/dts/fsl: t2080rdb: use the Cortina PHY driver compatible
Christoph Hellwig (1):
powerpc: Do not redefine NEED_DMA_MAP_STATE
Christophe Leroy (26):
powerpc/8xx: fix handling of early NULL pointer dereference
powerpc: remove kdump.h from page.h
powerpc: remove unneeded inclusions of cpu_has_feature.h
powerpc/405: move PPC405_ERR77 in asm-405.h
powerpc: move ASM_CONST and stringify_in_c() into asm-const.h
powerpc: clean the inclusion of stringify.h
powerpc: clean inclusions of asm/feature-fixups.h
powerpc: remove superflous inclusions of asm/fixmap.h
powerpc: declare set_breakpoint() static
powerpc/book3s: Remove PPC_PIN_SIZE
powerpc: fix includes in asm/processor.h
powerpc/nohash: fix hash related comments in pgtable.h
powerpc/44x: remove page.h from mmu-44x.h
powerpc: remove unnecessary inclusion of asm/tlbflush.h
powerpc: split asm/tlbflush.h
selftests/powerpc: Add test for 32 bits memcmp
selftests/powerpc: Add test for strlen()
powerpc/lib: Implement strlen() in assembly for PPC32
selftests/powerpc: Update strlen() test to test the new assembly function for PPC32
powerpc: Make CPU selection logic generic in Makefile
powerpc: Allow CPU selection also on PPC32
powerpc: Allow CPU selection of e300core variants
powerpc/cpm1: fix compilation error with CONFIG_PPC_EARLY_DEBUG_CPM
powerpc/cpm1: fix compilation error with CONFIG_PPC_EARLY_DEBUG_CPM
powerpc/lib: Use patch_site to patch copy_32 functions once cache is enabled
powerpc/mm: remove huge_pte_offset_and_shift() prototype
Cyril Bur (2):
powerpc/tm: Update function prototype comment
powerpc/tm: Remove struct thread_info param from tm_reclaim_thread()
Dan Carpenter (1):
powerpc: Fix size calculation using resource_size()
Daniel Klamt (1):
powerpc/xive: Replace msleep(x) with msleep(OPAL_BUSY_DELAY_MS)
Darren Stevens (2):
powerpc/pasemi: Search for PCI root bus by compatible property
powerpc/pasemi: Use pr_err/pr_warn... for kernel messages
David Gibson (1):
powerpc/hugetlbpage: Rmove unhelpful HUGEPD_*_SHIFT macros
Diana Craciun (6):
powerpc/64: Disable the speculation barrier from the command line
powerpc/64: Make stf barrier PPC_BOOK3S_64 specific.
powerpc/64: Make meltdown reporting Book3S 64 specific
powerpc/fsl: Add barrier_nospec implementation for NXP PowerPC Book3E
powerpc/fsl: Sanitize the syscall table for NXP PowerPC 32 bit platforms
Documentation: Add nospectre_v1 parameter
Finn Thain (11):
macintosh/via-pmu: Fix section mismatch warning
macintosh/via-pmu: Add missing mmio accessors
macintosh/via-pmu: Don't clear shift register interrupt flag twice
macintosh/via-pmu: Enhance state machine with new 'uninitialized' state
macintosh/via-pmu: Replace via pointer with via1 and via2 pointers
macintosh/via-pmu: Add support for m68k PowerBooks
macintosh/via-pmu: Explicitly specify CONFIG_PPC_PMAC dependencies
macintosh/via-pmu68k: Don't load driver on unsupported hardware
macintosh/via-pmu: Replace via-pmu68k driver with via-pmu driver
macintosh/via-pmu: Clean up interrupt statistics
macintosh/via-pmu: Disambiguate interrupt statistics
Frederic Barrat (4):
Revert "cxl: Add cxl_slot_is_supported API"
Revert "cxl: Allow a default context to be associated with an external pci_dev"
cxl: Remove abandonned capi support for the Mellanox CX4, final cleanup
ocxl: Fix page fault handler in case of fault on dying process
Geoff Levand (1):
powerpc/ps3: Set driver coherent_dma_mask
Guenter Roeck (1):
powerpc/4xx: Fix error return path in ppc4xx_msi_probe()
Haren Myneni (2):
powerpc/powernv: Export opal_check_token symbol
crypto/nx: Initialize 842 high and normal RxFIFO control registers
Hari Bathini (3):
powerpc/kdump: Handle crashkernel memory reservation failure
powerpc/fadump: handle crash memory ranges array index overflow
powerpc/fadump: merge adjacent memory ranges to reduce PT_LOAD segements
Joel Stanley (1):
powerpc: Remove Power8 DD1 from cputable
Jonathan Neuschäfer (1):
powerpc: wii: Remove outdated comment about memory fixups
Kees Cook (2):
powerpc/mpc5200: Remove VLA usage
powerpc/msi: Remove VLA usage
Mahesh Salgaonkar (3):
powerpc/pseries: Avoid using the size greater than RTAS_ERROR_LOG_MAX.
powerpc/pseries: Defer the logging of rtas error to irq work queue.
powerpc/pseries: Fix endianness while restoring of r3 in MCE handler.
Markus Elfring (1):
powerpc/kexec: Use common error handling code in setup_new_fdt()
Mathieu Malaterre (7):
powerpc/powermac: Add missing include of header pmac.h
cxl: remove a dead branch
powerpc/powermac: Remove variable x that's never read
powerpc/powermac: Make some functions static
powerpc: Move `path` variable inside DEBUG_PROM
powerpc/32: Include setup.h header file to fix warnings
powerpc/mm: remove warning about ‘type’ being set
Mauro S. M. Rodrigues (1):
powerpc/eeh: Avoid misleading message "EEH: no capable adapters found"
Michael Ellerman (45):
powerpc/64s: Report SLB multi-hit rather than parity error
Merge branch 'topic/ppc-kvm' into next
selftests/powerpc: Remove Power9 copy_unaligned test
selftests/powerpc: Remove Power9 paste tests
selftests/powerpc: Consolidate copy/paste test logic
powerpc64s: Show ori31 availability in spectre_v1 sysfs file not v2
powerpc: Add ppc32_allmodconfig defconfig target
powerpc: Add ppc64le and ppc64_book3e allmodconfig targets
powerpc/mm: Don't report PUDs as memory leaks when using kmemleak
powerpc/64: Disable irq restore warning for now
powerpc: Add a checkpatch wrapper with our preferred settings
selftests/powerpc: Add a helper for checking if we're on ppc64le
selftests/powerpc: Only run some tests on ppc64le
selftests/powerpc: Give some tests longer to run
powerpc/64s: Move SET_SCRATCH0() into EXCEPTION_PROLOG_PSERIES()
powerpc/64s: Move SET_SCRATCH0() into EXCEPTION_RELON_PROLOG_PSERIES()
powerpc/64s: Rename STD_EXCEPTION_PSERIES to STD_EXCEPTION
powerpc/64s: Rename STD_EXCEPTION_PSERIES_OOL to STD_EXCEPTION_OOL
powerpc/64s: Rename STD_RELON_EXCEPTION_PSERIES to STD_RELON_EXCEPTION
powerpc/64s: Rename STD_RELON_EXCEPTION_PSERIES_OOL to STD_RELON_EXCEPTION_OOL
powerpc/64s: Rename EXCEPTION_PROLOG_PSERIES_1 to EXCEPTION_PROLOG_2
powerpc/64s: Remove PSERIES from the NORI macros
powerpc/64s: Rename EXCEPTION_RELON_PROLOG_PSERIES_1
powerpc/64s: Rename EXCEPTION_RELON_PROLOG_PSERIES
powerpc/64s: Rename EXCEPTION_PROLOG_PSERIES to EXCEPTION_PROLOG
powerpc/64s: Drop _MASKABLE_EXCEPTION_PSERIES()
powerpc/64s: Drop _MASKABLE_RELON_EXCEPTION_PSERIES()
powerpc/64s: Remove PSERIES naming from the MASKABLE macros
powerpc/64s: Drop unused loc parameter to MASKABLE_EXCEPTION macros
powerpc/64s: Don't use __MASKABLE_EXCEPTION unnecessarily
powerpc/64: Add CONFIG_PPC_BARRIER_NOSPEC
powerpc/64: Call setup_barrier_nospec() from setup_arch()
powerpc/asm: Add a patch_site macro & helpers for patching instructions
powerpc/64s: Add new security feature flags for count cache flush
powerpc/64s: Add support for software count cache flush
powerpc/pseries: Query hypervisor for count cache flush settings
powerpc/powernv: Query firmware for count cache flush settings
powerpc/64s: Make rfi_flush_fallback a little more robust
selftests/powerpc: Skip earlier in alignment_handler test
selftests/powerpc: Add more version checks to alignment_handler test
selftests/powerpc/64: Test exception cases in copy_tofrom_user
powerpc/uaccess: Enable get_user(u64, *p) on 32-bit
Merge branch 'fixes' into next
Merge branch 'topic/hvc' into next
Merge branch 'next' of https://git.kernel.org/.../scottwood/linux into next
Michael Hanselmann (1):
MAINTAINERS: Remove the entry for the orphaned ams driver
Michael Neuling (3):
powerpc: Document issues with the DAWR on POWER9
powerpc: Document issues with TM on POWER9
powerpc/powernv/memtrace: Remove memtrace mmap()
Mukesh Ojha (2):
powerpc/powernv/opal-dump : Handles opal_dump_info properly
powerpc/powernv/opal-dump : Use IRQ_HANDLED instead of numbers in interrupt handler
Murilo Opsfelder Araujo (7):
powerpc/prom_init: Remove linux,stdout-package property
powerpc/traps: Print unhandled signals in a separate function
powerpc/traps: Use an explicit ratelimit state for show_signal_msg()
powerpc/traps: Use %lx format in show_signal_msg()
powerpc/traps: Print VMA for unhandled signals
powerpc: Add show_user_instructions()
powerpc/traps: Show instructions on exceptions
Nicholas Piggin (22):
powerpc/64s: Remove POWER9 DD1 support
tty: hvc: use mutex instead of spinlock for hvc_structs lock
tty: hvc: hvc_poll() break hv read loop
tty: hvc: hvc_poll() may sleep
tty: hvc: hvc_write() may sleep
tty: hvc: introduce the hv_ops.flush operation for hvc drivers
powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE] closely
powerpc: NMI IPI make NMI IPIs fully sychronous
powerpc/powernv: opal_put_chars partial write fix
powerpc/powernv: Fix OPAL console driver OPAL_BUSY loops
powerpc/powernv: opal-kmsg standardise OPAL_BUSY handling
powerpc/powernv: opal-kmsg use flush fallback from console code
powerpc/powernv: Implement and use opal_flush_console
powerpc/powernv: Remove OPALv1 support from opal console driver
powerpc/powernv: move opal console flushing to udbg
powerpc/powernv: implement opal_put_chars_atomic
tty: hvc: remove unexplained "just in case" spin delay
powernv/cpuidle: Fix idle states all being marked invalid
powerpc/64s/radix: tlb do not flush on page size when fullmm
powerpc/64s: free page table caches at exit_mmap time
powerpc/64s: Fix page table fragment refcount race vs speculative references
powerpc/64s: move machine check SLB flushing to mm/slb.c
Parth Y Shah (1):
misc: cxl: changed asterisk position
Paul Mackerras (3):
powerpc/64: Make exception table clearer in __copy_tofrom_user_base
selftests/powerpc/64: Test all paths through copy routines
powerpc/64: Copy as much as possible in __copy_tofrom_user
Ram Pai (9):
powerpc/pkeys: Give all threads control of their key permissions
powerpc/pkeys: Deny read/write/execute by default
powerpc/pkeys: key allocation/deallocation must not change pkey registers
powerpc/pkeys: Save the pkey registers before fork
powerpc/pkeys: Fix calculation of total pkeys.
powerpc/pkeys: Preallocate execute-only key
powerpc/pkeys: make protection key 0 less special
selftests/powerpc: Fix core-pkey for default execute permission change
selftests/powerpc: Fix ptrace-pkey for default execute permission change
Randy Dunlap (2):
chrp/nvram.c: add MODULE_LICENSE()
powerpc/platforms/85xx: fix t1042rdb_diu.c build errors & warning
Rashmica Gupta (2):
powerpc/powernv: Allow memory that has been hot-removed to be hot-added
Documentation: Update documentation on ppc-memtrace
Reza Arbab (1):
powerpc/powernv: Fix concurrency issue with npu->mmio_atsd_usage
Rodrigo R. Galvao (1):
powerpc/Makefiles: Convert ifeq to ifdef where possible
Sam Bobroff (1):
powerpc/pseries: fix EEH recovery of some IOV devices
Shilpasri G Bhat (3):
cpufreq: powernv: Remove global pstate ramp-down timer in POWER9
powerpc/powernv: Add support to enable sensor groups
hwmon: (ibmpowernv) Add attributes to enable/disable sensor groups
Simon Guo (5):
powerpc/64: Align bytes before fall back to .Lshort in powerpc64 memcmp()
powerpc: add vcmpequd/vcmpequb ppc instruction macro
powerpc/64: enhance memcmp() with VMX instruction for long bytes comparision
powerpc/64: add 32 bytes prechecking before using VMX optimization on memcmp()
selftests/powerpc: Update memcmp_64 selftest for VMX implementation
Souptick Joarder (1):
ocxl: Change return type for fault handler
Vaibhav Jain (1):
cxl: Fix wrong comparison in cxl_adapter_context_get()
zhong jiang (1):
powerpc/powermac: of_node_put() is not needed after iterator
Documentation/ABI/testing/ppc-memtrace | 9 +-
Documentation/admin-guide/kernel-parameters.txt | 4 +
Documentation/hwmon/ibmpowernv | 43 +-
Documentation/powerpc/DAWR-POWER9.txt | 58 ++
Documentation/powerpc/transactional_memory.txt | 44 ++
MAINTAINERS | 5 -
arch/m68k/configs/mac_defconfig | 2 +-
arch/m68k/configs/multi_defconfig | 2 +-
arch/m68k/mac/config.c | 2 +-
arch/m68k/mac/misc.c | 54 +-
arch/powerpc/Kconfig | 12 +-
arch/powerpc/Makefile | 49 +-
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/dts/ac14xx.dts | 20 +-
arch/powerpc/boot/dts/fsl/kmcent2.dts | 2 +-
arch/powerpc/boot/dts/fsl/t2080rdb.dts | 4 +-
arch/powerpc/boot/dts/fsl/t4240rdb.dts | 8 +-
arch/powerpc/boot/dts/pdm360ng.dts | 2 +-
arch/powerpc/configs/book3s_32.config | 2 +
arch/powerpc/configs/dpaa.config | 1 +
arch/powerpc/crypto/md5-asm.S | 1 +
arch/powerpc/crypto/sha1-powerpc-asm.S | 1 +
arch/powerpc/include/asm/asm-405.h | 19 +
arch/powerpc/include/asm/asm-compat.h | 26 +-
arch/powerpc/include/asm/asm-const.h | 14 +
arch/powerpc/include/asm/asm-prototypes.h | 11 +-
arch/powerpc/include/asm/atomic.h | 1 +
arch/powerpc/include/asm/barrier.h | 14 +-
arch/powerpc/include/asm/bitops.h | 1 +
arch/powerpc/include/asm/book3s/32/pgtable.h | 7 -
arch/powerpc/include/asm/book3s/32/tlbflush.h | 25 +
arch/powerpc/include/asm/book3s/64/hash-64k.h | 5 +-
arch/powerpc/include/asm/book3s/64/hash.h | 2 +
arch/powerpc/include/asm/book3s/64/hugetlb.h | 20 -
arch/powerpc/include/asm/book3s/64/mmu-hash.h | 15 +-
arch/powerpc/include/asm/book3s/64/pgalloc.h | 30 +-
arch/powerpc/include/asm/book3s/64/pgtable.h | 5 +-
arch/powerpc/include/asm/book3s/64/radix.h | 40 +-
.../powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 -
arch/powerpc/include/asm/book3s/tlbflush.h | 11 +
arch/powerpc/include/asm/cacheflush.h | 1 -
arch/powerpc/include/asm/cmpxchg.h | 2 +-
arch/powerpc/include/asm/code-patching-asm.h | 18 +
arch/powerpc/include/asm/code-patching.h | 3 +
arch/powerpc/include/asm/cpuidle.h | 13 +
arch/powerpc/include/asm/cputable.h | 29 +-
arch/powerpc/include/asm/cputime.h | 1 -
arch/powerpc/include/asm/dbell.h | 2 +-
arch/powerpc/include/asm/dcr-native.h | 1 +
arch/powerpc/include/asm/debug.h | 1 -
arch/powerpc/include/asm/dt_cpu_ftrs.h | 2 -
arch/powerpc/include/asm/eeh.h | 15 +-
arch/powerpc/include/asm/exception-64s.h | 118 ++-
arch/powerpc/include/asm/fadump.h | 3 -
arch/powerpc/include/asm/feature-fixups.h | 2 +
arch/powerpc/include/asm/firmware.h | 3 +-
arch/powerpc/include/asm/fixmap.h | 1 -
arch/powerpc/include/asm/futex.h | 2 +-
arch/powerpc/include/asm/head-64.h | 16 +-
arch/powerpc/include/asm/highmem.h | 2 +-
arch/powerpc/include/asm/hugetlb.h | 3 -
arch/powerpc/include/asm/hvcall.h | 2 +
arch/powerpc/include/asm/hw_breakpoint.h | 1 +
arch/powerpc/include/asm/hw_irq.h | 10 +-
arch/powerpc/include/asm/iommu.h | 12 +-
arch/powerpc/include/asm/jump_label.h | 2 +-
arch/powerpc/include/asm/kvm_booke_hv_asm.h | 2 +
arch/powerpc/include/asm/mmu-44x.h | 10 +-
arch/powerpc/include/asm/mmu.h | 3 +-
arch/powerpc/include/asm/nohash/32/pgtable.h | 7 +-
arch/powerpc/include/asm/nohash/64/pgtable.h | 19 +-
arch/powerpc/include/asm/nohash/tlbflush.h | 53 ++
arch/powerpc/include/asm/opal-api.h | 4 +-
arch/powerpc/include/asm/opal.h | 5 +
arch/powerpc/include/asm/paca.h | 8 +-
arch/powerpc/include/asm/page.h | 3 +-
arch/powerpc/include/asm/page_64.h | 2 +
arch/powerpc/include/asm/pkeys.h | 38 +-
arch/powerpc/include/asm/pnv-pci.h | 7 -
arch/powerpc/include/asm/ppc-opcode.h | 14 +-
arch/powerpc/include/asm/ppc_asm.h | 1 +
arch/powerpc/include/asm/processor.h | 5 +-
arch/powerpc/include/asm/ptrace.h | 1 +
arch/powerpc/include/asm/reg.h | 2 +
arch/powerpc/include/asm/reg_a2.h | 2 +
arch/powerpc/include/asm/reg_fsl_emb.h | 2 +
arch/powerpc/include/asm/security_features.h | 7 +
arch/powerpc/include/asm/setup.h | 6 +-
arch/powerpc/include/asm/smp.h | 1 -
arch/powerpc/include/asm/sparsemem.h | 13 +-
arch/powerpc/include/asm/spinlock.h | 2 +-
arch/powerpc/include/asm/stacktrace.h | 13 +
arch/powerpc/include/asm/string.h | 2 +
arch/powerpc/include/asm/synch.h | 2 +-
arch/powerpc/include/asm/thread_info.h | 3 +-
arch/powerpc/include/asm/tlb.h | 4 +-
arch/powerpc/include/asm/tlbflush.h | 86 +--
arch/powerpc/include/asm/uaccess.h | 14 +-
arch/powerpc/include/asm/xive.h | 1 -
arch/powerpc/kernel/Makefile | 17 +-
arch/powerpc/kernel/asm-offsets.c | 1 -
arch/powerpc/kernel/cpu_setup_6xx.S | 1 +
arch/powerpc/kernel/cputable.c | 38 -
arch/powerpc/kernel/crash.c | 1 -
arch/powerpc/kernel/dt_cpu_ftrs.c | 4 +-
arch/powerpc/kernel/eeh.c | 2 +-
arch/powerpc/kernel/entry_32.S | 12 +
arch/powerpc/kernel/entry_64.S | 64 ++
arch/powerpc/kernel/exceptions-64e.S | 5 +
arch/powerpc/kernel/exceptions-64s.S | 48 +-
arch/powerpc/kernel/fadump.c | 126 ++-
arch/powerpc/kernel/fpu.S | 2 +
arch/powerpc/kernel/head_32.S | 1 +
arch/powerpc/kernel/head_40x.S | 1 +
arch/powerpc/kernel/head_64.S | 1 +
arch/powerpc/kernel/head_8xx.S | 8 +-
arch/powerpc/kernel/head_fsl_booke.S | 1 +
arch/powerpc/kernel/idle_6xx.S | 1 +
arch/powerpc/kernel/idle_book3e.S | 7 +-
arch/powerpc/kernel/idle_book3s.S | 52 +-
arch/powerpc/kernel/idle_e500.S | 1 +
arch/powerpc/kernel/idle_power4.S | 1 +
arch/powerpc/kernel/irq.c | 41 +-
arch/powerpc/kernel/kvm_emul.S | 1 +
arch/powerpc/kernel/l2cr_6xx.S | 1 +
arch/powerpc/kernel/machine_kexec.c | 8 +-
arch/powerpc/kernel/machine_kexec_file_64.c | 28 +-
arch/powerpc/kernel/mce_power.c | 44 +-
arch/powerpc/kernel/misc_32.S | 1 +
arch/powerpc/kernel/misc_64.S | 1 +
arch/powerpc/kernel/module.c | 4 +-
arch/powerpc/kernel/pci-common.c | 3 -
arch/powerpc/kernel/ppc_save_regs.S | 1 +
arch/powerpc/kernel/process.c | 64 +-
arch/powerpc/kernel/prom.c | 33 +-
arch/powerpc/kernel/prom_init.c | 12 +-
arch/powerpc/kernel/security.c | 141 +++-
arch/powerpc/kernel/setup-common.c | 2 +
arch/powerpc/kernel/setup_32.c | 11 +-
arch/powerpc/kernel/setup_64.c | 1 +
arch/powerpc/kernel/smp.c | 50 +-
arch/powerpc/kernel/swsusp_32.S | 1 +
arch/powerpc/kernel/swsusp_asm64.S | 1 +
arch/powerpc/kernel/tm.S | 5 +-
arch/powerpc/kernel/traps.c | 52 +-
arch/powerpc/kernel/vdso.c | 1 -
arch/powerpc/kernel/vector.S | 1 +
arch/powerpc/kernel/vmlinux.lds.S | 4 +-
arch/powerpc/kernel/watchdog.c | 1 -
arch/powerpc/kvm/book3s.c | 1 -
arch/powerpc/kvm/book3s_32_mmu.c | 1 -
arch/powerpc/kvm/book3s_64_mmu.c | 1 -
arch/powerpc/kvm/book3s_64_mmu_hv.c | 1 -
arch/powerpc/kvm/book3s_64_mmu_radix.c | 15 +-
arch/powerpc/kvm/book3s_64_slb.S | 3 +
arch/powerpc/kvm/book3s_64_vio.c | 12 +-
arch/powerpc/kvm/book3s_64_vio_hv.c | 20 +-
arch/powerpc/kvm/book3s_hv.c | 11 -
arch/powerpc/kvm/book3s_hv_interrupts.S | 2 +
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 1 -
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 18 +-
arch/powerpc/kvm/book3s_interrupts.S | 1 +
arch/powerpc/kvm/book3s_pr.c | 1 -
arch/powerpc/kvm/book3s_rmhandlers.S | 1 +
arch/powerpc/kvm/book3s_segment.S | 3 +
arch/powerpc/kvm/book3s_xive_template.c | 39 +-
arch/powerpc/kvm/e500.c | 1 -
arch/powerpc/kvm/e500mc.c | 1 -
arch/powerpc/kvm/powerpc.c | 1 -
arch/powerpc/lib/Makefile | 2 +-
arch/powerpc/lib/code-patching.c | 16 +
arch/powerpc/lib/copy_32.S | 9 +-
arch/powerpc/lib/copypage_64.S | 1 +
arch/powerpc/lib/copypage_power7.S | 4 +-
arch/powerpc/lib/copyuser_64.S | 587 +++++++-------
arch/powerpc/lib/copyuser_power7.S | 21 +-
arch/powerpc/lib/feature-fixups-test.S | 1 +
arch/powerpc/lib/feature-fixups.c | 35 +-
arch/powerpc/lib/hweight_64.S | 1 +
arch/powerpc/lib/ldstfp.S | 1 +
arch/powerpc/lib/locks.c | 1 -
arch/powerpc/lib/memcmp_64.S | 414 +++++++++-
arch/powerpc/lib/memcpy_64.S | 11 +-
arch/powerpc/lib/memcpy_power7.S | 28 +-
arch/powerpc/lib/strlen_32.S | 78 ++
arch/powerpc/lib/vmx-helper.c | 4 +-
arch/powerpc/mm/44x_mmu.c | 2 +-
arch/powerpc/mm/Makefile | 4 +-
arch/powerpc/mm/dump_hashpagetable.c | 3 +-
arch/powerpc/mm/fault.c | 1 -
arch/powerpc/mm/hash64_4k.c | 8 +-
arch/powerpc/mm/hash64_64k.c | 15 +-
arch/powerpc/mm/hash_low_32.S | 1 +
arch/powerpc/mm/hash_native_64.c | 78 +-
arch/powerpc/mm/hash_utils_64.c | 41 +-
arch/powerpc/mm/highmem.c | 2 +-
arch/powerpc/mm/hugepage-hash64.c | 9 +-
arch/powerpc/mm/hugetlbpage.c | 26 +-
arch/powerpc/mm/mmu_context_book3s64.c | 25 +-
arch/powerpc/mm/mmu_context_hash32.c | 1 -
arch/powerpc/mm/mmu_decl.h | 1 -
arch/powerpc/mm/pgtable-book3s64.c | 39 +-
arch/powerpc/mm/pgtable-radix.c | 79 +-
arch/powerpc/mm/pkeys.c | 141 ++--
arch/powerpc/mm/slb.c | 39 +
arch/powerpc/mm/slb_low.S | 1 +
arch/powerpc/mm/subpage-prot.c | 1 -
arch/powerpc/mm/tlb-radix.c | 18 -
arch/powerpc/mm/tlb_low_64e.S | 1 +
arch/powerpc/mm/tlb_nohash_low.S | 2 +
arch/powerpc/net/Makefile | 2 +-
arch/powerpc/net/bpf_jit32.h | 1 +
arch/powerpc/net/bpf_jit_asm.S | 1 +
arch/powerpc/net/bpf_jit_comp.c | 1 +
arch/powerpc/net/bpf_jit_comp64.c | 1 +
arch/powerpc/perf/core-book3s.c | 34 -
arch/powerpc/perf/imc-pmu.c | 108 ++-
arch/powerpc/perf/isa207-common.c | 12 +-
arch/powerpc/perf/isa207-common.h | 5 -
arch/powerpc/perf/power9-pmu.c | 54 +-
arch/powerpc/perf/req-gen/_begin.h | 2 +
arch/powerpc/perf/req-gen/perf.h | 1 +
arch/powerpc/platforms/4xx/msi.c | 51 +-
arch/powerpc/platforms/52xx/Makefile | 2 +-
arch/powerpc/platforms/52xx/mpc52xx_pm.c | 5 +-
arch/powerpc/platforms/85xx/t1042rdb_diu.c | 4 +
arch/powerpc/platforms/Kconfig.cputype | 39 +-
arch/powerpc/platforms/cell/Makefile | 2 +-
arch/powerpc/platforms/cell/cbe_thermal.c | 1 +
arch/powerpc/platforms/cell/spufs/sputrace.h | 1 +
arch/powerpc/platforms/chrp/nvram.c | 3 +
arch/powerpc/platforms/embedded6xx/wii.c | 10 -
arch/powerpc/platforms/pasemi/dma_lib.c | 6 +-
arch/powerpc/platforms/pasemi/gpio_mdio.c | 2 +-
arch/powerpc/platforms/pasemi/idle.c | 4 +-
arch/powerpc/platforms/pasemi/iommu.c | 2 +-
arch/powerpc/platforms/pasemi/misc.c | 4 +-
arch/powerpc/platforms/pasemi/pci.c | 16 +-
arch/powerpc/platforms/pasemi/setup.c | 53 +-
arch/powerpc/platforms/powermac/cache.S | 1 +
arch/powerpc/platforms/powermac/feature.c | 2 -
arch/powerpc/platforms/powermac/pci.c | 12 +-
arch/powerpc/platforms/powermac/sleep.S | 1 +
arch/powerpc/platforms/powermac/time.c | 4 +-
arch/powerpc/platforms/powermac/udbg_scc.c | 4 +-
arch/powerpc/platforms/powernv/Makefile | 2 +-
arch/powerpc/platforms/powernv/eeh-powernv.c | 12 +-
arch/powerpc/platforms/powernv/idle.c | 245 +++---
arch/powerpc/platforms/powernv/memtrace.c | 121 ++-
arch/powerpc/platforms/powernv/npu-dma.c | 17 +-
arch/powerpc/platforms/powernv/opal-dump.c | 18 +-
arch/powerpc/platforms/powernv/opal-irqchip.c | 126 +--
arch/powerpc/platforms/powernv/opal-kmsg.c | 30 +-
.../powerpc/platforms/powernv/opal-sensor-groups.c | 28 +
arch/powerpc/platforms/powernv/opal-wrappers.S | 4 +
arch/powerpc/platforms/powernv/opal.c | 154 ++--
arch/powerpc/platforms/powernv/pci-cxl.c | 199 -----
arch/powerpc/platforms/powernv/pci-ioda-tce.c | 399 ++++++++++
arch/powerpc/platforms/powernv/pci-ioda.c | 208 +----
arch/powerpc/platforms/powernv/pci.c | 158 ----
arch/powerpc/platforms/powernv/pci.h | 53 +-
arch/powerpc/platforms/powernv/setup.c | 10 +-
arch/powerpc/platforms/powernv/smp.c | 27 +-
arch/powerpc/platforms/powernv/vas.h | 1 +
arch/powerpc/platforms/pseries/Makefile | 2 +-
arch/powerpc/platforms/pseries/hvCall.S | 1 +
arch/powerpc/platforms/pseries/kexec.c | 2 +-
arch/powerpc/platforms/pseries/lpar.c | 51 +-
arch/powerpc/platforms/pseries/mobility.c | 1 +
arch/powerpc/platforms/pseries/ras.c | 51 +-
arch/powerpc/platforms/pseries/setup.c | 50 +-
arch/powerpc/purgatory/trampoline.S | 10 +-
arch/powerpc/sysdev/Makefile | 2 +-
arch/powerpc/sysdev/cpm1.c | 1 -
arch/powerpc/sysdev/fsl_mpic_err.c | 2 +-
arch/powerpc/sysdev/mpic.c | 6 +-
arch/powerpc/sysdev/mpic_msgr.c | 2 +-
arch/powerpc/sysdev/msi_bitmap.c | 15 +-
arch/powerpc/sysdev/xive/common.c | 30 +-
arch/powerpc/sysdev/xive/native.c | 34 +-
arch/powerpc/tools/checkpatch.sh | 22 +
arch/powerpc/xmon/spr_access.S | 1 +
arch/powerpc/xmon/xmon.c | 38 +-
drivers/cpufreq/powernv-cpufreq.c | 20 +-
drivers/cpuidle/cpuidle-powernv.c | 158 +---
drivers/crypto/nx/nx-842-powernv.c | 31 +-
drivers/hwmon/ibmpowernv.c | 238 +++++-
drivers/macintosh/Kconfig | 19 +-
drivers/macintosh/Makefile | 1 -
drivers/macintosh/adb.c | 2 +-
drivers/macintosh/via-pmu.c | 346 +++++----
drivers/macintosh/via-pmu68k.c | 850 ---------------------
drivers/misc/cxl/Kconfig | 8 -
drivers/misc/cxl/Makefile | 2 +-
drivers/misc/cxl/api.c | 132 ----
drivers/misc/cxl/base.c | 83 --
drivers/misc/cxl/context.c | 3 +-
drivers/misc/cxl/cxl.h | 41 -
drivers/misc/cxl/cxllib.c | 4 -
drivers/misc/cxl/debugfs.c | 5 -
drivers/misc/cxl/fault.c | 2 +-
drivers/misc/cxl/guest.c | 8 -
drivers/misc/cxl/main.c | 7 +-
drivers/misc/cxl/native.c | 3 +-
drivers/misc/cxl/pci.c | 392 +---------
drivers/misc/cxl/phb.c | 44 --
drivers/misc/cxl/vphb.c | 46 +-
drivers/misc/ocxl/context.c | 22 +-
drivers/misc/ocxl/link.c | 24 +-
drivers/misc/ocxl/sysfs.c | 5 +-
drivers/tty/hvc/hvc_console.c | 194 +++--
drivers/tty/hvc/hvc_console.h | 1 +
drivers/tty/hvc/hvc_opal.c | 31 +-
drivers/usb/host/ehci-ps3.c | 6 +-
drivers/usb/host/ohci-ps3.c | 6 +-
drivers/vfio/vfio_iommu_spapr_tce.c | 65 +-
include/linux/mm_types.h | 5 +-
include/misc/cxl-base.h | 10 -
include/misc/cxl.h | 68 --
include/uapi/linux/pmu.h | 4 +-
scripts/checkstack.pl | 11 +-
sound/ppc/snd_ps3.c | 5 +
.../testing/selftests/powerpc/alignment/.gitignore | 4 -
tools/testing/selftests/powerpc/alignment/Makefile | 5 +-
.../powerpc/alignment/alignment_handler.c | 107 ++-
.../powerpc/alignment/copy_first_unaligned.c | 33 +-
.../alignment/copy_paste_unaligned_common.c | 53 --
.../alignment/copy_paste_unaligned_common.h | 26 -
.../selftests/powerpc/alignment/copy_unaligned.c | 41 -
.../powerpc/alignment/paste_last_unaligned.c | 43 --
.../selftests/powerpc/alignment/paste_unaligned.c | 43 --
.../selftests/powerpc/benchmarks/futex_bench.c | 1 +
.../selftests/powerpc/benchmarks/mmap_bench.c | 2 +
.../testing/selftests/powerpc/copyloops/.gitignore | 17 +-
tools/testing/selftests/powerpc/copyloops/Makefile | 45 +-
.../selftests/powerpc/copyloops/asm/asm-compat.h | 0
.../powerpc/copyloops/asm/feature-fixups.h | 0
.../selftests/powerpc/copyloops/asm/ppc_asm.h | 44 +-
.../powerpc/copyloops/copy_tofrom_user_reference.S | 24 +
.../selftests/powerpc/copyloops/exc_validate.c | 124 +++
tools/testing/selftests/powerpc/copyloops/stubs.S | 19 +
.../powerpc/dscr/dscr_inherit_exec_test.c | 8 +-
tools/testing/selftests/powerpc/harness.c | 18 +-
tools/testing/selftests/powerpc/include/utils.h | 2 +
.../powerpc/pmu/ebb/instruction_count_test.c | 1 +
.../powerpc/pmu/ebb/lost_exception_test.c | 1 +
.../selftests/powerpc/primitives/asm/asm-const.h | 1 +
.../powerpc/primitives/asm/feature-fixups.h | 1 +
tools/testing/selftests/powerpc/ptrace/core-pkey.c | 4 +
.../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 4 +
.../testing/selftests/powerpc/stringloops/Makefile | 29 +-
.../selftests/powerpc/stringloops/asm/cache.h | 1 +
.../selftests/powerpc/stringloops/asm/ppc-opcode.h | 39 +
.../selftests/powerpc/stringloops/asm/ppc_asm.h | 25 +
.../testing/selftests/powerpc/stringloops/memcmp.c | 99 ++-
.../selftests/powerpc/stringloops/memcmp_32.S | 1 +
.../testing/selftests/powerpc/stringloops/string.c | 21 +
.../testing/selftests/powerpc/stringloops/strlen.c | 127 +++
.../selftests/powerpc/stringloops/strlen_32.S | 1 +
tools/testing/selftests/powerpc/tm/tm-sigreturn.c | 1 +
tools/testing/selftests/powerpc/tm/tm-tar.c | 1 +
tools/testing/selftests/powerpc/tm/tm-vmxcopy.c | 1 +
tools/testing/selftests/powerpc/utils.c | 17 +
363 files changed, 5246 insertions(+), 5250 deletions(-)
create mode 100644 Documentation/powerpc/DAWR-POWER9.txt
create mode 100644 arch/powerpc/configs/book3s_32.config
create mode 100644 arch/powerpc/include/asm/asm-405.h
create mode 100644 arch/powerpc/include/asm/asm-const.h
create mode 100644 arch/powerpc/include/asm/book3s/32/tlbflush.h
create mode 100644 arch/powerpc/include/asm/book3s/tlbflush.h
create mode 100644 arch/powerpc/include/asm/code-patching-asm.h
create mode 100644 arch/powerpc/include/asm/nohash/tlbflush.h
create mode 100644 arch/powerpc/include/asm/stacktrace.h
create mode 100644 arch/powerpc/lib/strlen_32.S
create mode 100644 arch/powerpc/platforms/powernv/pci-ioda-tce.c
create mode 100755 arch/powerpc/tools/checkpatch.sh
delete mode 100644 drivers/macintosh/via-pmu68k.c
delete mode 100644 drivers/misc/cxl/phb.c
delete mode 100644 tools/testing/selftests/powerpc/alignment/copy_paste_unaligned_common.c
delete mode 100644 tools/testing/selftests/powerpc/alignment/copy_paste_unaligned_common.h
delete mode 100644 tools/testing/selftests/powerpc/alignment/copy_unaligned.c
delete mode 100644 tools/testing/selftests/powerpc/alignment/paste_last_unaligned.c
delete mode 100644 tools/testing/selftests/powerpc/alignment/paste_unaligned.c
create mode 100644 tools/testing/selftests/powerpc/copyloops/asm/asm-compat.h
create mode 100644 tools/testing/selftests/powerpc/copyloops/asm/feature-fixups.h
create mode 100644 tools/testing/selftests/powerpc/copyloops/copy_tofrom_user_reference.S
create mode 100644 tools/testing/selftests/powerpc/copyloops/exc_validate.c
create mode 100644 tools/testing/selftests/powerpc/copyloops/stubs.S
create mode 120000 tools/testing/selftests/powerpc/primitives/asm/asm-const.h
create mode 120000 tools/testing/selftests/powerpc/primitives/asm/feature-fixups.h
create mode 100644 tools/testing/selftests/powerpc/stringloops/asm/cache.h
create mode 100644 tools/testing/selftests/powerpc/stringloops/asm/ppc-opcode.h
create mode 120000 tools/testing/selftests/powerpc/stringloops/memcmp_32.S
create mode 100644 tools/testing/selftests/powerpc/stringloops/string.c
create mode 100644 tools/testing/selftests/powerpc/stringloops/strlen.c
create mode 120000 tools/testing/selftests/powerpc/stringloops/strlen_32.S
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply
* Re: [PATCH v2 3/4] powerpc/mm: fix a warning when a cache is common to PGD and hugepages
From: Aneesh Kumar K.V @ 2018-08-17 3:32 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <4aaca2d27429e6bdadc340fd3b96e7c350c4b2f4.1534258290.git.christophe.leroy@c-s.fr>
On 08/14/2018 08:24 PM, Christophe Leroy wrote:
> While implementing TLB miss HW assistance on the 8xx, the following
> warning was encountered:
>
> [ 423.732965] WARNING: CPU: 0 PID: 345 at mm/slub.c:2412 ___slab_alloc.constprop.30+0x26c/0x46c
> [ 423.733033] CPU: 0 PID: 345 Comm: mmap Not tainted 4.18.0-rc8-00664-g2dfff9121c55 #671
> [ 423.733075] NIP: c0108f90 LR: c0109ad0 CTR: 00000004
> [ 423.733121] REGS: c455bba0 TRAP: 0700 Not tainted (4.18.0-rc8-00664-g2dfff9121c55)
> [ 423.733147] MSR: 00021032 <ME,IR,DR,RI> CR: 24224848 XER: 20000000
> [ 423.733319]
> [ 423.733319] GPR00: c0109ad0 c455bc50 c4521910 c60053c0 007080c0 c0011b34 c7fa41e0 c455be30
> [ 423.733319] GPR08: 00000001 c00103a0 c7fa41e0 c49afcc4 24282842 10018840 c079b37c 00000040
> [ 423.733319] GPR16: 73f00000 00210d00 00000000 00000001 c455a000 00000100 00000200 c455a000
> [ 423.733319] GPR24: c60053c0 c0011b34 007080c0 c455a000 c455a000 c7fa41e0 00000000 00009032
> [ 423.734190] NIP [c0108f90] ___slab_alloc.constprop.30+0x26c/0x46c
> [ 423.734257] LR [c0109ad0] kmem_cache_alloc+0x210/0x23c
> [ 423.734283] Call Trace:
> [ 423.734326] [c455bc50] [00000100] 0x100 (unreliable)
> [ 423.734430] [c455bcc0] [c0109ad0] kmem_cache_alloc+0x210/0x23c
> [ 423.734543] [c455bcf0] [c0011b34] huge_pte_alloc+0xc0/0x1dc
> [ 423.734633] [c455bd20] [c01044dc] hugetlb_fault+0x408/0x48c
> [ 423.734720] [c455bdb0] [c0104b20] follow_hugetlb_page+0x14c/0x44c
> [ 423.734826] [c455be10] [c00e8e54] __get_user_pages+0x1c4/0x3dc
> [ 423.734919] [c455be80] [c00e9924] __mm_populate+0xac/0x140
> [ 423.735020] [c455bec0] [c00db14c] vm_mmap_pgoff+0xb4/0xb8
> [ 423.735127] [c455bf00] [c00f27c0] ksys_mmap_pgoff+0xcc/0x1fc
> [ 423.735222] [c455bf40] [c000e0f8] ret_from_syscall+0x0/0x38
> [ 423.735271] Instruction dump:
> [ 423.735321] 7cbf482e 38fd0008 7fa6eb78 7fc4f378 4bfff5dd 7fe3fb78 4bfffe24 81370010
> [ 423.735536] 71280004 41a2ff88 4840c571 4bffff80 <0fe00000> 4bfffeb8 81340010 712a0004
> [ 423.735757] ---[ end trace e9b222919a470790 ]---
>
> This warning occurs when calling kmem_cache_zalloc() on a
> cache having a constructor.
>
> In this case it happens because PGD cache and 512k hugepte cache are
> the same size (4k). While a cache with constructor is created for
> the PGD, hugepages create cache without constructor and uses
> kmem_cache_zalloc(). As both expect a cache with the same size,
> the hugepages reuse the cache created for PGD, hence the conflict.
>
> In order to avoid this conflict, this patch:
> - modifies pgtable_cache_add() so that a zeroising constructor is
> added for any cache size.
> - replaces calls to kmem_cache_zalloc() by kmem_cache_alloc()
>
Can't we just do kmem_cache_alloc with gfp flags __GFP_ZERO? and remove
the constructor completely?
-aneesh
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox