PCI/LINK: Clear bandwidth notification interrupt before enabling it [Linux 5.1]

PCI/LINK: Clear bandwidth notification interrupt before enabling it [Linux 5.1]

This Linux kernel change "PCI/LINK: Clear bandwidth notification interrupt before enabling it" 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 55397ce (patch).

PCI/LINK: Clear bandwidth notification interrupt before enabling it

When booting a MacBookPro9,1, duplicate link downtraining messages are
logged for the devices directly attached to the two CPU-internal Root Ports
of the Core i7 3615QM:  Once on device enumeration and once on enablement
of the bandwidth notification interrupt on the Root Ports.

Duplicate messages do not occur with Root Ports on the PCH and Downstream
Ports on the Thunderbolt controller:  Only a single message is logged for
these, namely on device enumeration.

The reason for the duplicate messages is a stale interrupt in the Link
Status register of the 3615QM's internal Root Ports.  Avoid by clearing the
interrupt before enabling it.

An alternative approach would be to clear the interrupt already on device
enumeration or to report link downtraining only if the speed has changed.
That way, link downtraining occurring between device enumeration and
enablement of the bandwidth notification interrupt could be caught.
However clearing stale interrupts before enabling them is a standard
operating procedure for any driver and keeping the two steps in one place
makes the code easier to follow.

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 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/pci/pcie/bw_notification.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pcie/bw_notification.c b/drivers/pci/pcie/bw_notification.c
index c48746f..3c0f368 100644
--- a/drivers/pci/pcie/bw_notification.c
+++ b/drivers/pci/pcie/bw_notification.c
@@ -30,6 +30,8 @@ static void pcie_enable_link_bandwidth_notification(struct pci_dev *dev)
 {
    u16 lnk_ctl;

+   pcie_capability_write_word(dev, PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_LBMS);
+
    pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnk_ctl);
    lnk_ctl |= PCI_EXP_LNKCTL_LBMIE;
    pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnk_ctl);

Leave a Reply

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