PCI/LINK: Deduplicate bandwidth reports for multi-function devices [Linux 5.1]

PCI/LINK: Deduplicate bandwidth reports for multi-function devices [Linux 5.1]

This Linux kernel change "PCI/LINK: Deduplicate bandwidth reports for multi-function devices" is included in the Linux 5.1 release. This change is authored by Lukas Wunner <lukas [at] wunner.de> on Wed Mar 20 12:05:30 2019 +0100. The commit for this change in Linux stable tree is 0fa635a (patch).

PCI/LINK: Deduplicate bandwidth reports for multi-function devices

If a multi-function device's bandwidth is already limited when it is
enumerated, a message is logged only for function 0.  By contrast, when
downtraining occurs after enumeration, a message is logged for all
functions.  That's because the former uses pcie_report_downtraining(),
whereas the latter uses __pcie_print_link_status() (which doesn't filter
functions != 0).  I am seeing this happen on a MacBookPro9,1 with a GPU
(function 0) and an integrated HDA controller (function 1).

Avoid this incongruence by calling pcie_report_downtraining() in both
cases.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alexandru Gagniuc <alex.gagniuc@dellteam.com>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/pci/pci.h                  | 1 +
 drivers/pci/pcie/bw_notification.c | 2 +-
 drivers/pci/probe.c                | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 224d886..d994839 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -273,6 +273,7 @@ void __pci_bus_assign_resources(const struct pci_bus *bus,
 u32 pcie_bandwidth_capable(struct pci_dev *dev, enum pci_bus_speed *speed,
               enum pcie_link_width *width);
 void __pcie_print_link_status(struct pci_dev *dev, bool verbose);
+void pcie_report_downtraining(struct pci_dev *dev);

 /* Single Root I/O Virtualization */
 struct pci_sriov {
diff --git a/drivers/pci/pcie/bw_notification.c b/drivers/pci/pcie/bw_notification.c
index 3c0f368..4fa9e352 100644
--- a/drivers/pci/pcie/bw_notification.c
+++ b/drivers/pci/pcie/bw_notification.c
@@ -76,7 +76,7 @@ static irqreturn_t pcie_bw_notification_handler(int irq, void *context)
     */
    down_read(&pci_bus_sem);
    list_for_each_entry(dev, &port->subordinate->devices, bus_list)
-       __pcie_print_link_status(dev, false);
+       pcie_report_downtraining(dev);
    up_read(&pci_bus_sem);

    return IRQ_HANDLED;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2ec0df0..7e12d01 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2388,7 +2388,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
    return dev;
 }

-static void pcie_report_downtraining(struct pci_dev *dev)
+void pcie_report_downtraining(struct pci_dev *dev)
 {
    if (!pci_is_pcie(dev))
        return;

Leave a Reply

Your email address will not be published. Required fields are marked *