* [PATCH 1/5] s390/pci: refresh function handle in iomap
From: Niklas Schnelle @ 2021-09-06 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-s390, Pierre Morel, Matthew Rosato, linux-kernel,
Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
The function handle of a PCI function is updated when disabling or
enabling it as well as when the function's availability changes or it
enters the error state.
Until now this only occurred either while there is no struct pci_dev
associated with the function yet or the function became unavailable.
This meant that leaving a stale function handle in the iomap either
didn't happen because there was no iomap yet or it lead to errors on PCI
access but so would the correct disabled function handle.
In the future a CLP Set PCI Function Disable/Enable cycle during PCI
device recovery may be done while the device is bound to a driver. In
this case we must update the iomap associated with the now-stale
function handle to ensure that the resulting zPCI instruction references
an accurate function handle.
Since the function handle is accessed by the PCI accessor helpers
without locking use READ_ONCE()/WRITE_ONCE() to mark this access and
prevent compiler optimizations that would move the load/store.
With that infrastructure in place let's also properly update the
function handle in the existing cases. This makes sure that in the
future debugging of a zPCI function access through the handle will
show an up to date handle reducing the chance of confusion. Also it
makes sure we have one single place where a zPCI function handle is
updated after initialization.
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
arch/s390/include/asm/pci.h | 1 +
arch/s390/pci/pci.c | 36 ++++++++++++++++++++++++++++++++----
arch/s390/pci/pci_event.c | 6 +++---
arch/s390/pci/pci_insn.c | 4 ++--
4 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index e4803ec51110..5e6cba22a801 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -211,6 +211,7 @@ int zpci_deconfigure_device(struct zpci_dev *zdev);
int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
int zpci_unregister_ioat(struct zpci_dev *, u8);
void zpci_remove_reserved_devices(void);
+void zpci_update_fh(struct zpci_dev *zdev, u32 fh);
/* CLP */
int clp_setup_writeback_mio(void);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index e7e6788d75a8..af22778551c1 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -481,6 +481,34 @@ static void zpci_free_iomap(struct zpci_dev *zdev, int entry)
spin_unlock(&zpci_iomap_lock);
}
+static void zpci_do_update_iomap_fh(struct zpci_dev *zdev, u32 fh)
+{
+ int bar, idx;
+
+ spin_lock(&zpci_iomap_lock);
+ for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
+ if (!zdev->bars[bar].size)
+ continue;
+ idx = zdev->bars[bar].map_idx;
+ if (!zpci_iomap_start[idx].count)
+ continue;
+ WRITE_ONCE(zpci_iomap_start[idx].fh, zdev->fh);
+ }
+ spin_unlock(&zpci_iomap_lock);
+}
+
+void zpci_update_fh(struct zpci_dev *zdev, u32 fh)
+{
+ if (!fh || zdev->fh == fh)
+ return;
+
+ zdev->fh = fh;
+ if (zpci_use_mio(zdev))
+ return;
+ if (zdev->has_resources && zdev_enabled(zdev))
+ zpci_do_update_iomap_fh(zdev, fh);
+}
+
static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start,
unsigned long size, unsigned long flags)
{
@@ -668,7 +696,7 @@ int zpci_enable_device(struct zpci_dev *zdev)
if (clp_enable_fh(zdev, &fh, ZPCI_NR_DMA_SPACES))
rc = -EIO;
else
- zdev->fh = fh;
+ zpci_update_fh(zdev, fh);
return rc;
}
@@ -679,14 +707,14 @@ int zpci_disable_device(struct zpci_dev *zdev)
cc = clp_disable_fh(zdev, &fh);
if (!cc) {
- zdev->fh = fh;
+ zpci_update_fh(zdev, fh);
} else if (cc == CLP_RC_SETPCIFN_ALRDY) {
pr_info("Disabling PCI function %08x had no effect as it was already disabled\n",
zdev->fid);
/* Function is already disabled - update handle */
rc = clp_refresh_fh(zdev->fid, &fh);
if (!rc) {
- zdev->fh = fh;
+ zpci_update_fh(zdev, fh);
rc = -EINVAL;
}
} else {
@@ -768,7 +796,7 @@ int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh)
{
int rc;
- zdev->fh = fh;
+ zpci_update_fh(zdev, fh);
/* the PCI function will be scanned once function 0 appears */
if (!zdev->zbus->bus)
return 0;
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
index c856f80cb21b..e868d996ec5b 100644
--- a/arch/s390/pci/pci_event.c
+++ b/arch/s390/pci/pci_event.c
@@ -76,7 +76,7 @@ void zpci_event_error(void *data)
static void zpci_event_hard_deconfigured(struct zpci_dev *zdev, u32 fh)
{
- zdev->fh = fh;
+ zpci_update_fh(zdev, fh);
/* Give the driver a hint that the function is
* already unusable.
*/
@@ -117,7 +117,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
if (!zdev)
zpci_create_device(ccdf->fid, ccdf->fh, ZPCI_FN_STATE_STANDBY);
else
- zdev->fh = ccdf->fh;
+ zpci_update_fh(zdev, ccdf->fh);
break;
case 0x0303: /* Deconfiguration requested */
if (zdev) {
@@ -126,7 +126,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
*/
if (zdev->state != ZPCI_FN_STATE_CONFIGURED)
break;
- zdev->fh = ccdf->fh;
+ zpci_update_fh(zdev, ccdf->fh);
zpci_deconfigure_device(zdev);
}
break;
diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c
index 2e43996159f0..28d863aaafea 100644
--- a/arch/s390/pci/pci_insn.c
+++ b/arch/s390/pci/pci_insn.c
@@ -163,7 +163,7 @@ static inline int zpci_load_fh(u64 *data, const volatile void __iomem *addr,
unsigned long len)
{
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(addr)];
- u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, len);
+ u64 req = ZPCI_CREATE_REQ(READ_ONCE(entry->fh), entry->bar, len);
return __zpci_load(data, req, ZPCI_OFFSET(addr));
}
@@ -244,7 +244,7 @@ static inline int zpci_store_fh(const volatile void __iomem *addr, u64 data,
unsigned long len)
{
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(addr)];
- u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, len);
+ u64 req = ZPCI_CREATE_REQ(READ_ONCE(entry->fh), entry->bar, len);
return __zpci_store(data, req, ZPCI_OFFSET(addr));
}
--
2.25.1
^ permalink raw reply related
* [PATCH 0/5] s390/pci: automatic error recovery
From: Niklas Schnelle @ 2021-09-06 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-s390, Pierre Morel, Matthew Rosato, linux-kernel,
Oliver O'Halloran, Linas Vepstas, linuxppc-dev
Hello,
This series implements automatic error recovery for PCI devices on s390
following the scheme outlined at Documentation/PCI/pci-error-recovery.rst
it applies on top of currenct master.
The patches have are almost completely s390 specific except for two patches
exporting existing functionality for use by arch/s390/pci/ code. Nevertheless
I would also appreciate any feedback, especially on the last patch, concerning
the implementation of the error recovery flow. I believe we might be the first
implementation of PCI device recovery in a virtualized setting requiring us to
coordinate the device reset with the hypervisor platform by issuing a disable
and re-enable to the platform as well as starting the recovery following
a platform event.
The outline of the patches is as follows:
Patch 1 and 2 add s390 specific code implementing a reset mechanism that
takes the PCI function out of the platform specific error state.
Patches 3 and 4 export existing common code functions for use by the s390
specific recovery code.
Patch 3 I already sent separately resulting in the discussion below but without
a final conclusion.
https://lore.kernel.org/lkml/20210720150145.640727-1-schnelle@linux.ibm.com/
I believe even though there were some doubts about the use of
pci_dev_is_added() by arch code the existing uses as well as the use in the
final patch of this series warrant this export.
Patch 4 "PCI: Export pci_dev_lock()" is basically an extension to commit
e3a9b1212b9d ("PCI: Export pci_dev_trylock() and pci_dev_unlock()") which
already exported pci_dev_trylock(). In the final patch we make use of
pci_dev_lock() to wait for any other exclusive uses of the pdev to be finished
before starting recovery.
Finally Patch 5 implements the recovery flow as part of the existing s390
specific PCI availability and error event mechanism. Where previously the error
case only set an error indication requiring manual intervention to make the
device usable again. Now we handle the case where firmware has already reset
a PCI function after an error was encountered informing the OS that it should
be ready to be used again. Note that the same event is also issued by the
hypervisor if the function was manually taken into a service mode for example
for firmware upgrade via the hypervisor and is now ready to be used again.
Thanks,
Niklas Schnelle
Niklas Schnelle (5):
s390/pci: refresh function handle in iomap
s390/pci: implement reset_slot for hotplug slot
PCI: Move pci_dev_is/assign_added() to pci.h
PCI: Export pci_dev_lock()
s390/pci: implement minimal PCI error recovery
arch/powerpc/platforms/powernv/pci-sriov.c | 3 -
arch/powerpc/platforms/pseries/setup.c | 1 -
arch/s390/include/asm/pci.h | 6 +-
arch/s390/pci/pci.c | 143 ++++++++++++++-
arch/s390/pci/pci_event.c | 196 ++++++++++++++++++++-
arch/s390/pci/pci_insn.c | 4 +-
arch/s390/pci/pci_irq.c | 9 +
arch/s390/pci/pci_sysfs.c | 2 -
drivers/pci/hotplug/acpiphp_glue.c | 1 -
drivers/pci/hotplug/s390_pci_hpc.c | 24 +++
drivers/pci/pci.c | 3 +-
drivers/pci/pci.h | 15 --
include/linux/pci.h | 16 ++
13 files changed, 389 insertions(+), 34 deletions(-)
--
2.25.1
^ permalink raw reply
* [PATCH 2/5] s390/pci: implement reset_slot for hotplug slot
From: Niklas Schnelle @ 2021-09-06 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-s390, Pierre Morel, Matthew Rosato, linux-kernel,
Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
This is done by adding a zpci_hot_reset_device() call which does a low
level reset of the PCI function without changing its higher level
function state. This way it can be used while the zPCI function is bound
to a driver and with DMA tables being controlled either through the
IOMMU or DMA APIs which is prohibited when using zpci_disable_device()
as that drop existing DMA translations.
As this reset, unlike a normal FLR, also calls zpci_clear_irq() we need
to implement arch_restore_msi_irqs() and make sure we re-enable IRQs for
the PCI function if they were previously disabled.
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
arch/s390/include/asm/pci.h | 1 +
arch/s390/pci/pci.c | 58 ++++++++++++++++++++++++++++++
arch/s390/pci/pci_irq.c | 9 +++++
drivers/pci/hotplug/s390_pci_hpc.c | 24 +++++++++++++
4 files changed, 92 insertions(+)
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 5e6cba22a801..2a2ed165a270 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -208,6 +208,7 @@ int zpci_disable_device(struct zpci_dev *);
int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh);
int zpci_deconfigure_device(struct zpci_dev *zdev);
+int zpci_hot_reset_device(struct zpci_dev *zdev);
int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
int zpci_unregister_ioat(struct zpci_dev *, u8);
void zpci_remove_reserved_devices(void);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index af22778551c1..a6322f45b5bd 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -723,6 +723,64 @@ int zpci_disable_device(struct zpci_dev *zdev)
return rc;
}
+/**
+ * zpci_hot_reset_device - perform a reset of the given zPCI function
+ * @zdev: the slot which should be reset
+ *
+ * Performs a low level reset of the zPCI function. The reset is low level in
+ * the sense that the zPCI function can be reset without detaching it from the
+ * common PCI subsystem. The reset may be performed while under control of
+ * either DMA or IOMMU APIs in which case the existing DMA/IOMMU translation
+ * table is reinstated at the end of the reset.
+ *
+ * After the reset the functions internal state is reset to an initial state
+ * equivalent to its state during boot when first probing a driver.
+ * Consequently after reset the PCI function requires re-initialization via the
+ * common PCI code including re-enabling IRQs via pci_alloc_irq_vectors()
+ * and enabling the function via e.g.pci_enablde_device_flags().The caller
+ * must guard against concurrent reset attempts.
+ *
+ * In most cases this function should not be called directly but through
+ * pci_reset_function() or pci_reset_bus() which handle the save/restore and
+ * locking.
+ *
+ * Return: 0 on success and an error value otherwise
+ */
+int zpci_hot_reset_device(struct zpci_dev *zdev)
+{
+ int rc;
+
+ zpci_dbg(3, "reset fid:%x\n", zdev->fid);
+ if (zdev_enabled(zdev)) {
+ /* Disables device access, DMAs and IRQs (reset state) */
+ rc = zpci_disable_device(zdev);
+ /*
+ * Due to a z/VM vs LPAR inconsistency in the error state the
+ * FH may indicate an enabled device but disable says the
+ * device is already disabled don't treat it as an error here.
+ */
+ if (rc == -EINVAL)
+ rc = 0;
+ if (rc)
+ return rc;
+ }
+
+ rc = zpci_enable_device(zdev);
+ if (rc)
+ return rc;
+
+ if (zdev->dma_table) {
+ rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
+ (u64)zdev->dma_table);
+ if (rc)
+ return rc;
+ } else {
+ zpci_dma_init_device(zdev);
+ }
+
+ return 0;
+}
+
/**
* zpci_create_device() - Create a new zpci_dev and add it to the zbus
* @fid: Function ID of the device to be created
diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
index 9c7de9089939..ab98e7f5b79b 100644
--- a/arch/s390/pci/pci_irq.c
+++ b/arch/s390/pci/pci_irq.c
@@ -391,6 +391,15 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
airq_iv_free(zpci_ibv[0], zdev->msi_first_bit, zdev->msi_nr_irqs);
}
+void arch_restore_msi_irqs(struct pci_dev *pdev)
+{
+ struct zpci_dev *zdev = to_zpci(pdev);
+
+ if (!zdev->irqs_registered)
+ zpci_set_irq(zdev);
+ default_restore_msi_irqs(pdev);
+}
+
static struct airq_struct zpci_airq = {
.handler = zpci_floating_irq_handler,
.isc = PCI_ISC,
diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c
index 014868752cd4..07f28db0eed5 100644
--- a/drivers/pci/hotplug/s390_pci_hpc.c
+++ b/drivers/pci/hotplug/s390_pci_hpc.c
@@ -57,6 +57,29 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
return zpci_deconfigure_device(zdev);
}
+static int reset_slot(struct hotplug_slot *hotplug_slot, int probe)
+{
+ struct zpci_dev *zdev = container_of(hotplug_slot, struct zpci_dev,
+ hotplug_slot);
+
+ if (zdev->state != ZPCI_FN_STATE_CONFIGURED)
+ return -EIO;
+ /*
+ * We can't take the zdev->lock as reset_slot may be called during
+ * probing and/or device removal which already happens under the
+ * zdev->lock. Instead the user should use the higher level
+ * pci_reset_function() or pci_bus_reset() which hold the PCI device
+ * lock preventing concurrent removal. If not using these functions
+ * holding the PCI device lock is required.
+ */
+
+ /* As long as the function is configured we can reset */
+ if (probe)
+ return 0;
+
+ return zpci_hot_reset_device(zdev);
+}
+
static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
{
struct zpci_dev *zdev = container_of(hotplug_slot, struct zpci_dev,
@@ -83,6 +106,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
static const struct hotplug_slot_ops s390_hotplug_slot_ops = {
.enable_slot = enable_slot,
.disable_slot = disable_slot,
+ .reset_slot = reset_slot,
.get_power_status = get_power_status,
.get_adapter_status = get_adapter_status,
};
--
2.25.1
^ permalink raw reply related
* [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: Niklas Schnelle @ 2021-09-06 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-s390, Pierre Morel, Matthew Rosato, linux-kernel,
Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
The helper function pci_dev_is_added() from drivers/pci/pci.h is used in
PCI arch code of both s390 and powerpc leading to awkward relative
includes. Move it to the global include/linux/pci.h and get rid of these
includes just for that one function.
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
arch/powerpc/platforms/powernv/pci-sriov.c | 3 ---
arch/powerpc/platforms/pseries/setup.c | 1 -
arch/s390/pci/pci_sysfs.c | 2 --
drivers/pci/hotplug/acpiphp_glue.c | 1 -
drivers/pci/pci.h | 15 ---------------
include/linux/pci.h | 15 +++++++++++++++
6 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/pci-sriov.c b/arch/powerpc/platforms/powernv/pci-sriov.c
index 28aac933a439..2e0ca5451e85 100644
--- a/arch/powerpc/platforms/powernv/pci-sriov.c
+++ b/arch/powerpc/platforms/powernv/pci-sriov.c
@@ -9,9 +9,6 @@
#include "pci.h"
-/* for pci_dev_is_added() */
-#include "../../../../drivers/pci/pci.h"
-
/*
* The majority of the complexity in supporting SR-IOV on PowerNV comes from
* the need to put the MMIO space for each VF into a separate PE. Internally
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 0dfaa6ab44cc..08e846ae1853 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -74,7 +74,6 @@
#include <asm/hvconsole.h>
#include "pseries.h"
-#include "../../../../drivers/pci/pci.h"
DEFINE_STATIC_KEY_FALSE(shared_processor);
EXPORT_SYMBOL(shared_processor);
diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
index 335c281811c7..40733b93a086 100644
--- a/arch/s390/pci/pci_sysfs.c
+++ b/arch/s390/pci/pci_sysfs.c
@@ -13,8 +13,6 @@
#include <linux/stat.h>
#include <linux/pci.h>
-#include "../../../drivers/pci/pci.h"
-
#include <asm/sclp.h>
#define zpci_attr(name, fmt, member) \
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index f031302ad401..4cb963f88183 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -38,7 +38,6 @@
#include <linux/slab.h>
#include <linux/acpi.h>
-#include "../pci.h"
#include "acpiphp.h"
static LIST_HEAD(bridge_list);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 93dcdd431072..a159cd0f6f05 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -383,21 +383,6 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
return dev->error_state == pci_channel_io_perm_failure;
}
-/* pci_dev priv_flags */
-#define PCI_DEV_ADDED 0
-#define PCI_DPC_RECOVERED 1
-#define PCI_DPC_RECOVERING 2
-
-static inline void pci_dev_assign_added(struct pci_dev *dev, bool added)
-{
- assign_bit(PCI_DEV_ADDED, &dev->priv_flags, added);
-}
-
-static inline bool pci_dev_is_added(const struct pci_dev *dev)
-{
- return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
-}
-
#ifdef CONFIG_PCIEAER
#include <linux/aer.h>
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 540b377ca8f6..ea0e23dbc8ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -507,6 +507,21 @@ struct pci_dev {
unsigned long priv_flags; /* Private flags for the PCI driver */
};
+/* pci_dev priv_flags */
+#define PCI_DEV_ADDED 0
+#define PCI_DPC_RECOVERED 1
+#define PCI_DPC_RECOVERING 2
+
+static inline void pci_dev_assign_added(struct pci_dev *dev, bool added)
+{
+ assign_bit(PCI_DEV_ADDED, &dev->priv_flags, added);
+}
+
+static inline bool pci_dev_is_added(const struct pci_dev *dev)
+{
+ return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
+}
+
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
{
#ifdef CONFIG_PCI_IOV
--
2.25.1
^ permalink raw reply related
* [PATCH 5/5] s390/pci: implement minimal PCI error recovery
From: Niklas Schnelle @ 2021-09-06 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-s390, Pierre Morel, Matthew Rosato, linux-kernel,
Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
When the platform detects an error on a PCI function or a service action
has been performed it is put in the error state and an error event
notification is provided to the OS.
Currently we treat all error event notifications the same and simply set
pdev->error_state = pci_channel_io_perm_failure requiring user
intervention such as use of the recover attribute to get the device
usable again. Despite requiring a manual step this also has the
disadvantage that the device is completely torn down and recreated
resulting in higher level devices such as a block or network device
being recreated. In case of a block device this also means that it may
need to be removed and added to a software raid even if that could
otherwise survive with a temporary degradation.
This is of course not ideal more so since an error notification with PEC
0x3A indicates that the platform already performed error recovery
successfully or that the error state was caused by a service action that
is now finished.
At least in this case we can assume that the error state can be reset
and the function made usable again. So as not to have the disadvantage
of a full tear down and recreation we need to coordinate this recovery
with the driver. Thankfully there is already a well defined recovery
flow for this described in Documentation/PCI/pci-error-recovery.rst.
The implementation of this is somewhat straight forward and simplified
by the fact that our recovery flow is defined per PCI function. As
a reset we use the newly introduced zpci_hot_reset_device() which also
takes the PCI function out of the error state.
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
arch/s390/include/asm/pci.h | 4 +-
arch/s390/pci/pci.c | 49 ++++++++++
arch/s390/pci/pci_event.c | 190 +++++++++++++++++++++++++++++++++++-
3 files changed, 241 insertions(+), 2 deletions(-)
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 2a2ed165a270..558877aff2e5 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -294,8 +294,10 @@ void zpci_debug_exit(void);
void zpci_debug_init_device(struct zpci_dev *, const char *);
void zpci_debug_exit_device(struct zpci_dev *);
-/* Error reporting */
+/* Error handling */
int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *);
+int zpci_clear_error_state(struct zpci_dev *zdev);
+int zpci_reset_load_store_blocked(struct zpci_dev *zdev);
#ifdef CONFIG_NUMA
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a6322f45b5bd..77a3e85d43fb 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -954,6 +954,55 @@ int zpci_report_error(struct pci_dev *pdev,
}
EXPORT_SYMBOL(zpci_report_error);
+/**
+ * zpci_clear_error_state() - Clears the zPCI error state of the device
+ * @zdev: The zdev for which the zPCI error state should be reset
+ *
+ * Clear the zPCI error state of the device. If clearing the zPCI error state
+ * fails the device is left in the error state. In this case it may make sense
+ * to call zpci_io_perm_failure() on the associated pdev if it exists.
+ *
+ * Returns: 0 on success, -EIO otherwise
+ */
+int zpci_clear_error_state(struct zpci_dev *zdev)
+{
+ u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_RESET_ERROR);
+ struct zpci_fib fib = {0};
+ u8 status;
+ int rc;
+
+ rc = zpci_mod_fc(req, &fib, &status);
+ if (rc)
+ return -EIO;
+
+ return 0;
+}
+
+/**
+ * zpci_reset_load_store_blocked() - Re-enables L/S from error state
+ * @zdev: The zdev for which to unblock load/store access
+ *
+ * R-eenables load/store access for a PCI function in the error state while
+ * keeping DMA blocked. In this state drivers can poke MMIO space to determine
+ * if error recovery is possible while catching any rogue DMA access from the
+ * device.
+ *
+ * Returns: 0 on success, -EIO otherwise
+ */
+int zpci_reset_load_store_blocked(struct zpci_dev *zdev)
+{
+ u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_RESET_BLOCK);
+ struct zpci_fib fib = {0};
+ u8 status;
+ int rc;
+
+ rc = zpci_mod_fc(req, &fib, &status);
+ if (rc)
+ return -EIO;
+
+ return 0;
+}
+
static int zpci_mem_init(void)
{
BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) ||
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
index e868d996ec5b..ac9ed1572d39 100644
--- a/arch/s390/pci/pci_event.c
+++ b/arch/s390/pci/pci_event.c
@@ -47,15 +47,190 @@ struct zpci_ccdf_avail {
u16 pec; /* PCI event code */
} __packed;
+static inline bool ers_result_indicates_abort(pci_ers_result_t ers_res)
+{
+ switch (ers_res) {
+ case PCI_ERS_RESULT_CAN_RECOVER:
+ case PCI_ERS_RESULT_RECOVERED:
+ case PCI_ERS_RESULT_NEED_RESET:
+ return false;
+ default:
+ return true;
+ }
+}
+
+static pci_ers_result_t zpci_event_notify_error_detected(struct pci_dev *pdev)
+{
+ pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
+ struct pci_driver *driver = pdev->driver;
+
+ pr_debug("%s: calling error_detected() callback\n", pci_name(pdev));
+ ers_res = driver->err_handler->error_detected(pdev, pdev->error_state);
+ if (ers_result_indicates_abort(ers_res))
+ pr_info("%s: driver can't recover\n", pci_name(pdev));
+ else if (ers_res == PCI_ERS_RESULT_NEED_RESET)
+ pr_debug("%s: driver needs reset to recover\n", pci_name(pdev));
+
+ return ers_res;
+}
+
+static pci_ers_result_t zpci_event_do_error_state_clear(struct pci_dev *pdev)
+{
+ pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
+ struct pci_driver *driver = pdev->driver;
+ struct zpci_dev *zdev = to_zpci(pdev);
+ int rc;
+
+ pr_debug("%s: reset load/store blocked\n", pci_name(pdev));
+ rc = zpci_reset_load_store_blocked(zdev);
+ if (rc) {
+ pr_err("%s: reset load/store blocked failed\n", pci_name(pdev));
+ /* Let's try a full reset instead */
+ return PCI_ERS_RESULT_NEED_RESET;
+ }
+
+ if (driver->err_handler->mmio_enabled) {
+ pr_debug("%s: calling mmio_enabled() callback\n", pci_name(pdev));
+ ers_res = driver->err_handler->mmio_enabled(pdev);
+ if (ers_result_indicates_abort(ers_res)) {
+ pr_info("%s: driver can't recover after enabling MMIO\n", pci_name(pdev));
+ return ers_res;
+ } else if (ers_res == PCI_ERS_RESULT_NEED_RESET) {
+ pr_debug("%s: driver needs reset to recover\n", pci_name(pdev));
+ return ers_res;
+ }
+ }
+
+ pr_debug("%s: clearing error state\n", pci_name(pdev));
+ rc = zpci_clear_error_state(zdev);
+ if (!rc) {
+ pdev->error_state = pci_channel_io_normal;
+ } else {
+ pr_err("%s: resetting error state failed\n", pci_name(pdev));
+ /* Let's try a full reset instead */
+ return PCI_ERS_RESULT_NEED_RESET;
+ }
+
+ return ers_res;
+}
+
+static pci_ers_result_t zpci_event_do_reset(struct pci_dev *pdev)
+{
+ pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
+ struct pci_driver *driver = pdev->driver;
+
+ pr_info("%s: initiating reset\n", pci_name(pdev));
+ if (zpci_hot_reset_device(to_zpci(pdev))) {
+ pr_err("%s: resetting function failed\n", pci_name(pdev));
+ return ers_res;
+ }
+ pdev->error_state = pci_channel_io_normal;
+ if (driver->err_handler->slot_reset) {
+ ers_res = driver->err_handler->slot_reset(pdev);
+ if (ers_result_indicates_abort(ers_res)) {
+ pr_info("%s: driver can't recover after slot reset\n", pci_name(pdev));
+ return ers_res;
+ }
+ }
+
+ return ers_res;
+}
+
+/* zpci_event_attempt_error_recovery - Try to recover the given PCI function
+ * @pdev: PCI function to recover currently in the error state
+ *
+ * We follow the scheme outlined in Documentation/PCI/pci-error-recovery.rst.
+ * With the simplification that recovery always happens per function
+ * and the platform determines which functions are affected for
+ * multi-function devices.
+ */
+static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)
+{
+ pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
+ struct pci_driver *driver;
+
+ /*
+ * Ensure that the PCI function is not removed concurrently, no driver
+ * is unbound or probed and that userspace can't access its
+ * configuration space while we perform recovery.
+ */
+ pci_dev_lock(pdev);
+ /*
+ * Between getting the pdev and locking it the PCI device may have been
+ * removed e.g. by a concurrent call to recover_store().
+ */
+ if (!pci_dev_is_added(pdev))
+ goto out_unlock;
+ if (pdev->error_state == pci_channel_io_perm_failure) {
+ ers_res = PCI_ERS_RESULT_DISCONNECT;
+ goto out_unlock;
+ }
+ pdev->error_state = pci_channel_io_frozen;
+
+ driver = pdev->driver;
+ if (!driver || !driver->err_handler || !driver->err_handler->error_detected) {
+ pr_info("%s: driver does not support error recovery\n", pci_name(pdev));
+ goto out_unlock;
+ }
+
+ ers_res = zpci_event_notify_error_detected(pdev);
+ if (ers_result_indicates_abort(ers_res))
+ goto out_unlock;
+
+ if (ers_res == PCI_ERS_RESULT_CAN_RECOVER) {
+ ers_res = zpci_event_do_error_state_clear(pdev);
+ if (ers_result_indicates_abort(ers_res))
+ goto out_unlock;
+ }
+
+ if (ers_res == PCI_ERS_RESULT_NEED_RESET)
+ ers_res = zpci_event_do_reset(pdev);
+
+ if (ers_res != PCI_ERS_RESULT_RECOVERED) {
+ pr_err("%s: recovery failed\n", pci_name(pdev));
+ goto out_unlock;
+ }
+
+ pr_info("%s: resuming operations\n", pci_name(pdev));
+ if (driver->err_handler->resume)
+ driver->err_handler->resume(pdev);
+out_unlock:
+ pci_dev_unlock(pdev);
+
+ return ers_res;
+}
+
+/* zpci_event_io_failure - Report IO failure state es to driver
+ * @pdev: PCI function to report as failed
+ */
+static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_t es)
+{
+ struct pci_driver *driver;
+
+ pci_dev_lock(pdev);
+ if (!pci_dev_is_added(pdev))
+ goto out_unlock;
+ pdev->error_state = es;
+ driver = pdev->driver;
+ if (driver && driver->err_handler && driver->err_handler->error_detected)
+ driver->err_handler->error_detected(pdev, pdev->error_state);
+out_unlock:
+ pci_dev_unlock(pdev);
+}
+
static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
{
struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
struct pci_dev *pdev = NULL;
+ pci_ers_result_t ers_res;
zpci_err("error CCDF:\n");
zpci_err_hex(ccdf, sizeof(*ccdf));
if (zdev)
+ zpci_update_fh(zdev, ccdf->fh);
+
+ if (zdev->zbus->bus)
pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
@@ -64,7 +239,20 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
if (!pdev)
return;
- pdev->error_state = pci_channel_io_perm_failure;
+ switch (ccdf->pec) {
+ case 0x003a: /* Service Action or Error Recovery Successful */
+ ers_res = zpci_event_attempt_error_recovery(pdev);
+ if (ers_res != PCI_ERS_RESULT_RECOVERED)
+ zpci_event_io_failure(pdev, pci_channel_io_perm_failure);
+ break;
+ default:
+ /*
+ * Mark as frozen not permanently failed because the device
+ * could be subsequently recovered by the platform.
+ */
+ zpci_event_io_failure(pdev, pci_channel_io_frozen);
+ break;
+ }
pci_dev_put(pdev);
}
--
2.25.1
^ permalink raw reply related
* [PATCH 4/5] PCI: Export pci_dev_lock()
From: Niklas Schnelle @ 2021-09-06 9:49 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-s390, Pierre Morel, Matthew Rosato, linux-kernel,
Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
Commit e3a9b1212b9d ("PCI: Export pci_dev_trylock() and pci_dev_unlock()")
already exported pci_dev_trylock()/pci_dev_unlock() however in some
circumstances such as during error recovery it makes sense to block
waiting to get full access to the device so also export pci_dev_lock().
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
drivers/pci/pci.c | 3 ++-
include/linux/pci.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index aacf575c15cf..3f416c6d3b0b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5040,12 +5040,13 @@ static int pci_reset_bus_function(struct pci_dev *dev, int probe)
return pci_parent_bus_reset(dev, probe);
}
-static void pci_dev_lock(struct pci_dev *dev)
+void pci_dev_lock(struct pci_dev *dev)
{
pci_cfg_access_lock(dev);
/* block PM suspend, driver probe, etc. */
device_lock(&dev->dev);
}
+EXPORT_SYMBOL_GPL(pci_dev_lock);
/* Return 1 on successful lock, 0 on contention */
int pci_dev_trylock(struct pci_dev *dev)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ea0e23dbc8ec..efc78b8d4696 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1639,6 +1639,7 @@ void pci_cfg_access_lock(struct pci_dev *dev);
bool pci_cfg_access_trylock(struct pci_dev *dev);
void pci_cfg_access_unlock(struct pci_dev *dev);
+void pci_dev_lock(struct pci_dev *dev);
int pci_dev_trylock(struct pci_dev *dev);
void pci_dev_unlock(struct pci_dev *dev);
--
2.25.1
^ permalink raw reply related
* Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest
From: Paolo Bonzini @ 2021-09-06 10:28 UTC (permalink / raw)
To: Mathieu Desnoyers, Sean Christopherson
Cc: KVM list, Peter Zijlstra, Oleg Nesterov, Will Deacon, Guo Ren,
linux-kselftest, Ben Gardon, shuah, linux-s390, gor,
Russell King, ARM Linux, linux-csky, Christian Borntraeger,
Ingo Molnar, Catalin Marinas, linux-mips, Boqun Feng, paulmck,
Heiko Carstens, rostedt, Shakeel Butt, Andy Lutomirski,
Thomas Gleixner, Peter Foley, linux-arm-kernel,
Thomas Bogendoerfer, linux-kernel, Paul Mackerras, linuxppc-dev
In-Reply-To: <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com>
On 20/08/21 20:51, Mathieu Desnoyers wrote:
>> Ah, or is it the case that rseq_cs is non-NULL if and only if userspace is in an
>> rseq critical section, and because syscalls in critical sections are illegal, by
>> definition clearing rseq_cs is a nop unless userspace is misbehaving.
> Not quite, as I described above. But we want it to stay set so the CONFIG_DEBUG_RSEQ
> code executed when returning from ioctl to userspace will be able to validate that
> it is not nested within a rseq critical section.
>
>> If that's true, what about explicitly checking that at NOTIFY_RESUME? Or is it
>> not worth the extra code to detect an error that will likely be caught anyways?
> The error will indeed already be caught on return from ioctl to userspace, so I
> don't see any added value in duplicating this check.
Sean, can you send a v2 (even for this patch only would be okay)?
Thanks,
Paolo
^ permalink raw reply
* [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Weizhao Ouyang @ 2021-09-06 11:16 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Catalin Marinas, Albert Ou, Weizhao Ouyang,
Vasily Gorbik, Heiko Carstens, Borislav Petkov, Greentime Hu,
Paul Walmsley, Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
ftrace_dyn_arch_init() to cleanup them.
Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
---
Changes in v2:
-- correct CONFIG_DYNAMIC_FTRACE on PowerPC
-- add Acked-by tag
---
arch/arm/kernel/ftrace.c | 5 -----
arch/arm64/kernel/ftrace.c | 5 -----
arch/csky/kernel/ftrace.c | 5 -----
arch/ia64/kernel/ftrace.c | 6 ------
arch/microblaze/kernel/ftrace.c | 5 -----
arch/mips/include/asm/ftrace.h | 2 ++
arch/nds32/kernel/ftrace.c | 5 -----
arch/parisc/kernel/ftrace.c | 5 -----
arch/powerpc/include/asm/ftrace.h | 4 ++++
arch/riscv/kernel/ftrace.c | 5 -----
arch/s390/kernel/ftrace.c | 5 -----
arch/sh/kernel/ftrace.c | 5 -----
arch/sparc/kernel/ftrace.c | 5 -----
arch/x86/kernel/ftrace.c | 5 -----
include/linux/ftrace.h | 1 -
kernel/trace/ftrace.c | 5 +++++
16 files changed, 11 insertions(+), 62 deletions(-)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 3c83b5d29697..a006585e1c09 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -193,11 +193,6 @@ int ftrace_make_nop(struct module *mod,
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index 7f467bd9db7a..fc62dfe73f93 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -236,11 +236,6 @@ void arch_ftrace_update_code(int command)
command |= FTRACE_MAY_SLEEP;
ftrace_modify_all_code(command);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c
index b4a7ec1517ff..50bfcf129078 100644
--- a/arch/csky/kernel/ftrace.c
+++ b/arch/csky/kernel/ftrace.c
@@ -133,11 +133,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
(unsigned long)func, true, true);
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c
index b2ab2d58fb30..d6360fd404ab 100644
--- a/arch/ia64/kernel/ftrace.c
+++ b/arch/ia64/kernel/ftrace.c
@@ -194,9 +194,3 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
flush_icache_range(addr, addr + 16);
return 0;
}
-
-/* run from kstop_machine */
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
index 224eea40e1ee..188749d62709 100644
--- a/arch/microblaze/kernel/ftrace.c
+++ b/arch/microblaze/kernel/ftrace.c
@@ -163,11 +163,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return ret;
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long ip = (unsigned long)(&ftrace_call);
diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
index b463f2aa5a61..ed013e767390 100644
--- a/arch/mips/include/asm/ftrace.h
+++ b/arch/mips/include/asm/ftrace.h
@@ -76,6 +76,8 @@ do { \
#ifdef CONFIG_DYNAMIC_FTRACE
+int __init ftrace_dyn_arch_init(void);
+
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
return addr;
diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
index 0e23e3a8df6b..f0ef4842d191 100644
--- a/arch/nds32/kernel/ftrace.c
+++ b/arch/nds32/kernel/ftrace.c
@@ -84,11 +84,6 @@ void _ftrace_caller(unsigned long parent_ip)
/* restore all state needed by the compiler epilogue */
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
static unsigned long gen_sethi_insn(unsigned long addr)
{
unsigned long opcode = 0x46000000;
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 0a1e75af5382..01581f715737 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -94,11 +94,6 @@ int ftrace_disable_ftrace_graph_caller(void)
#endif
#ifdef CONFIG_DYNAMIC_FTRACE
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
int ftrace_update_ftrace_func(ftrace_func_t func)
{
return 0;
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index debe8c4f7062..d59f67c0225f 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
};
#endif /* __ASSEMBLY__ */
+#ifdef CONFIG_DYNAMIC_FTRACE
+int __init ftrace_dyn_arch_init(void);
+#endif /* CONFIG_DYNAMIC_FTRACE */
+
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
#define ARCH_SUPPORTS_FTRACE_OPS 1
#endif
diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
index 7f1e5203de88..4716f4cdc038 100644
--- a/arch/riscv/kernel/ftrace.c
+++ b/arch/riscv/kernel/ftrace.c
@@ -154,11 +154,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index 0a464d328467..3fd80397ff52 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -262,11 +262,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return 0;
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
void arch_ftrace_update_code(int command)
{
if (ftrace_shared_hotpatch_trampoline(NULL))
diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c
index 295c43315bbe..930001bb8c6a 100644
--- a/arch/sh/kernel/ftrace.c
+++ b/arch/sh/kernel/ftrace.c
@@ -252,11 +252,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return ftrace_modify_code(rec->ip, old, new);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
index 684b84ce397f..eaead3da8e03 100644
--- a/arch/sparc/kernel/ftrace.c
+++ b/arch/sparc/kernel/ftrace.c
@@ -82,11 +82,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
new = ftrace_call_replace(ip, (unsigned long)func);
return ftrace_modify_code(ip, old, new);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1b3ce3b4a2a2..23d221a9a3cd 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -252,11 +252,6 @@ void arch_ftrace_update_code(int command)
ftrace_modify_all_code(command);
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
/* Currently only x86_64 supports dynamic trampolines */
#ifdef CONFIG_X86_64
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 832e65f06754..f1eca123d89d 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
/* defined in arch */
extern int ftrace_ip_converted(unsigned long ip);
-extern int ftrace_dyn_arch_init(void);
extern void ftrace_replace_code(int enable);
extern int ftrace_update_ftrace_func(ftrace_func_t func);
extern void ftrace_caller(void);
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 7efbc8aaf7f6..4c090323198d 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6846,6 +6846,11 @@ void __init ftrace_free_init_mem(void)
ftrace_free_mem(NULL, start, end);
}
+int __init __weak ftrace_dyn_arch_init(void)
+{
+ return 0;
+}
+
void __init ftrace_init(void)
{
extern unsigned long __start_mcount_loc[];
--
2.30.2
^ permalink raw reply related
* Re: [PATCH for-5.15 0/5] ASoC: fsl: register platform component before registering cpu dai
From: Mark Brown @ 2021-09-06 11:47 UTC (permalink / raw)
To: Shengjiu Wang
Cc: alsa-devel, timur, Xiubo.Lee, linuxppc-dev, tiwai, perex,
nicoleotsuka, festevam, linux-kernel
In-Reply-To: <1630665006-31437-1-git-send-email-shengjiu.wang@nxp.com>
[-- Attachment #1: Type: text/plain, Size: 428 bytes --]
On Fri, Sep 03, 2021 at 06:30:01PM +0800, Shengjiu Wang wrote:
> There is no defer probe when adding platform component to
> snd_soc_pcm_runtime(rtd), the code is in snd_soc_add_pcm_runtime()
...
> So if the platform component is not ready at that time, then the
> sound card still registered successfully, but platform component
> is empty, the sound card can't be used.
This sounds like a bug which should be fixed there?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH] powerpc/mce: Fix access error in mce handler
From: Michael Ellerman @ 2021-09-06 12:33 UTC (permalink / raw)
To: Ganesh Goudar, linuxppc-dev; +Cc: Ganesh Goudar, mahesh, npiggin
In-Reply-To: <20210906081823.181509-1-ganeshgr@linux.ibm.com>
Ganesh Goudar <ganeshgr@linux.ibm.com> writes:
> We queue an irq work for deferred processing of mce event
> in realmode mce handler, where translation is disabled.
> Queuing of the work may result in accessing memory outside
> RMO region, such access needs the translation to be enabled
> for an LPAR running with hash mmu else the kernel crashes.
>
> So enable the translation before queuing the work.
>
> Without this change following trace is seen on injecting machine
> check error in an LPAR running with hash mmu.
What type of error are you injecting?
> Oops: Kernel access of bad area, sig: 11 [#1]
> LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
> CPU: 5 PID: 1883 Comm: insmod Tainted: G OE 5.14.0-mce+ #137
> NIP: c000000000735d60 LR: c000000000318640 CTR: 0000000000000000
> REGS: c00000001ebff9a0 TRAP: 0300 Tainted: G OE (5.14.0-mce+)
> MSR: 8000000000001003 <SF,ME,RI,LE> CR: 28008228 XER: 00000001
> CFAR: c00000000031863c DAR: c00000027fa8fe08 DSISR: 40000000 IRQMASK: 0
> GPR00: c0000000003186d0 c00000001ebffc40 c000000001b0df00 c0000000016337e8
> GPR04: c0000000016337e8 c00000027fa8fe08 0000000000000023 c0000000016337f0
> GPR08: 0000000000000023 c0000000012ffe08 0000000000000000 c008000001460240
> GPR12: 0000000000000000 c00000001ec9a900 c00000002ac4bd00 0000000000000000
> GPR16: 00000000000005a0 c0080000006b0000 c0080000006b05a0 c000000000ff3068
> GPR20: c00000002ac4bbc0 0000000000000001 c00000002ac4bbc0 c008000001490298
> GPR24: c008000001490108 c000000001636198 c008000001470090 c008000001470058
> GPR28: 0000000000000510 c008000001000000 c008000008000019 0000000000000019
> NIP [c000000000735d60] llist_add_batch+0x0/0x40
> LR [c000000000318640] __irq_work_queue_local+0x70/0xc0
> Call Trace:
> [c00000001ebffc40] [c00000001ebffc0c] 0xc00000001ebffc0c (unreliable)
> [c00000001ebffc60] [c0000000003186d0] irq_work_queue+0x40/0x70
> [c00000001ebffc80] [c00000000004425c] machine_check_queue_event+0xbc/0xd0
> [c00000001ebffcf0] [c00000000000838c] machine_check_early_common+0x16c/0x1f4
>
> Fixes: 74c3354bc1d89 ("powerpc/pseries/mce: restore msr before returning from handler")
Please explain in more detail why that commit caused this breakage.
> diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
> index 47a683cd00d2..9d1e39d42e3e 100644
> --- a/arch/powerpc/kernel/mce.c
> +++ b/arch/powerpc/kernel/mce.c
> @@ -249,6 +249,7 @@ void machine_check_queue_event(void)
> {
> int index;
> struct machine_check_event evt;
> + unsigned long msr;
>
> if (!get_mce_event(&evt, MCE_EVENT_RELEASE))
> return;
> @@ -262,8 +263,19 @@ void machine_check_queue_event(void)
> memcpy(&local_paca->mce_info->mce_event_queue[index],
> &evt, sizeof(evt));
>
> - /* Queue irq work to process this event later. */
> - irq_work_queue(&mce_event_process_work);
> + /* Queue irq work to process this event later. Before
> + * queuing the work enable translation for non radix LPAR,
> + * as irq_work_queue may try to access memory outside RMO
> + * region.
> + */
> + if (!radix_enabled() && firmware_has_feature(FW_FEATURE_LPAR)) {
> + msr = mfmsr();
> + mtmsr(msr | MSR_IR | MSR_DR);
> + irq_work_queue(&mce_event_process_work);
> + mtmsr(msr);
> + } else {
> + irq_work_queue(&mce_event_process_work);
> + }
> }
We already went to virtual mode and queued (different) irq work in
arch/powerpc/platforms/pseries/ras.c:mce_handle_error()
We also called save_mce_event() which also might have queued irq work,
via machine_check_ue_event().
So it really feels like something about the design is wrong if we have
to go to virtual mode again and queue more irq work here.
I guess we can probably merge this as a backportable fix, doing anything
else would be a bigger change.
Looking at ras.c there's the comment:
* Enable translation as we will be accessing per-cpu variables
* in save_mce_event() which may fall outside RMO region, also
But AFAICS it's only irq_work_queue() that touches anything percpu?
So maybe we should just not be using irq_work_queue(). It's a pretty
thin wrapper around set_dec(1), perhaps we just need to hand-roll some
real-mode friendly way of doing that.
cheers
^ permalink raw reply
* Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Michael Ellerman @ 2021-09-06 14:22 UTC (permalink / raw)
To: Weizhao Ouyang, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Albert Ou, Weizhao Ouyang, Vasily Gorbik,
Heiko Carstens, Borislav Petkov, Greentime Hu, Paul Walmsley,
Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
In-Reply-To: <20210906111626.1259867-1-o451686892@gmail.com>
Weizhao Ouyang <o451686892@gmail.com> writes:
> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
> ftrace_dyn_arch_init() to cleanup them.
>
> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
>
> ---
>
> Changes in v2:
> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
> -- add Acked-by tag
> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index debe8c4f7062..d59f67c0225f 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
> };
> #endif /* __ASSEMBLY__ */
>
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +#endif /* CONFIG_DYNAMIC_FTRACE */
> +
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> #define ARCH_SUPPORTS_FTRACE_OPS 1
> #endif
That breaks the build for powerpc:
/linux/arch/powerpc/include/asm/ftrace.h: Assembler messages:
/linux/arch/powerpc/include/asm/ftrace.h:65: Error: unrecognized opcode: `int'
make[4]: *** [/linux/scripts/Makefile.build:352: arch/powerpc/kernel/trace/ftrace_64.o] Error 1
make[3]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel/trace] Error 2
make[2]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel] Error 2
make[1]: *** [/linux/Makefile:1861: arch/powerpc] Error 2
make[1]: *** Waiting for unfinished jobs....
It needs to be inside an #ifndef __ASSEMBLY__ section.
cheers
^ permalink raw reply
* Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Weizhao Ouyang @ 2021-09-06 14:57 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Albert Ou, Vasily Gorbik, Heiko Carstens,
Borislav Petkov, Greentime Hu, Paul Walmsley, Thomas Gleixner,
linux-arm-kernel, Michal Simek, Thomas Bogendoerfer, linux-parisc,
Nick Hu, linux-kernel, Palmer Dabbelt, Paul Mackerras,
linuxppc-dev, David S. Miller
In-Reply-To: <87v93dn5qh.fsf@mpe.ellerman.id.au>
On 2021/9/6 22:22, Michael Ellerman wrote:
> Weizhao Ouyang <o451686892@gmail.com> writes:
>> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
>> ftrace_dyn_arch_init() to cleanup them.
>>
>> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
>> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
>>
>> ---
>>
>> Changes in v2:
>> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
>> -- add Acked-by tag
>> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
>> index debe8c4f7062..d59f67c0225f 100644
>> --- a/arch/powerpc/include/asm/ftrace.h
>> +++ b/arch/powerpc/include/asm/ftrace.h
>> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
>> };
>> #endif /* __ASSEMBLY__ */
>>
>> +#ifdef CONFIG_DYNAMIC_FTRACE
>> +int __init ftrace_dyn_arch_init(void);
>> +#endif /* CONFIG_DYNAMIC_FTRACE */
>> +
>> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
>> #define ARCH_SUPPORTS_FTRACE_OPS 1
>> #endif
> That breaks the build for powerpc:
>
> /linux/arch/powerpc/include/asm/ftrace.h: Assembler messages:
> /linux/arch/powerpc/include/asm/ftrace.h:65: Error: unrecognized opcode: `int'
> make[4]: *** [/linux/scripts/Makefile.build:352: arch/powerpc/kernel/trace/ftrace_64.o] Error 1
> make[3]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel/trace] Error 2
> make[2]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel] Error 2
> make[1]: *** [/linux/Makefile:1861: arch/powerpc] Error 2
> make[1]: *** Waiting for unfinished jobs....
>
> It needs to be inside an #ifndef __ASSEMBLY__ section.
>
> cheers
Thanks for reply, I'll fix it up.
^ permalink raw reply
* Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Helge Deller @ 2021-09-06 20:36 UTC (permalink / raw)
To: Weizhao Ouyang, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, x86, Russell King, linux-csky,
Christian Borntraeger, Catalin Marinas, Albert Ou, Vasily Gorbik,
Heiko Carstens, Borislav Petkov, Greentime Hu, Paul Walmsley,
Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
In-Reply-To: <20210906111626.1259867-1-o451686892@gmail.com>
On 9/6/21 1:16 PM, Weizhao Ouyang wrote:
> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
> ftrace_dyn_arch_init() to cleanup them.
>
> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
Acked-by: Helge Deller <deller@gmx.de> # parisc
Thanks,
Helge
> ---
>
> Changes in v2:
> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
> -- add Acked-by tag
>
> ---
> arch/arm/kernel/ftrace.c | 5 -----
> arch/arm64/kernel/ftrace.c | 5 -----
> arch/csky/kernel/ftrace.c | 5 -----
> arch/ia64/kernel/ftrace.c | 6 ------
> arch/microblaze/kernel/ftrace.c | 5 -----
> arch/mips/include/asm/ftrace.h | 2 ++
> arch/nds32/kernel/ftrace.c | 5 -----
> arch/parisc/kernel/ftrace.c | 5 -----
> arch/powerpc/include/asm/ftrace.h | 4 ++++
> arch/riscv/kernel/ftrace.c | 5 -----
> arch/s390/kernel/ftrace.c | 5 -----
> arch/sh/kernel/ftrace.c | 5 -----
> arch/sparc/kernel/ftrace.c | 5 -----
> arch/x86/kernel/ftrace.c | 5 -----
> include/linux/ftrace.h | 1 -
> kernel/trace/ftrace.c | 5 +++++
> 16 files changed, 11 insertions(+), 62 deletions(-)
>
> diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> index 3c83b5d29697..a006585e1c09 100644
> --- a/arch/arm/kernel/ftrace.c
> +++ b/arch/arm/kernel/ftrace.c
> @@ -193,11 +193,6 @@ int ftrace_make_nop(struct module *mod,
>
> return ret;
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> index 7f467bd9db7a..fc62dfe73f93 100644
> --- a/arch/arm64/kernel/ftrace.c
> +++ b/arch/arm64/kernel/ftrace.c
> @@ -236,11 +236,6 @@ void arch_ftrace_update_code(int command)
> command |= FTRACE_MAY_SLEEP;
> ftrace_modify_all_code(command);
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c
> index b4a7ec1517ff..50bfcf129078 100644
> --- a/arch/csky/kernel/ftrace.c
> +++ b/arch/csky/kernel/ftrace.c
> @@ -133,11 +133,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> (unsigned long)func, true, true);
> return ret;
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c
> index b2ab2d58fb30..d6360fd404ab 100644
> --- a/arch/ia64/kernel/ftrace.c
> +++ b/arch/ia64/kernel/ftrace.c
> @@ -194,9 +194,3 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> flush_icache_range(addr, addr + 16);
> return 0;
> }
> -
> -/* run from kstop_machine */
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
> index 224eea40e1ee..188749d62709 100644
> --- a/arch/microblaze/kernel/ftrace.c
> +++ b/arch/microblaze/kernel/ftrace.c
> @@ -163,11 +163,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
> return ret;
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> int ftrace_update_ftrace_func(ftrace_func_t func)
> {
> unsigned long ip = (unsigned long)(&ftrace_call);
> diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
> index b463f2aa5a61..ed013e767390 100644
> --- a/arch/mips/include/asm/ftrace.h
> +++ b/arch/mips/include/asm/ftrace.h
> @@ -76,6 +76,8 @@ do { \
>
>
> #ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +
> static inline unsigned long ftrace_call_adjust(unsigned long addr)
> {
> return addr;
> diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
> index 0e23e3a8df6b..f0ef4842d191 100644
> --- a/arch/nds32/kernel/ftrace.c
> +++ b/arch/nds32/kernel/ftrace.c
> @@ -84,11 +84,6 @@ void _ftrace_caller(unsigned long parent_ip)
> /* restore all state needed by the compiler epilogue */
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> static unsigned long gen_sethi_insn(unsigned long addr)
> {
> unsigned long opcode = 0x46000000;
> diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
> index 0a1e75af5382..01581f715737 100644
> --- a/arch/parisc/kernel/ftrace.c
> +++ b/arch/parisc/kernel/ftrace.c
> @@ -94,11 +94,6 @@ int ftrace_disable_ftrace_graph_caller(void)
> #endif
>
> #ifdef CONFIG_DYNAMIC_FTRACE
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> int ftrace_update_ftrace_func(ftrace_func_t func)
> {
> return 0;
> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index debe8c4f7062..d59f67c0225f 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
> };
> #endif /* __ASSEMBLY__ */
>
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +#endif /* CONFIG_DYNAMIC_FTRACE */
> +
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> #define ARCH_SUPPORTS_FTRACE_OPS 1
> #endif
> diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
> index 7f1e5203de88..4716f4cdc038 100644
> --- a/arch/riscv/kernel/ftrace.c
> +++ b/arch/riscv/kernel/ftrace.c
> @@ -154,11 +154,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
>
> return ret;
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif
>
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
> index 0a464d328467..3fd80397ff52 100644
> --- a/arch/s390/kernel/ftrace.c
> +++ b/arch/s390/kernel/ftrace.c
> @@ -262,11 +262,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> return 0;
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> void arch_ftrace_update_code(int command)
> {
> if (ftrace_shared_hotpatch_trampoline(NULL))
> diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c
> index 295c43315bbe..930001bb8c6a 100644
> --- a/arch/sh/kernel/ftrace.c
> +++ b/arch/sh/kernel/ftrace.c
> @@ -252,11 +252,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>
> return ftrace_modify_code(rec->ip, old, new);
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
> index 684b84ce397f..eaead3da8e03 100644
> --- a/arch/sparc/kernel/ftrace.c
> +++ b/arch/sparc/kernel/ftrace.c
> @@ -82,11 +82,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> new = ftrace_call_replace(ip, (unsigned long)func);
> return ftrace_modify_code(ip, old, new);
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 1b3ce3b4a2a2..23d221a9a3cd 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -252,11 +252,6 @@ void arch_ftrace_update_code(int command)
> ftrace_modify_all_code(command);
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> /* Currently only x86_64 supports dynamic trampolines */
> #ifdef CONFIG_X86_64
>
> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> index 832e65f06754..f1eca123d89d 100644
> --- a/include/linux/ftrace.h
> +++ b/include/linux/ftrace.h
> @@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
>
> /* defined in arch */
> extern int ftrace_ip_converted(unsigned long ip);
> -extern int ftrace_dyn_arch_init(void);
> extern void ftrace_replace_code(int enable);
> extern int ftrace_update_ftrace_func(ftrace_func_t func);
> extern void ftrace_caller(void);
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 7efbc8aaf7f6..4c090323198d 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -6846,6 +6846,11 @@ void __init ftrace_free_init_mem(void)
> ftrace_free_mem(NULL, start, end);
> }
>
> +int __init __weak ftrace_dyn_arch_init(void)
> +{
> + return 0;
> +}
> +
> void __init ftrace_init(void)
> {
> extern unsigned long __start_mcount_loc[];
>
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: kernel test robot @ 2021-09-07 0:22 UTC (permalink / raw)
To: Niklas Schnelle, Bjorn Helgaas
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato, llvm,
linux-kernel, Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-4-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 28550 bytes --]
Hi Niklas,
I love your patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on next-20210906]
[cannot apply to pci/next powerpc/next v5.14]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: i386-randconfig-a016-20210906 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6fe2beba7d2a41964af658c8c59dd172683ef739)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/pci/hotplug/acpiphp_glue.c:330:6: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror,-Wimplicit-function-declaration]
if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
^
>> drivers/pci/hotplug/acpiphp_glue.c:505:6: error: implicit declaration of function '__pci_bus_size_bridges' [-Werror,-Wimplicit-function-declaration]
__pci_bus_size_bridges(dev->subordinate,
^
drivers/pci/hotplug/acpiphp_glue.c:505:6: note: did you mean 'pci_bus_size_bridges'?
include/linux/pci.h:1336:6: note: 'pci_bus_size_bridges' declared here
void pci_bus_size_bridges(struct pci_bus *bus);
^
>> drivers/pci/hotplug/acpiphp_glue.c:510:3: error: implicit declaration of function '__pci_bus_assign_resources' [-Werror,-Wimplicit-function-declaration]
__pci_bus_assign_resources(bus, &add_list, NULL);
^
drivers/pci/hotplug/acpiphp_glue.c:510:3: note: did you mean 'pci_bus_assign_resources'?
include/linux/pci.h:1334:6: note: 'pci_bus_assign_resources' declared here
void pci_bus_assign_resources(const struct pci_bus *bus);
^
drivers/pci/hotplug/acpiphp_glue.c:604:8: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror,-Wimplicit-function-declaration]
if (pci_bus_read_dev_vendor_id(slot->bus,
^
drivers/pci/hotplug/acpiphp_glue.c:619:7: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror,-Wimplicit-function-declaration]
if (pci_bus_read_dev_vendor_id(slot->bus,
^
>> drivers/pci/hotplug/acpiphp_glue.c:660:3: error: implicit declaration of function 'pci_dev_set_disconnected' [-Werror,-Wimplicit-function-declaration]
pci_dev_set_disconnected(dev, NULL);
^
>> drivers/pci/hotplug/acpiphp_glue.c:661:7: error: implicit declaration of function 'pci_has_subordinate' [-Werror,-Wimplicit-function-declaration]
if (pci_has_subordinate(dev))
^
7 errors generated.
vim +/pci_bus_read_dev_vendor_id +330 drivers/pci/hotplug/acpiphp_glue.c
4e8662bbd680c5 Kristen Accardi 2006-06-28 217
3799c5a032aefb Rafael J. Wysocki 2014-02-16 218 /**
3799c5a032aefb Rafael J. Wysocki 2014-02-16 219 * acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 220 * @handle: ACPI handle of the object to add a context to.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 221 * @lvl: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 222 * @data: The object's parent ACPIPHP bridge.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 223 * @rv: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 224 */
3799c5a032aefb Rafael J. Wysocki 2014-02-16 225 static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 226 void **rv)
^1da177e4c3f41 Linus Torvalds 2005-04-16 227 {
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 228 struct acpiphp_bridge *bridge = data;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 229 struct acpiphp_context *context;
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 230 struct acpi_device *adev;
^1da177e4c3f41 Linus Torvalds 2005-04-16 231 struct acpiphp_slot *slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 232 struct acpiphp_func *newfunc;
^1da177e4c3f41 Linus Torvalds 2005-04-16 233 acpi_status status = AE_OK;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 234 unsigned long long adr;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 235 int device, function;
e8c331e963c58b Kenji Kaneshige 2008-12-17 236 struct pci_bus *pbus = bridge->pci_bus;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 237 struct pci_dev *pdev = bridge->pci_dev;
3b63aaa70e1ccc Jiang Liu 2013-04-12 238 u32 val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 239
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 240 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 241 if (ACPI_FAILURE(status)) {
f26ca1d699e8b5 Toshi Kani 2013-11-27 242 if (status != AE_NOT_FOUND)
f26ca1d699e8b5 Toshi Kani 2013-11-27 243 acpi_handle_warn(handle,
f26ca1d699e8b5 Toshi Kani 2013-11-27 244 "can't evaluate _ADR (%#x)\n", status);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 245 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 246 }
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 247 if (acpi_bus_get_device(handle, &adev))
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 248 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 249
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 250 device = (adr >> 16) & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 251 function = adr & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 252
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 253 acpi_lock_hp_context();
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 254 context = acpiphp_init_context(adev);
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 255 if (!context) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 256 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 257 acpi_handle_err(handle, "No hotplug context\n");
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 258 return AE_NOT_EXIST;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 259 }
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 260 newfunc = &context->func;
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 261 newfunc->function = function;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 262 newfunc->parent = bridge;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 263 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 264
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 265 /*
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 266 * If this is a dock device, its _EJ0 should be executed by the dock
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 267 * notify handler after calling _DCK.
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 268 */
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 269 if (!is_dock_device(adev) && acpi_has_method(handle, "_EJ0"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 270 newfunc->flags = FUNC_HAS_EJ0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 271
ecd046da57d332 Jiang Liu 2013-06-29 272 if (acpi_has_method(handle, "_STA"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 273 newfunc->flags |= FUNC_HAS_STA;
^1da177e4c3f41 Linus Torvalds 2005-04-16 274
^1da177e4c3f41 Linus Torvalds 2005-04-16 275 /* search for objects that share the same slot */
ad41dd9dd0c8ca Yijing Wang 2013-04-12 276 list_for_each_entry(slot, &bridge->slots, node)
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 277 if (slot->device == device)
ac372338b75064 Rafael J. Wysocki 2013-07-13 278 goto slot_found;
^1da177e4c3f41 Linus Torvalds 2005-04-16 279
f5afe8064f3087 Eric Sesterhenn 2006-02-28 280 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
^1da177e4c3f41 Linus Torvalds 2005-04-16 281 if (!slot) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 282 acpi_lock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 283 acpiphp_put_context(context);
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 284 acpi_unlock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 285 return AE_NO_MEMORY;
^1da177e4c3f41 Linus Torvalds 2005-04-16 286 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 287
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 288 slot->bus = bridge->pci_bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 289 slot->device = device;
^1da177e4c3f41 Linus Torvalds 2005-04-16 290 INIT_LIST_HEAD(&slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 291
ad41dd9dd0c8ca Yijing Wang 2013-04-12 292 list_add_tail(&slot->node, &bridge->slots);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 293
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 294 /*
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 295 * Expose slots to user space for functions that have _EJ0 or _RMV or
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 296 * are located in dock stations. Do not expose them for devices handled
84c8b58ed3addf Mika Westerberg 2018-05-29 297 * by the native PCIe hotplug (PCIeHP) or standard PCI hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 298 * (SHPCHP), because that code is supposed to expose slots to user
84c8b58ed3addf Mika Westerberg 2018-05-29 299 * space in those cases.
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 300 */
3b52b21fa1f44c Rafael J. Wysocki 2014-02-21 301 if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(adev))
84c8b58ed3addf Mika Westerberg 2018-05-29 302 && !(pdev && hotplug_is_native(pdev))) {
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 303 unsigned long long sun;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 304 int retval;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 305
^1da177e4c3f41 Linus Torvalds 2005-04-16 306 bridge->nr_slots++;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 307 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 308 if (ACPI_FAILURE(status))
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 309 sun = bridge->nr_slots;
^1da177e4c3f41 Linus Torvalds 2005-04-16 310
bd950799d9510c Lan Tianyu 2013-09-24 311 pr_debug("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
7342798d0ab850 Rafael J. Wysocki 2013-07-13 312 sun, pci_domain_nr(pbus), pbus->number, device);
ac372338b75064 Rafael J. Wysocki 2013-07-13 313
7342798d0ab850 Rafael J. Wysocki 2013-07-13 314 retval = acpiphp_register_hotplug_slot(slot, sun);
e27da381417038 MUNEDA Takahiro 2006-02-23 315 if (retval) {
1aaac07112f040 Rafael J. Wysocki 2013-08-17 316 slot->slot = NULL;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 317 bridge->nr_slots--;
f46753c5e354b8 Alex Chiang 2008-06-10 318 if (retval == -EBUSY)
227f06470502c4 Ryan Desfosses 2014-04-18 319 pr_warn("Slot %llu already registered by another hotplug driver\n", sun);
f46753c5e354b8 Alex Chiang 2008-06-10 320 else
227f06470502c4 Ryan Desfosses 2014-04-18 321 pr_warn("acpiphp_register_hotplug_slot failed (err code = 0x%x)\n", retval);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 322 }
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 323 /* Even if the slot registration fails, we can still use it. */
e27da381417038 MUNEDA Takahiro 2006-02-23 324 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 325
ac372338b75064 Rafael J. Wysocki 2013-07-13 326 slot_found:
^1da177e4c3f41 Linus Torvalds 2005-04-16 327 newfunc->slot = slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 328 list_add_tail(&newfunc->sibling, &slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 329
3b63aaa70e1ccc Jiang Liu 2013-04-12 @330 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
3b63aaa70e1ccc Jiang Liu 2013-04-12 331 &val, 60*1000))
bc805a55392a7c Rafael J. Wysocki 2013-07-13 332 slot->flags |= SLOT_ENABLED;
^1da177e4c3f41 Linus Torvalds 2005-04-16 333
2e862c51904ddd Rafael J. Wysocki 2013-07-13 334 return AE_OK;
^1da177e4c3f41 Linus Torvalds 2005-04-16 335 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 336
364d5094a43ff2 Rajesh Shah 2005-04-28 337 static void cleanup_bridge(struct acpiphp_bridge *bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 338 {
3d54a3160fb6ba Jiang Liu 2013-04-12 339 struct acpiphp_slot *slot;
3d54a3160fb6ba Jiang Liu 2013-04-12 340 struct acpiphp_func *func;
42f49a6ae5dca9 Rajesh Shah 2005-04-28 341
3d54a3160fb6ba Jiang Liu 2013-04-12 342 list_for_each_entry(slot, &bridge->slots, node) {
3d54a3160fb6ba Jiang Liu 2013-04-12 343 list_for_each_entry(func, &slot->funcs, sibling) {
1a699476e25814 Rafael J. Wysocki 2014-02-06 344 struct acpi_device *adev = func_to_acpi_device(func);
5a3bc573ae32a7 Rafael J. Wysocki 2013-07-13 345
1a699476e25814 Rafael J. Wysocki 2014-02-06 346 acpi_lock_hp_context();
be27b3dcb02335 Rafael J. Wysocki 2014-02-21 347 adev->hp->notify = NULL;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 348 adev->hp->fixup = NULL;
1a699476e25814 Rafael J. Wysocki 2014-02-06 349 acpi_unlock_hp_context();
42f49a6ae5dca9 Rajesh Shah 2005-04-28 350 }
9217a984671e8a Rafael J. Wysocki 2014-01-10 351 slot->flags |= SLOT_IS_GOING_AWAY;
1aaac07112f040 Rafael J. Wysocki 2013-08-17 352 if (slot->slot)
e27da381417038 MUNEDA Takahiro 2006-02-23 353 acpiphp_unregister_hotplug_slot(slot);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 354 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 355
3d54a3160fb6ba Jiang Liu 2013-04-12 356 mutex_lock(&bridge_mutex);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 357 list_del(&bridge->list);
3d54a3160fb6ba Jiang Liu 2013-04-12 358 mutex_unlock(&bridge_mutex);
9217a984671e8a Rafael J. Wysocki 2014-01-10 359
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 360 acpi_lock_hp_context();
9217a984671e8a Rafael J. Wysocki 2014-01-10 361 bridge->is_going_away = true;
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 362 acpi_unlock_hp_context();
^1da177e4c3f41 Linus Torvalds 2005-04-16 363 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 364
15a1ae74879925 Kristen Accardi 2006-02-23 365 /**
26e6c66e47fe7f Randy Dunlap 2007-11-28 366 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
15a1ae74879925 Kristen Accardi 2006-02-23 367 * @bus: bus to start search with
15a1ae74879925 Kristen Accardi 2006-02-23 368 */
15a1ae74879925 Kristen Accardi 2006-02-23 369 static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
15a1ae74879925 Kristen Accardi 2006-02-23 370 {
c6f0d5adc21e2d Yijing Wang 2014-02-13 371 struct pci_bus *tmp;
15a1ae74879925 Kristen Accardi 2006-02-23 372 unsigned char max, n;
15a1ae74879925 Kristen Accardi 2006-02-23 373
15a1ae74879925 Kristen Accardi 2006-02-23 374 /*
15a1ae74879925 Kristen Accardi 2006-02-23 375 * pci_bus_max_busnr will return the highest
15a1ae74879925 Kristen Accardi 2006-02-23 376 * reserved busnr for all these children.
15a1ae74879925 Kristen Accardi 2006-02-23 377 * that is equivalent to the bus->subordinate
15a1ae74879925 Kristen Accardi 2006-02-23 378 * value. We don't want to use the parent's
15a1ae74879925 Kristen Accardi 2006-02-23 379 * bus->subordinate value because it could have
15a1ae74879925 Kristen Accardi 2006-02-23 380 * padding in it.
15a1ae74879925 Kristen Accardi 2006-02-23 381 */
b918c62e086b21 Yinghai Lu 2012-05-17 382 max = bus->busn_res.start;
15a1ae74879925 Kristen Accardi 2006-02-23 383
c6f0d5adc21e2d Yijing Wang 2014-02-13 384 list_for_each_entry(tmp, &bus->children, node) {
c6f0d5adc21e2d Yijing Wang 2014-02-13 385 n = pci_bus_max_busnr(tmp);
15a1ae74879925 Kristen Accardi 2006-02-23 386 if (n > max)
15a1ae74879925 Kristen Accardi 2006-02-23 387 max = n;
15a1ae74879925 Kristen Accardi 2006-02-23 388 }
15a1ae74879925 Kristen Accardi 2006-02-23 389 return max;
15a1ae74879925 Kristen Accardi 2006-02-23 390 }
15a1ae74879925 Kristen Accardi 2006-02-23 391
d06070509147c9 Shaohua Li 2010-02-25 392 static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
d06070509147c9 Shaohua Li 2010-02-25 393 {
d06070509147c9 Shaohua Li 2010-02-25 394 struct acpiphp_func *func;
d06070509147c9 Shaohua Li 2010-02-25 395
d06070509147c9 Shaohua Li 2010-02-25 396 list_for_each_entry(func, &slot->funcs, sibling) {
d06070509147c9 Shaohua Li 2010-02-25 397 /* _REG is optional, we don't care about if there is failure */
6dd10c47e91239 Hans de Goede 2020-05-07 398 acpi_evaluate_reg(func_to_handle(func),
6dd10c47e91239 Hans de Goede 2020-05-07 399 ACPI_ADR_SPACE_PCI_CONFIG,
6dd10c47e91239 Hans de Goede 2020-05-07 400 ACPI_REG_CONNECT);
d06070509147c9 Shaohua Li 2010-02-25 401 }
d06070509147c9 Shaohua Li 2010-02-25 402 }
d06070509147c9 Shaohua Li 2010-02-25 403
1f96a965e30d09 Yinghai Lu 2013-01-21 404 static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
1f96a965e30d09 Yinghai Lu 2013-01-21 405 {
1f96a965e30d09 Yinghai Lu 2013-01-21 406 struct acpiphp_func *func;
1f96a965e30d09 Yinghai Lu 2013-01-21 407
1f96a965e30d09 Yinghai Lu 2013-01-21 408 /* quirk, or pcie could set it already */
1f96a965e30d09 Yinghai Lu 2013-01-21 409 if (dev->is_hotplug_bridge)
1f96a965e30d09 Yinghai Lu 2013-01-21 410 return;
1f96a965e30d09 Yinghai Lu 2013-01-21 411
1f96a965e30d09 Yinghai Lu 2013-01-21 412 list_for_each_entry(func, &slot->funcs, sibling) {
1f96a965e30d09 Yinghai Lu 2013-01-21 413 if (PCI_FUNC(dev->devfn) == func->function) {
1f96a965e30d09 Yinghai Lu 2013-01-21 414 dev->is_hotplug_bridge = 1;
1f96a965e30d09 Yinghai Lu 2013-01-21 415 break;
1f96a965e30d09 Yinghai Lu 2013-01-21 416 }
1f96a965e30d09 Yinghai Lu 2013-01-21 417 }
1f96a965e30d09 Yinghai Lu 2013-01-21 418 }
3b63aaa70e1ccc Jiang Liu 2013-04-12 419
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 420 static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 421 {
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 422 struct acpiphp_func *func;
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 423
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 424 list_for_each_entry(func, &slot->funcs, sibling) {
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 425 struct acpi_device *adev = func_to_acpi_device(func);
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 426
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 427 acpi_bus_scan(adev->handle);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 428 if (acpi_device_enumerated(adev))
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 429 acpi_device_set_power(adev, ACPI_STATE_D0);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 430 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 431 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 432 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 433
84c8b58ed3addf Mika Westerberg 2018-05-29 434 static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
84c8b58ed3addf Mika Westerberg 2018-05-29 435 {
84c8b58ed3addf Mika Westerberg 2018-05-29 436 struct pci_bus *bus = bridge->subordinate;
84c8b58ed3addf Mika Westerberg 2018-05-29 437 struct pci_dev *dev;
84c8b58ed3addf Mika Westerberg 2018-05-29 438 int max;
84c8b58ed3addf Mika Westerberg 2018-05-29 439
84c8b58ed3addf Mika Westerberg 2018-05-29 440 if (!bus)
84c8b58ed3addf Mika Westerberg 2018-05-29 441 return;
84c8b58ed3addf Mika Westerberg 2018-05-29 442
84c8b58ed3addf Mika Westerberg 2018-05-29 443 max = bus->busn_res.start;
84c8b58ed3addf Mika Westerberg 2018-05-29 444 /* Scan already configured non-hotplug bridges */
84c8b58ed3addf Mika Westerberg 2018-05-29 445 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 446 if (!hotplug_is_native(dev))
84c8b58ed3addf Mika Westerberg 2018-05-29 447 max = pci_scan_bridge(bus, dev, max, 0);
84c8b58ed3addf Mika Westerberg 2018-05-29 448 }
84c8b58ed3addf Mika Westerberg 2018-05-29 449
84c8b58ed3addf Mika Westerberg 2018-05-29 450 /* Scan non-hotplug bridges that need to be reconfigured */
84c8b58ed3addf Mika Westerberg 2018-05-29 451 for_each_pci_bridge(dev, bus) {
77adf9355304f8 Mika Westerberg 2019-10-30 452 if (hotplug_is_native(dev))
77adf9355304f8 Mika Westerberg 2019-10-30 453 continue;
77adf9355304f8 Mika Westerberg 2019-10-30 454
84c8b58ed3addf Mika Westerberg 2018-05-29 455 max = pci_scan_bridge(bus, dev, max, 1);
77adf9355304f8 Mika Westerberg 2019-10-30 456 if (dev->subordinate) {
77adf9355304f8 Mika Westerberg 2019-10-30 457 pcibios_resource_survey_bus(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 458 pci_bus_size_bridges(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 459 pci_bus_assign_resources(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 460 }
84c8b58ed3addf Mika Westerberg 2018-05-29 461 }
84c8b58ed3addf Mika Westerberg 2018-05-29 462 }
84c8b58ed3addf Mika Westerberg 2018-05-29 463
^1da177e4c3f41 Linus Torvalds 2005-04-16 464 /**
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 465 * enable_slot - enable, configure a slot
^1da177e4c3f41 Linus Torvalds 2005-04-16 466 * @slot: slot to be enabled
f188b99f0b2d33 Mika Westerberg 2018-09-26 467 * @bridge: true if enable is for the whole bridge (not a single slot)
^1da177e4c3f41 Linus Torvalds 2005-04-16 468 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 469 * This function should be called per *physical slot*,
^1da177e4c3f41 Linus Torvalds 2005-04-16 470 * not per each slot object in ACPI namespace.
^1da177e4c3f41 Linus Torvalds 2005-04-16 471 */
f188b99f0b2d33 Mika Westerberg 2018-09-26 472 static void enable_slot(struct acpiphp_slot *slot, bool bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 473 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 474 struct pci_dev *dev;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 475 struct pci_bus *bus = slot->bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 476 struct acpiphp_func *func;
84c8b58ed3addf Mika Westerberg 2018-05-29 477
f188b99f0b2d33 Mika Westerberg 2018-09-26 478 if (bridge && bus->self && hotplug_is_native(bus->self)) {
84c8b58ed3addf Mika Westerberg 2018-05-29 479 /*
84c8b58ed3addf Mika Westerberg 2018-05-29 480 * If native hotplug is used, it will take care of hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 481 * slot management and resource allocation for hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 482 * bridges. However, ACPI hotplug may still be used for
84c8b58ed3addf Mika Westerberg 2018-05-29 483 * non-hotplug bridges to bring in additional devices such
84c8b58ed3addf Mika Westerberg 2018-05-29 484 * as a Thunderbolt host controller.
84c8b58ed3addf Mika Westerberg 2018-05-29 485 */
84c8b58ed3addf Mika Westerberg 2018-05-29 486 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 487 if (PCI_SLOT(dev->devfn) == slot->device)
84c8b58ed3addf Mika Westerberg 2018-05-29 488 acpiphp_native_scan_bridge(dev);
84c8b58ed3addf Mika Westerberg 2018-05-29 489 }
84c8b58ed3addf Mika Westerberg 2018-05-29 490 } else {
d66ecb7220a70e Jiang Liu 2013-06-23 491 LIST_HEAD(add_list);
84c8b58ed3addf Mika Westerberg 2018-05-29 492 int max, pass;
^1da177e4c3f41 Linus Torvalds 2005-04-16 493
ab1225901da2d4 Mika Westerberg 2013-10-30 494 acpiphp_rescan_slot(slot);
15a1ae74879925 Kristen Accardi 2006-02-23 495 max = acpiphp_max_busnr(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 496 for (pass = 0; pass < 2; pass++) {
24a0c654d7d606 Andy Shevchenko 2017-10-20 497 for_each_pci_bridge(dev, bus) {
42f49a6ae5dca9 Rajesh Shah 2005-04-28 498 if (PCI_SLOT(dev->devfn) != slot->device)
42f49a6ae5dca9 Rajesh Shah 2005-04-28 499 continue;
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 500
42f49a6ae5dca9 Rajesh Shah 2005-04-28 501 max = pci_scan_bridge(bus, dev, max, pass);
1f96a965e30d09 Yinghai Lu 2013-01-21 502 if (pass && dev->subordinate) {
1f96a965e30d09 Yinghai Lu 2013-01-21 503 check_hotplug_bridge(slot, dev);
d66ecb7220a70e Jiang Liu 2013-06-23 504 pcibios_resource_survey_bus(dev->subordinate);
84c8b58ed3addf Mika Westerberg 2018-05-29 @505 __pci_bus_size_bridges(dev->subordinate,
84c8b58ed3addf Mika Westerberg 2018-05-29 506 &add_list);
c64b5eead93f9d Kristen Accardi 2005-12-14 507 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 508 }
1f96a965e30d09 Yinghai Lu 2013-01-21 509 }
d66ecb7220a70e Jiang Liu 2013-06-23 @510 __pci_bus_assign_resources(bus, &add_list, NULL);
84c8b58ed3addf Mika Westerberg 2018-05-29 511 }
2dc41281b1d117 Rafael J. Wysocki 2013-09-06 512
8e5dce35221850 Kristen Accardi 2005-10-18 513 acpiphp_sanitize_bus(bus);
81ee57326c9ca6 Bjorn Helgaas 2014-08-28 514 pcie_bus_configure_settings(bus);
d06070509147c9 Shaohua Li 2010-02-25 515 acpiphp_set_acpi_region(slot);
69643e4829c5cd Ian Campbell 2011-05-11 516
69643e4829c5cd Ian Campbell 2011-05-11 517 list_for_each_entry(dev, &bus->devices, bus_list) {
69643e4829c5cd Ian Campbell 2011-05-11 518 /* Assume that newly added devices are powered on already. */
44bda4b7d26e9f Hari Vyas 2018-07-03 519 if (!pci_dev_is_added(dev))
69643e4829c5cd Ian Campbell 2011-05-11 520 dev->current_state = PCI_D0;
69643e4829c5cd Ian Campbell 2011-05-11 521 }
69643e4829c5cd Ian Campbell 2011-05-11 522
42f49a6ae5dca9 Rajesh Shah 2005-04-28 523 pci_bus_add_devices(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 524
f382a086f3129e Amos Kong 2011-11-25 525 slot->flags |= SLOT_ENABLED;
58c08628c4fe66 Alex Chiang 2009-10-26 526 list_for_each_entry(func, &slot->funcs, sibling) {
9d911d7903926a Alex Chiang 2009-05-21 527 dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
^1da177e4c3f41 Linus Torvalds 2005-04-16 528 func->function));
f382a086f3129e Amos Kong 2011-11-25 529 if (!dev) {
f382a086f3129e Amos Kong 2011-11-25 530 /* Do not set SLOT_ENABLED flag if some funcs
f382a086f3129e Amos Kong 2011-11-25 531 are not added. */
9337a493623d59 Mika Westerberg 2018-05-24 532 slot->flags &= ~SLOT_ENABLED;
551bcb75b3d9f2 MUNEDA Takahiro 2006-03-22 533 continue;
f382a086f3129e Amos Kong 2011-11-25 534 }
3bbfd319034ddc Feilong Lin 2021-03-25 535 pci_dev_put(dev);
^1da177e4c3f41 Linus Torvalds 2005-04-16 536 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 537 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 538
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 42097 bytes --]
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: kernel test robot @ 2021-09-07 0:25 UTC (permalink / raw)
To: Niklas Schnelle, Bjorn Helgaas
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato,
linux-kernel, Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-4-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 27718 bytes --]
Hi Niklas,
I love your patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on next-20210906]
[cannot apply to pci/next powerpc/next v5.14]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
# save the attached .config to linux build tree
make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/pci/hotplug/acpiphp_glue.c: In function 'acpiphp_add_context':
>> drivers/pci/hotplug/acpiphp_glue.c:330:6: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror=implicit-function-declaration]
330 | if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/hotplug/acpiphp_glue.c: In function 'enable_slot':
>> drivers/pci/hotplug/acpiphp_glue.c:505:6: error: implicit declaration of function '__pci_bus_size_bridges'; did you mean 'pci_bus_size_bridges'? [-Werror=implicit-function-declaration]
505 | __pci_bus_size_bridges(dev->subordinate,
| ^~~~~~~~~~~~~~~~~~~~~~
| pci_bus_size_bridges
>> drivers/pci/hotplug/acpiphp_glue.c:510:3: error: implicit declaration of function '__pci_bus_assign_resources'; did you mean 'pci_bus_assign_resources'? [-Werror=implicit-function-declaration]
510 | __pci_bus_assign_resources(bus, &add_list, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| pci_bus_assign_resources
drivers/pci/hotplug/acpiphp_glue.c: In function 'trim_stale_devices':
>> drivers/pci/hotplug/acpiphp_glue.c:660:3: error: implicit declaration of function 'pci_dev_set_disconnected' [-Werror=implicit-function-declaration]
660 | pci_dev_set_disconnected(dev, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/pci/hotplug/acpiphp_glue.c:661:7: error: implicit declaration of function 'pci_has_subordinate' [-Werror=implicit-function-declaration]
661 | if (pci_has_subordinate(dev))
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/pci_bus_read_dev_vendor_id +330 drivers/pci/hotplug/acpiphp_glue.c
4e8662bbd680c5 Kristen Accardi 2006-06-28 217
3799c5a032aefb Rafael J. Wysocki 2014-02-16 218 /**
3799c5a032aefb Rafael J. Wysocki 2014-02-16 219 * acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 220 * @handle: ACPI handle of the object to add a context to.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 221 * @lvl: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 222 * @data: The object's parent ACPIPHP bridge.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 223 * @rv: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 224 */
3799c5a032aefb Rafael J. Wysocki 2014-02-16 225 static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 226 void **rv)
^1da177e4c3f41 Linus Torvalds 2005-04-16 227 {
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 228 struct acpiphp_bridge *bridge = data;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 229 struct acpiphp_context *context;
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 230 struct acpi_device *adev;
^1da177e4c3f41 Linus Torvalds 2005-04-16 231 struct acpiphp_slot *slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 232 struct acpiphp_func *newfunc;
^1da177e4c3f41 Linus Torvalds 2005-04-16 233 acpi_status status = AE_OK;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 234 unsigned long long adr;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 235 int device, function;
e8c331e963c58b Kenji Kaneshige 2008-12-17 236 struct pci_bus *pbus = bridge->pci_bus;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 237 struct pci_dev *pdev = bridge->pci_dev;
3b63aaa70e1ccc Jiang Liu 2013-04-12 238 u32 val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 239
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 240 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 241 if (ACPI_FAILURE(status)) {
f26ca1d699e8b5 Toshi Kani 2013-11-27 242 if (status != AE_NOT_FOUND)
f26ca1d699e8b5 Toshi Kani 2013-11-27 243 acpi_handle_warn(handle,
f26ca1d699e8b5 Toshi Kani 2013-11-27 244 "can't evaluate _ADR (%#x)\n", status);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 245 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 246 }
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 247 if (acpi_bus_get_device(handle, &adev))
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 248 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 249
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 250 device = (adr >> 16) & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 251 function = adr & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 252
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 253 acpi_lock_hp_context();
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 254 context = acpiphp_init_context(adev);
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 255 if (!context) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 256 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 257 acpi_handle_err(handle, "No hotplug context\n");
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 258 return AE_NOT_EXIST;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 259 }
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 260 newfunc = &context->func;
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 261 newfunc->function = function;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 262 newfunc->parent = bridge;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 263 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 264
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 265 /*
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 266 * If this is a dock device, its _EJ0 should be executed by the dock
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 267 * notify handler after calling _DCK.
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 268 */
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 269 if (!is_dock_device(adev) && acpi_has_method(handle, "_EJ0"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 270 newfunc->flags = FUNC_HAS_EJ0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 271
ecd046da57d332 Jiang Liu 2013-06-29 272 if (acpi_has_method(handle, "_STA"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 273 newfunc->flags |= FUNC_HAS_STA;
^1da177e4c3f41 Linus Torvalds 2005-04-16 274
^1da177e4c3f41 Linus Torvalds 2005-04-16 275 /* search for objects that share the same slot */
ad41dd9dd0c8ca Yijing Wang 2013-04-12 276 list_for_each_entry(slot, &bridge->slots, node)
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 277 if (slot->device == device)
ac372338b75064 Rafael J. Wysocki 2013-07-13 278 goto slot_found;
^1da177e4c3f41 Linus Torvalds 2005-04-16 279
f5afe8064f3087 Eric Sesterhenn 2006-02-28 280 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
^1da177e4c3f41 Linus Torvalds 2005-04-16 281 if (!slot) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 282 acpi_lock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 283 acpiphp_put_context(context);
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 284 acpi_unlock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 285 return AE_NO_MEMORY;
^1da177e4c3f41 Linus Torvalds 2005-04-16 286 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 287
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 288 slot->bus = bridge->pci_bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 289 slot->device = device;
^1da177e4c3f41 Linus Torvalds 2005-04-16 290 INIT_LIST_HEAD(&slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 291
ad41dd9dd0c8ca Yijing Wang 2013-04-12 292 list_add_tail(&slot->node, &bridge->slots);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 293
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 294 /*
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 295 * Expose slots to user space for functions that have _EJ0 or _RMV or
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 296 * are located in dock stations. Do not expose them for devices handled
84c8b58ed3addf Mika Westerberg 2018-05-29 297 * by the native PCIe hotplug (PCIeHP) or standard PCI hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 298 * (SHPCHP), because that code is supposed to expose slots to user
84c8b58ed3addf Mika Westerberg 2018-05-29 299 * space in those cases.
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 300 */
3b52b21fa1f44c Rafael J. Wysocki 2014-02-21 301 if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(adev))
84c8b58ed3addf Mika Westerberg 2018-05-29 302 && !(pdev && hotplug_is_native(pdev))) {
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 303 unsigned long long sun;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 304 int retval;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 305
^1da177e4c3f41 Linus Torvalds 2005-04-16 306 bridge->nr_slots++;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 307 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 308 if (ACPI_FAILURE(status))
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 309 sun = bridge->nr_slots;
^1da177e4c3f41 Linus Torvalds 2005-04-16 310
bd950799d9510c Lan Tianyu 2013-09-24 311 pr_debug("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
7342798d0ab850 Rafael J. Wysocki 2013-07-13 312 sun, pci_domain_nr(pbus), pbus->number, device);
ac372338b75064 Rafael J. Wysocki 2013-07-13 313
7342798d0ab850 Rafael J. Wysocki 2013-07-13 314 retval = acpiphp_register_hotplug_slot(slot, sun);
e27da381417038 MUNEDA Takahiro 2006-02-23 315 if (retval) {
1aaac07112f040 Rafael J. Wysocki 2013-08-17 316 slot->slot = NULL;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 317 bridge->nr_slots--;
f46753c5e354b8 Alex Chiang 2008-06-10 318 if (retval == -EBUSY)
227f06470502c4 Ryan Desfosses 2014-04-18 319 pr_warn("Slot %llu already registered by another hotplug driver\n", sun);
f46753c5e354b8 Alex Chiang 2008-06-10 320 else
227f06470502c4 Ryan Desfosses 2014-04-18 321 pr_warn("acpiphp_register_hotplug_slot failed (err code = 0x%x)\n", retval);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 322 }
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 323 /* Even if the slot registration fails, we can still use it. */
e27da381417038 MUNEDA Takahiro 2006-02-23 324 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 325
ac372338b75064 Rafael J. Wysocki 2013-07-13 326 slot_found:
^1da177e4c3f41 Linus Torvalds 2005-04-16 327 newfunc->slot = slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 328 list_add_tail(&newfunc->sibling, &slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 329
3b63aaa70e1ccc Jiang Liu 2013-04-12 @330 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
3b63aaa70e1ccc Jiang Liu 2013-04-12 331 &val, 60*1000))
bc805a55392a7c Rafael J. Wysocki 2013-07-13 332 slot->flags |= SLOT_ENABLED;
^1da177e4c3f41 Linus Torvalds 2005-04-16 333
2e862c51904ddd Rafael J. Wysocki 2013-07-13 334 return AE_OK;
^1da177e4c3f41 Linus Torvalds 2005-04-16 335 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 336
364d5094a43ff2 Rajesh Shah 2005-04-28 337 static void cleanup_bridge(struct acpiphp_bridge *bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 338 {
3d54a3160fb6ba Jiang Liu 2013-04-12 339 struct acpiphp_slot *slot;
3d54a3160fb6ba Jiang Liu 2013-04-12 340 struct acpiphp_func *func;
42f49a6ae5dca9 Rajesh Shah 2005-04-28 341
3d54a3160fb6ba Jiang Liu 2013-04-12 342 list_for_each_entry(slot, &bridge->slots, node) {
3d54a3160fb6ba Jiang Liu 2013-04-12 343 list_for_each_entry(func, &slot->funcs, sibling) {
1a699476e25814 Rafael J. Wysocki 2014-02-06 344 struct acpi_device *adev = func_to_acpi_device(func);
5a3bc573ae32a7 Rafael J. Wysocki 2013-07-13 345
1a699476e25814 Rafael J. Wysocki 2014-02-06 346 acpi_lock_hp_context();
be27b3dcb02335 Rafael J. Wysocki 2014-02-21 347 adev->hp->notify = NULL;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 348 adev->hp->fixup = NULL;
1a699476e25814 Rafael J. Wysocki 2014-02-06 349 acpi_unlock_hp_context();
42f49a6ae5dca9 Rajesh Shah 2005-04-28 350 }
9217a984671e8a Rafael J. Wysocki 2014-01-10 351 slot->flags |= SLOT_IS_GOING_AWAY;
1aaac07112f040 Rafael J. Wysocki 2013-08-17 352 if (slot->slot)
e27da381417038 MUNEDA Takahiro 2006-02-23 353 acpiphp_unregister_hotplug_slot(slot);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 354 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 355
3d54a3160fb6ba Jiang Liu 2013-04-12 356 mutex_lock(&bridge_mutex);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 357 list_del(&bridge->list);
3d54a3160fb6ba Jiang Liu 2013-04-12 358 mutex_unlock(&bridge_mutex);
9217a984671e8a Rafael J. Wysocki 2014-01-10 359
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 360 acpi_lock_hp_context();
9217a984671e8a Rafael J. Wysocki 2014-01-10 361 bridge->is_going_away = true;
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 362 acpi_unlock_hp_context();
^1da177e4c3f41 Linus Torvalds 2005-04-16 363 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 364
15a1ae74879925 Kristen Accardi 2006-02-23 365 /**
26e6c66e47fe7f Randy Dunlap 2007-11-28 366 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
15a1ae74879925 Kristen Accardi 2006-02-23 367 * @bus: bus to start search with
15a1ae74879925 Kristen Accardi 2006-02-23 368 */
15a1ae74879925 Kristen Accardi 2006-02-23 369 static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
15a1ae74879925 Kristen Accardi 2006-02-23 370 {
c6f0d5adc21e2d Yijing Wang 2014-02-13 371 struct pci_bus *tmp;
15a1ae74879925 Kristen Accardi 2006-02-23 372 unsigned char max, n;
15a1ae74879925 Kristen Accardi 2006-02-23 373
15a1ae74879925 Kristen Accardi 2006-02-23 374 /*
15a1ae74879925 Kristen Accardi 2006-02-23 375 * pci_bus_max_busnr will return the highest
15a1ae74879925 Kristen Accardi 2006-02-23 376 * reserved busnr for all these children.
15a1ae74879925 Kristen Accardi 2006-02-23 377 * that is equivalent to the bus->subordinate
15a1ae74879925 Kristen Accardi 2006-02-23 378 * value. We don't want to use the parent's
15a1ae74879925 Kristen Accardi 2006-02-23 379 * bus->subordinate value because it could have
15a1ae74879925 Kristen Accardi 2006-02-23 380 * padding in it.
15a1ae74879925 Kristen Accardi 2006-02-23 381 */
b918c62e086b21 Yinghai Lu 2012-05-17 382 max = bus->busn_res.start;
15a1ae74879925 Kristen Accardi 2006-02-23 383
c6f0d5adc21e2d Yijing Wang 2014-02-13 384 list_for_each_entry(tmp, &bus->children, node) {
c6f0d5adc21e2d Yijing Wang 2014-02-13 385 n = pci_bus_max_busnr(tmp);
15a1ae74879925 Kristen Accardi 2006-02-23 386 if (n > max)
15a1ae74879925 Kristen Accardi 2006-02-23 387 max = n;
15a1ae74879925 Kristen Accardi 2006-02-23 388 }
15a1ae74879925 Kristen Accardi 2006-02-23 389 return max;
15a1ae74879925 Kristen Accardi 2006-02-23 390 }
15a1ae74879925 Kristen Accardi 2006-02-23 391
d06070509147c9 Shaohua Li 2010-02-25 392 static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
d06070509147c9 Shaohua Li 2010-02-25 393 {
d06070509147c9 Shaohua Li 2010-02-25 394 struct acpiphp_func *func;
d06070509147c9 Shaohua Li 2010-02-25 395
d06070509147c9 Shaohua Li 2010-02-25 396 list_for_each_entry(func, &slot->funcs, sibling) {
d06070509147c9 Shaohua Li 2010-02-25 397 /* _REG is optional, we don't care about if there is failure */
6dd10c47e91239 Hans de Goede 2020-05-07 398 acpi_evaluate_reg(func_to_handle(func),
6dd10c47e91239 Hans de Goede 2020-05-07 399 ACPI_ADR_SPACE_PCI_CONFIG,
6dd10c47e91239 Hans de Goede 2020-05-07 400 ACPI_REG_CONNECT);
d06070509147c9 Shaohua Li 2010-02-25 401 }
d06070509147c9 Shaohua Li 2010-02-25 402 }
d06070509147c9 Shaohua Li 2010-02-25 403
1f96a965e30d09 Yinghai Lu 2013-01-21 404 static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
1f96a965e30d09 Yinghai Lu 2013-01-21 405 {
1f96a965e30d09 Yinghai Lu 2013-01-21 406 struct acpiphp_func *func;
1f96a965e30d09 Yinghai Lu 2013-01-21 407
1f96a965e30d09 Yinghai Lu 2013-01-21 408 /* quirk, or pcie could set it already */
1f96a965e30d09 Yinghai Lu 2013-01-21 409 if (dev->is_hotplug_bridge)
1f96a965e30d09 Yinghai Lu 2013-01-21 410 return;
1f96a965e30d09 Yinghai Lu 2013-01-21 411
1f96a965e30d09 Yinghai Lu 2013-01-21 412 list_for_each_entry(func, &slot->funcs, sibling) {
1f96a965e30d09 Yinghai Lu 2013-01-21 413 if (PCI_FUNC(dev->devfn) == func->function) {
1f96a965e30d09 Yinghai Lu 2013-01-21 414 dev->is_hotplug_bridge = 1;
1f96a965e30d09 Yinghai Lu 2013-01-21 415 break;
1f96a965e30d09 Yinghai Lu 2013-01-21 416 }
1f96a965e30d09 Yinghai Lu 2013-01-21 417 }
1f96a965e30d09 Yinghai Lu 2013-01-21 418 }
3b63aaa70e1ccc Jiang Liu 2013-04-12 419
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 420 static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 421 {
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 422 struct acpiphp_func *func;
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 423
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 424 list_for_each_entry(func, &slot->funcs, sibling) {
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 425 struct acpi_device *adev = func_to_acpi_device(func);
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 426
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 427 acpi_bus_scan(adev->handle);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 428 if (acpi_device_enumerated(adev))
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 429 acpi_device_set_power(adev, ACPI_STATE_D0);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 430 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 431 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 432 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 433
84c8b58ed3addf Mika Westerberg 2018-05-29 434 static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
84c8b58ed3addf Mika Westerberg 2018-05-29 435 {
84c8b58ed3addf Mika Westerberg 2018-05-29 436 struct pci_bus *bus = bridge->subordinate;
84c8b58ed3addf Mika Westerberg 2018-05-29 437 struct pci_dev *dev;
84c8b58ed3addf Mika Westerberg 2018-05-29 438 int max;
84c8b58ed3addf Mika Westerberg 2018-05-29 439
84c8b58ed3addf Mika Westerberg 2018-05-29 440 if (!bus)
84c8b58ed3addf Mika Westerberg 2018-05-29 441 return;
84c8b58ed3addf Mika Westerberg 2018-05-29 442
84c8b58ed3addf Mika Westerberg 2018-05-29 443 max = bus->busn_res.start;
84c8b58ed3addf Mika Westerberg 2018-05-29 444 /* Scan already configured non-hotplug bridges */
84c8b58ed3addf Mika Westerberg 2018-05-29 445 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 446 if (!hotplug_is_native(dev))
84c8b58ed3addf Mika Westerberg 2018-05-29 447 max = pci_scan_bridge(bus, dev, max, 0);
84c8b58ed3addf Mika Westerberg 2018-05-29 448 }
84c8b58ed3addf Mika Westerberg 2018-05-29 449
84c8b58ed3addf Mika Westerberg 2018-05-29 450 /* Scan non-hotplug bridges that need to be reconfigured */
84c8b58ed3addf Mika Westerberg 2018-05-29 451 for_each_pci_bridge(dev, bus) {
77adf9355304f8 Mika Westerberg 2019-10-30 452 if (hotplug_is_native(dev))
77adf9355304f8 Mika Westerberg 2019-10-30 453 continue;
77adf9355304f8 Mika Westerberg 2019-10-30 454
84c8b58ed3addf Mika Westerberg 2018-05-29 455 max = pci_scan_bridge(bus, dev, max, 1);
77adf9355304f8 Mika Westerberg 2019-10-30 456 if (dev->subordinate) {
77adf9355304f8 Mika Westerberg 2019-10-30 457 pcibios_resource_survey_bus(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 458 pci_bus_size_bridges(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 459 pci_bus_assign_resources(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 460 }
84c8b58ed3addf Mika Westerberg 2018-05-29 461 }
84c8b58ed3addf Mika Westerberg 2018-05-29 462 }
84c8b58ed3addf Mika Westerberg 2018-05-29 463
^1da177e4c3f41 Linus Torvalds 2005-04-16 464 /**
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 465 * enable_slot - enable, configure a slot
^1da177e4c3f41 Linus Torvalds 2005-04-16 466 * @slot: slot to be enabled
f188b99f0b2d33 Mika Westerberg 2018-09-26 467 * @bridge: true if enable is for the whole bridge (not a single slot)
^1da177e4c3f41 Linus Torvalds 2005-04-16 468 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 469 * This function should be called per *physical slot*,
^1da177e4c3f41 Linus Torvalds 2005-04-16 470 * not per each slot object in ACPI namespace.
^1da177e4c3f41 Linus Torvalds 2005-04-16 471 */
f188b99f0b2d33 Mika Westerberg 2018-09-26 472 static void enable_slot(struct acpiphp_slot *slot, bool bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 473 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 474 struct pci_dev *dev;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 475 struct pci_bus *bus = slot->bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 476 struct acpiphp_func *func;
84c8b58ed3addf Mika Westerberg 2018-05-29 477
f188b99f0b2d33 Mika Westerberg 2018-09-26 478 if (bridge && bus->self && hotplug_is_native(bus->self)) {
84c8b58ed3addf Mika Westerberg 2018-05-29 479 /*
84c8b58ed3addf Mika Westerberg 2018-05-29 480 * If native hotplug is used, it will take care of hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 481 * slot management and resource allocation for hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 482 * bridges. However, ACPI hotplug may still be used for
84c8b58ed3addf Mika Westerberg 2018-05-29 483 * non-hotplug bridges to bring in additional devices such
84c8b58ed3addf Mika Westerberg 2018-05-29 484 * as a Thunderbolt host controller.
84c8b58ed3addf Mika Westerberg 2018-05-29 485 */
84c8b58ed3addf Mika Westerberg 2018-05-29 486 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 487 if (PCI_SLOT(dev->devfn) == slot->device)
84c8b58ed3addf Mika Westerberg 2018-05-29 488 acpiphp_native_scan_bridge(dev);
84c8b58ed3addf Mika Westerberg 2018-05-29 489 }
84c8b58ed3addf Mika Westerberg 2018-05-29 490 } else {
d66ecb7220a70e Jiang Liu 2013-06-23 491 LIST_HEAD(add_list);
84c8b58ed3addf Mika Westerberg 2018-05-29 492 int max, pass;
^1da177e4c3f41 Linus Torvalds 2005-04-16 493
ab1225901da2d4 Mika Westerberg 2013-10-30 494 acpiphp_rescan_slot(slot);
15a1ae74879925 Kristen Accardi 2006-02-23 495 max = acpiphp_max_busnr(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 496 for (pass = 0; pass < 2; pass++) {
24a0c654d7d606 Andy Shevchenko 2017-10-20 497 for_each_pci_bridge(dev, bus) {
42f49a6ae5dca9 Rajesh Shah 2005-04-28 498 if (PCI_SLOT(dev->devfn) != slot->device)
42f49a6ae5dca9 Rajesh Shah 2005-04-28 499 continue;
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 500
42f49a6ae5dca9 Rajesh Shah 2005-04-28 501 max = pci_scan_bridge(bus, dev, max, pass);
1f96a965e30d09 Yinghai Lu 2013-01-21 502 if (pass && dev->subordinate) {
1f96a965e30d09 Yinghai Lu 2013-01-21 503 check_hotplug_bridge(slot, dev);
d66ecb7220a70e Jiang Liu 2013-06-23 504 pcibios_resource_survey_bus(dev->subordinate);
84c8b58ed3addf Mika Westerberg 2018-05-29 @505 __pci_bus_size_bridges(dev->subordinate,
84c8b58ed3addf Mika Westerberg 2018-05-29 506 &add_list);
c64b5eead93f9d Kristen Accardi 2005-12-14 507 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 508 }
1f96a965e30d09 Yinghai Lu 2013-01-21 509 }
d66ecb7220a70e Jiang Liu 2013-06-23 @510 __pci_bus_assign_resources(bus, &add_list, NULL);
84c8b58ed3addf Mika Westerberg 2018-05-29 511 }
2dc41281b1d117 Rafael J. Wysocki 2013-09-06 512
8e5dce35221850 Kristen Accardi 2005-10-18 513 acpiphp_sanitize_bus(bus);
81ee57326c9ca6 Bjorn Helgaas 2014-08-28 514 pcie_bus_configure_settings(bus);
d06070509147c9 Shaohua Li 2010-02-25 515 acpiphp_set_acpi_region(slot);
69643e4829c5cd Ian Campbell 2011-05-11 516
69643e4829c5cd Ian Campbell 2011-05-11 517 list_for_each_entry(dev, &bus->devices, bus_list) {
69643e4829c5cd Ian Campbell 2011-05-11 518 /* Assume that newly added devices are powered on already. */
44bda4b7d26e9f Hari Vyas 2018-07-03 519 if (!pci_dev_is_added(dev))
69643e4829c5cd Ian Campbell 2011-05-11 520 dev->current_state = PCI_D0;
69643e4829c5cd Ian Campbell 2011-05-11 521 }
69643e4829c5cd Ian Campbell 2011-05-11 522
42f49a6ae5dca9 Rajesh Shah 2005-04-28 523 pci_bus_add_devices(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 524
f382a086f3129e Amos Kong 2011-11-25 525 slot->flags |= SLOT_ENABLED;
58c08628c4fe66 Alex Chiang 2009-10-26 526 list_for_each_entry(func, &slot->funcs, sibling) {
9d911d7903926a Alex Chiang 2009-05-21 527 dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
^1da177e4c3f41 Linus Torvalds 2005-04-16 528 func->function));
f382a086f3129e Amos Kong 2011-11-25 529 if (!dev) {
f382a086f3129e Amos Kong 2011-11-25 530 /* Do not set SLOT_ENABLED flag if some funcs
f382a086f3129e Amos Kong 2011-11-25 531 are not added. */
9337a493623d59 Mika Westerberg 2018-05-24 532 slot->flags &= ~SLOT_ENABLED;
551bcb75b3d9f2 MUNEDA Takahiro 2006-03-22 533 continue;
f382a086f3129e Amos Kong 2011-11-25 534 }
3bbfd319034ddc Feilong Lin 2021-03-25 535 pci_dev_put(dev);
^1da177e4c3f41 Linus Torvalds 2005-04-16 536 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 537 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 538
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 65111 bytes --]
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Oliver O'Halloran @ 2021-09-07 2:04 UTC (permalink / raw)
To: Niklas Schnelle
Cc: linux-s390, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Linas Vepstas,
linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
On Mon, Sep 6, 2021 at 7:49 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
>
> Patch 3 I already sent separately resulting in the discussion below but without
> a final conclusion.
>
> https://lore.kernel.org/lkml/20210720150145.640727-1-schnelle@linux.ibm.com/
>
> I believe even though there were some doubts about the use of
> pci_dev_is_added() by arch code the existing uses as well as the use in the
> final patch of this series warrant this export.
The use of pci_dev_is_added() in arch/powerpc was because in the past
pci_bus_add_device() could be called before pci_device_add(). That was
fixed a while ago so It should be safe to remove those calls now.
> Patch 4 "PCI: Export pci_dev_lock()" is basically an extension to commit
> e3a9b1212b9d ("PCI: Export pci_dev_trylock() and pci_dev_unlock()") which
> already exported pci_dev_trylock(). In the final patch we make use of
> pci_dev_lock() to wait for any other exclusive uses of the pdev to be finished
> before starting recovery.
Hmm, I noticed the EEH
(arch/powerpc/kernel/eeh_driver.c:eeh_pe_report_edev()) and the
generic PCIe error recovery code (see
drivers/pci/pcie/err.c:report_error_detected()) only call
device_lock() before entering the driver's error handling callbacks. I
wonder if they should be using pci_dev_lock() instead. The only real
difference is that pci_dev_lock() will also block user space from
accessing the device's config space while error recovery is in
progress which seems sensible enough.
^ permalink raw reply
* Re: [PATCH for-5.15 0/5] ASoC: fsl: register platform component before registering cpu dai
From: Shengjiu Wang @ 2021-09-07 2:43 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel, Timur Tabi, Xiubo Li, Fabio Estevam, Shengjiu Wang,
Takashi Iwai, linux-kernel, Nicolin Chen, linuxppc-dev
In-Reply-To: <20210906114701.GC4309@sirena.org.uk>
Hi Mark
On Mon, Sep 6, 2021 at 7:48 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Fri, Sep 03, 2021 at 06:30:01PM +0800, Shengjiu Wang wrote:
>
> > There is no defer probe when adding platform component to
> > snd_soc_pcm_runtime(rtd), the code is in snd_soc_add_pcm_runtime()
>
> ...
>
> > So if the platform component is not ready at that time, then the
> > sound card still registered successfully, but platform component
> > is empty, the sound card can't be used.
>
> This sounds like a bug which should be fixed there?
It is hard.
In cpu dai driver we always register two components, one is for
cpu dai, another is for platform, so for sound card platform and
cpu share the same node.
/* Find PLATFORM from registered PLATFORMs */
for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
if (!snd_soc_is_matching_component(platform, component))
continue;
snd_soc_rtd_add_component(rtd, component);
}
}
Above code in snd_soc_add_pcm_runtime() checks components
for the platform, because there are two components for the node,
the first one is the component of cpu dai, which is added by
registering dai, it is already added in the beginning, so it is
duplicated, but the second one (which is for platform) is not ready,
then issue happens.
It is hard to add conditions here for defer probe. And maybe
some drivers need the same components for cpu and platform.
Do you have any suggestions?
(The easy way is to fix in each drivers:))
Best Regards
Wang Shengjiu
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Linas Vepstas @ 2021-09-07 2:05 UTC (permalink / raw)
To: Niklas Schnelle
Cc: linux-s390, Pierre Morel, Matthew Rosato,
linux-kernel@vger.kernel.org, Oliver O'Halloran,
Bjorn Helgaas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
On Mon, Sep 6, 2021 at 4:49 AM Niklas Schnelle <schnelle@linux.ibm.com>
wrote:
> I believe we might be the first
> implementation of PCI device recovery in a virtualized setting requiring
> us to
> coordinate the device reset with the hypervisor platform by issuing a
> disable
> and re-enable to the platform as well as starting the recovery following
> a platform event.
>
I recall none of the details, but SRIOV is a standardized system for
sharing a PCI device across multiple virtual machines. It has detailed info
on what the hypervisor must do, and what the local OS instance must do to
accomplish this. It's part of the PCI standard, and its more than a decade
old now, maybe two. Being a part of the PCI standard, it was interoperable
with error recovery, to the best of my recollection. At the time it was
introduced, it got pushed very aggressively. The x86 hypervisor vendors
were aiming at the heart of zseries, and were militant about it.
-- Linas
--
Patrick: Are they laughing at us?
Sponge Bob: No, Patrick, they are laughing next to us.
[-- Attachment #2: Type: text/html, Size: 1607 bytes --]
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Niklas Schnelle @ 2021-09-07 7:49 UTC (permalink / raw)
To: linasvepstas
Cc: linux-s390, Pierre Morel, Matthew Rosato,
linux-kernel@vger.kernel.org, Oliver O'Halloran,
Bjorn Helgaas, linuxppc-dev
In-Reply-To: <CAHrUA34TK6U4TB34FHejott9TdFvSgAedOpmro-Uj2ZwnvzecQ@mail.gmail.com>
On Mon, 2021-09-06 at 21:05 -0500, Linas Vepstas wrote:
> On Mon, Sep 6, 2021 at 4:49 AM Niklas Schnelle <schnelle@linux.ibm.com>
> wrote:
>
> > I believe we might be the first
> > implementation of PCI device recovery in a virtualized setting requiring
> > us to
> > coordinate the device reset with the hypervisor platform by issuing a
> > disable
> > and re-enable to the platform as well as starting the recovery following
> > a platform event.
> >
>
> I recall none of the details, but SRIOV is a standardized system for
> sharing a PCI device across multiple virtual machines. It has detailed info
> on what the hypervisor must do, and what the local OS instance must do to
> accomplish this.
Yes and in fact on s390 we make heavy use of SR-IOV.
> It's part of the PCI standard, and its more than a decade
> old now, maybe two. Being a part of the PCI standard, it was interoperable
> with error recovery, to the best of my recollection.
Maybe I worded things with a bit too much sensationalism and it might
even be that POWER supports error recovery also with virtualization,
though I'm not sure how far that goes.
I believe you are right in that SR-IOV supports the error recovery,
after all this patch set also has to work together with SRIOV enabled
devices. At least on s390 though until this patch set the error
recovery performed by the hypervisor stopped in the hypervisor.
The missing part added by this patch set is coordinating with device
drivers in Linux to determine where use of a recovered device can pick
up after the PCIe level error recovery is done.
As for virtualization this coordination of course needs to cross the
hypervisor/guest boundary and at least for KVM+QEMU I know for a fact
that reporting a PCI error to the guest is currently just a stub that
actually completely stops the guest, so you definitely don't get smooth
error recovery there yet.
> At the time it was
> introduced, it got pushed very aggressively. The x86 hypervisor vendors
> were aiming at the heart of zseries, and were militant about it.
And yet we're still here, use SR-IOV ourselves and even support Linux +
KVM as a hypervisor you can use just the same on a mainframe, an x86,
POWER, or ARM system.
>
> -- Linas
>
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: Andy Shevchenko @ 2021-09-07 7:51 UTC (permalink / raw)
To: kernel test robot
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato,
Niklas Schnelle, Linux Kernel Mailing List, Bjorn Helgaas,
Oliver O'Halloran, Linas Vepstas,
open list:LINUX FOR POWERPC PA SEMI PWRFICIENT
In-Reply-To: <202109070818.aHlo0OT9-lkp@intel.com>
On Tue, Sep 7, 2021 at 3:26 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Niklas,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on s390/features]
> [also build test ERROR on next-20210906]
> [cannot apply to pci/next powerpc/next v5.14]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
> config: i386-allyesconfig (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
> # https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
> # save the attached .config to linux build tree
> make W=1 ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
Obviously drivers/pci/pci.h is not only for the above.
When play with headers always do two test builds: allyesconfig and allmodconfig.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: Niklas Schnelle @ 2021-09-07 8:14 UTC (permalink / raw)
To: Andy Shevchenko, kernel test robot
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Oliver O'Halloran,
Linas Vepstas, open list:LINUX FOR POWERPC PA SEMI PWRFICIENT
In-Reply-To: <CAHp75VeiWH0MoAchctDES7zLk4Q9NwODu=O2y-NYOsu3SBeimg@mail.gmail.com>
On Tue, 2021-09-07 at 10:51 +0300, Andy Shevchenko wrote:
> On Tue, Sep 7, 2021 at 3:26 AM kernel test robot <lkp@intel.com> wrote:
> > Hi Niklas,
> >
> > I love your patch! Yet something to improve:
> >
> > [auto build test ERROR on s390/features]
> > [also build test ERROR on next-20210906]
> > [cannot apply to pci/next powerpc/next v5.14]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch]
> >
> > url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
> > config: i386-allyesconfig (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> > reproduce (this is a W=1 build):
> > # https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
> > git remote add linux-review https://github.com/0day-ci/linux
> > git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> > git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
> > # save the attached .config to linux build tree
> > make W=1 ARCH=i386
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
>
> Obviously drivers/pci/pci.h is not only for the above.
>
> When play with headers always do two test builds: allyesconfig and allmodconfig.
You're right and additionally have to built on some other architectures
as well because allyesconfig and allmodconfig both run through fine on
s390.
I'll look into it but at first glance it looks like I was over reaching
removing the include from drivers/pci/hotplug/acpiphp_glue.c in
addition it's not even the same kind of awkward relative include from
drivers into arch code. Sorry about that.
>
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Niklas Schnelle @ 2021-09-07 8:45 UTC (permalink / raw)
To: Oliver O'Halloran
Cc: linux-s390, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Linas Vepstas,
linuxppc-dev
In-Reply-To: <CAOSf1CFyuf9FaeSNparj+7W0mKTPvtcM8vxjHDSFsNDC6k_7xQ@mail.gmail.com>
On Tue, 2021-09-07 at 12:04 +1000, Oliver O'Halloran wrote:
> On Mon, Sep 6, 2021 at 7:49 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
> > Patch 3 I already sent separately resulting in the discussion below but without
> > a final conclusion.
> >
> > https://lore.kernel.org/lkml/20210720150145.640727-1-schnelle@linux.ibm.com/
> >
> > I believe even though there were some doubts about the use of
> > pci_dev_is_added() by arch code the existing uses as well as the use in the
> > final patch of this series warrant this export.
>
> The use of pci_dev_is_added() in arch/powerpc was because in the past
> pci_bus_add_device() could be called before pci_device_add(). That was
> fixed a while ago so It should be safe to remove those calls now.
Hmm, ok that confirms Bjorns suspicion and explains how it came to be.
I can certainly sent a patch for that. This would then leave only the
existing use in s390 which I added because of a dead lock prevention
and explained here:
https://lore.kernel.org/lkml/87d15d5eead35c9eaa667958d057cf4a81a8bf13.camel@linux.ibm.com/
Plus the need to use it in the recovery code of this series. I think in
the EEH code the need for a similar check is alleviated by the checks
in the beginning of
arch/powerpc/kernel/eeh_driver.c:eeh_handle_normal_event() especially
eeh_slot_presence_check() which checks presence via the hotplug slot.
I guess we could use our own state tracking in a similar way but felt
like pci_dev_is_added() is the more logical choice.
>
> > Patch 4 "PCI: Export pci_dev_lock()" is basically an extension to commit
> > e3a9b1212b9d ("PCI: Export pci_dev_trylock() and pci_dev_unlock()") which
> > already exported pci_dev_trylock(). In the final patch we make use of
> > pci_dev_lock() to wait for any other exclusive uses of the pdev to be finished
> > before starting recovery.
>
> Hmm, I noticed the EEH
> (arch/powerpc/kernel/eeh_driver.c:eeh_pe_report_edev()) and the
> generic PCIe error recovery code (see
> drivers/pci/pcie/err.c:report_error_detected()) only call
> device_lock() before entering the driver's error handling callbacks. I
> wonder if they should be using pci_dev_lock() instead. The only real
> difference is that pci_dev_lock() will also block user space from
> accessing the device's config space while error recovery is in
> progress which seems sensible enough.
I agree that sounds reasonable.
^ permalink raw reply
* [PATCH] pci/hotplug/pnv-php: Remove probable double put
From: Xu Wang @ 2021-09-07 8:59 UTC (permalink / raw)
To: mpe, benh, paulus, bhelgaas; +Cc: linux-pci, linuxppc-dev, linux-kernel
Device node iterators put the previous value of the index variable,
so an explicit put causes a double put.
Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
---
drivers/pci/hotplug/pnv_php.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index 04565162a449..ed4d1a2c3f22 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
for_each_child_of_node(parent, dn) {
pnv_php_detach_device_nodes(dn);
- of_node_put(dn);
of_detach_node(dn);
}
}
--
2.17.1
^ permalink raw reply related
* [PATCH v3] ftrace: Cleanup ftrace_dyn_arch_init()
From: Weizhao Ouyang @ 2021-09-07 10:05 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Catalin Marinas, Albert Ou, Weizhao Ouyang,
Vasily Gorbik, Heiko Carstens, Borislav Petkov, Greentime Hu,
Paul Walmsley, Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
ftrace_dyn_arch_init() to cleanup them.
Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
Acked-by: Helge Deller <deller@gmx.de> (parisc)
---
Changes in v3:
-- fix unrecognized opcode on PowerPC
Changes in v2:
-- correct CONFIG_DYNAMIC_FTRACE on PowerPC
-- add Acked-by tag
---
arch/arm/kernel/ftrace.c | 5 -----
arch/arm64/kernel/ftrace.c | 5 -----
arch/csky/kernel/ftrace.c | 5 -----
arch/ia64/kernel/ftrace.c | 6 ------
arch/microblaze/kernel/ftrace.c | 5 -----
arch/mips/include/asm/ftrace.h | 2 ++
arch/nds32/kernel/ftrace.c | 5 -----
arch/parisc/kernel/ftrace.c | 5 -----
arch/powerpc/include/asm/ftrace.h | 4 ++++
arch/riscv/kernel/ftrace.c | 5 -----
arch/s390/kernel/ftrace.c | 5 -----
arch/sh/kernel/ftrace.c | 5 -----
arch/sparc/kernel/ftrace.c | 5 -----
arch/x86/kernel/ftrace.c | 5 -----
include/linux/ftrace.h | 1 -
kernel/trace/ftrace.c | 5 +++++
16 files changed, 11 insertions(+), 62 deletions(-)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 3c83b5d29697..a006585e1c09 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -193,11 +193,6 @@ int ftrace_make_nop(struct module *mod,
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index 7f467bd9db7a..fc62dfe73f93 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -236,11 +236,6 @@ void arch_ftrace_update_code(int command)
command |= FTRACE_MAY_SLEEP;
ftrace_modify_all_code(command);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c
index b4a7ec1517ff..50bfcf129078 100644
--- a/arch/csky/kernel/ftrace.c
+++ b/arch/csky/kernel/ftrace.c
@@ -133,11 +133,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
(unsigned long)func, true, true);
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c
index b2ab2d58fb30..d6360fd404ab 100644
--- a/arch/ia64/kernel/ftrace.c
+++ b/arch/ia64/kernel/ftrace.c
@@ -194,9 +194,3 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
flush_icache_range(addr, addr + 16);
return 0;
}
-
-/* run from kstop_machine */
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
index 224eea40e1ee..188749d62709 100644
--- a/arch/microblaze/kernel/ftrace.c
+++ b/arch/microblaze/kernel/ftrace.c
@@ -163,11 +163,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return ret;
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long ip = (unsigned long)(&ftrace_call);
diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
index b463f2aa5a61..ed013e767390 100644
--- a/arch/mips/include/asm/ftrace.h
+++ b/arch/mips/include/asm/ftrace.h
@@ -76,6 +76,8 @@ do { \
#ifdef CONFIG_DYNAMIC_FTRACE
+int __init ftrace_dyn_arch_init(void);
+
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
return addr;
diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
index 0e23e3a8df6b..f0ef4842d191 100644
--- a/arch/nds32/kernel/ftrace.c
+++ b/arch/nds32/kernel/ftrace.c
@@ -84,11 +84,6 @@ void _ftrace_caller(unsigned long parent_ip)
/* restore all state needed by the compiler epilogue */
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
static unsigned long gen_sethi_insn(unsigned long addr)
{
unsigned long opcode = 0x46000000;
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 0a1e75af5382..01581f715737 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -94,11 +94,6 @@ int ftrace_disable_ftrace_graph_caller(void)
#endif
#ifdef CONFIG_DYNAMIC_FTRACE
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
int ftrace_update_ftrace_func(ftrace_func_t func)
{
return 0;
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index debe8c4f7062..b05c43f13a4d 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -126,6 +126,10 @@ static inline void this_cpu_enable_ftrace(void) { }
static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
#endif /* CONFIG_PPC64 */
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+int __init ftrace_dyn_arch_init(void);
+#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* !__ASSEMBLY__ */
#endif /* _ASM_POWERPC_FTRACE */
diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
index 7f1e5203de88..4716f4cdc038 100644
--- a/arch/riscv/kernel/ftrace.c
+++ b/arch/riscv/kernel/ftrace.c
@@ -154,11 +154,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index 0a464d328467..3fd80397ff52 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -262,11 +262,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return 0;
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
void arch_ftrace_update_code(int command)
{
if (ftrace_shared_hotpatch_trampoline(NULL))
diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c
index 295c43315bbe..930001bb8c6a 100644
--- a/arch/sh/kernel/ftrace.c
+++ b/arch/sh/kernel/ftrace.c
@@ -252,11 +252,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return ftrace_modify_code(rec->ip, old, new);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
index 684b84ce397f..eaead3da8e03 100644
--- a/arch/sparc/kernel/ftrace.c
+++ b/arch/sparc/kernel/ftrace.c
@@ -82,11 +82,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
new = ftrace_call_replace(ip, (unsigned long)func);
return ftrace_modify_code(ip, old, new);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1b3ce3b4a2a2..23d221a9a3cd 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -252,11 +252,6 @@ void arch_ftrace_update_code(int command)
ftrace_modify_all_code(command);
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
/* Currently only x86_64 supports dynamic trampolines */
#ifdef CONFIG_X86_64
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 832e65f06754..f1eca123d89d 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
/* defined in arch */
extern int ftrace_ip_converted(unsigned long ip);
-extern int ftrace_dyn_arch_init(void);
extern void ftrace_replace_code(int enable);
extern int ftrace_update_ftrace_func(ftrace_func_t func);
extern void ftrace_caller(void);
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 7efbc8aaf7f6..4c090323198d 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6846,6 +6846,11 @@ void __init ftrace_free_init_mem(void)
ftrace_free_mem(NULL, start, end);
}
+int __init __weak ftrace_dyn_arch_init(void)
+{
+ return 0;
+}
+
void __init ftrace_init(void)
{
extern unsigned long __start_mcount_loc[];
--
2.30.2
^ permalink raw reply related
* [PATCH 5/9] xen/x86: make "earlyprintk=xen" work for HVM/PVH DomU
From: Jan Beulich @ 2021-09-07 10:10 UTC (permalink / raw)
To: Juergen Gross, Boris Ostrovsky
Cc: xen-devel@lists.xenproject.org, Stefano Stabellini,
linuxppc-dev@lists.ozlabs.org, lkml
In-Reply-To: <4efa804e-3250-227f-00c7-347581366cd4@suse.com>
xenboot_write_console() is dealing with these quite fine so I don't see
why xenboot_console_setup() would return -ENOENT in this case.
Adjust documentation accordingly.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1266,7 +1266,7 @@
The VGA and EFI output is eventually overwritten by
the real console.
- The xen output can only be used by Xen PV guests.
+ The xen option can only be used in Xen domains.
The sclp output can only be used on s390.
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -618,10 +618,8 @@ static int __init xenboot_console_setup(
{
static struct xencons_info xenboot;
- if (xen_initial_domain())
+ if (xen_initial_domain() || !xen_pv_domain())
return 0;
- if (!xen_pv_domain())
- return -ENODEV;
return xencons_info_pv_init(&xenboot, 0);
}
^ 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