[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z__hZ2M8wDHn2XSn@wunner.de>
Date: Wed, 16 Apr 2025 18:57:11 +0200
From: Lukas Wunner <lukas@...ner.de>
To: manivannan.sadhasivam@...aro.org
Cc: Mahesh J Salgaonkar <mahesh@...ux.ibm.com>,
Oliver O'Halloran <oohall@...il.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Krzysztof Wilczy??ski <kw@...ux.com>, Rob Herring <robh@...nel.org>,
dingwei@...vell.com, cassel@...nel.org,
Krishna Chaitanya Chundru <krishna.chundru@....qualcomm.com>,
linuxppc-dev@...ts.ozlabs.org, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH v2 3/4] PCI: Add link down handling for host bridges
On Wed, Apr 16, 2025 at 09:59:05PM +0530, Manivannan Sadhasivam via B4 Relay wrote:
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -270,3 +270,30 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
>
> return status;
> }
> +
> +static pci_ers_result_t pcie_do_slot_reset(struct pci_dev *dev)
> +{
> + int ret;
> +
> + ret = pci_bus_error_reset(dev);
> + if (ret) {
> + pci_err(dev, "Failed to reset slot: %d\n", ret);
> + return PCI_ERS_RESULT_DISCONNECT;
> + }
> +
> + pci_info(dev, "Slot has been reset\n");
> +
> + return PCI_ERS_RESULT_RECOVERED;
> +}
> +
> +void pcie_do_recover_slots(struct pci_host_bridge *host)
> +{
> + struct pci_bus *bus = host->bus;
> + struct pci_dev *dev;
> +
> + for_each_pci_bridge(dev, bus) {
> + if (pci_is_root_bus(bus))
> + pcie_do_recovery(dev, pci_channel_io_frozen,
> + pcie_do_slot_reset);
> + }
> +}
Since pcie_do_slot_reset(), pcie_do_recover_slots() and
pcie_do_recover_slots() are only needed on platforms with a
specific host controller (and not, say, on x86), it would be good
if they could be kept e.g. in a library in drivers/pci/controller/
to avoid unnecessarily enlarging the .text section for everyone else.
One option would be the existing pci-host-common.c, another a
completely new file.
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -966,6 +966,7 @@ int pci_aer_clear_status(struct pci_dev *dev);
> int pci_aer_raw_clear_status(struct pci_dev *dev);
> void pci_save_aer_state(struct pci_dev *dev);
> void pci_restore_aer_state(struct pci_dev *dev);
> +void pcie_do_recover_slots(struct pci_host_bridge *host);
> #else
> static inline void pci_no_aer(void) { }
> static inline void pci_aer_init(struct pci_dev *d) { }
> @@ -975,6 +976,26 @@ static inline int pci_aer_clear_status(struct pci_dev *dev) { return -EINVAL; }
> static inline int pci_aer_raw_clear_status(struct pci_dev *dev) { return -EINVAL; }
> static inline void pci_save_aer_state(struct pci_dev *dev) { }
> static inline void pci_restore_aer_state(struct pci_dev *dev) { }
> +static inline void pcie_do_recover_slots(struct pci_host_bridge *host)
> +{
> + struct pci_bus *bus = host->bus;
> + struct pci_dev *dev;
> + int ret;
> +
> + if (!host->reset_slot)
> + dev_warn(&host->dev, "Missing reset_slot() callback\n");
> +
> + for_each_pci_bridge(dev, bus) {
> + if (!pci_is_root_bus(bus))
> + continue;
> +
> + ret = pci_bus_error_reset(dev);
> + if (ret)
> + pci_err(dev, "Failed to reset slot: %d\n", ret);
> + else
> + pci_info(dev, "Slot has been reset\n");
> + }
> +}
> #endif
Unusual to have such a large inline function in a header.
Can this likewise be moved to some library file and separated
from the other version via #ifdef please?
Thanks,
Lukas
Powered by blists - more mailing lists