On 2/24/19 8:29 PM, Lukas Wunner wrote: > On Fri, Dec 07, 2018 at 12:20:00PM -0600, Alexandru Gagniuc wrote: > > >> Q: Why is this unconditionally compiled in? >> A: The symmetrical check in pci probe() is also always compiled in. > > Hm, it looks like the convention is to provide a separate Kconfig entry > for each port service. Does the convention still make sense in light of the symmetry reason? >> Q: Why call module_init() instead of adding a call in pcie_init_services() ? >> A: A call in pcie_init_services() also requires a prototype in portdrv.h, a >> non-static implementation in bw_notification.c. Using module_init() is >> functionally equivalent, and takes less code. > > Commit c29de84149ab ("PCI: portdrv: Initialize service drivers directly") > moved away from module_init() on purpose, apparently to fix a race > condition. *GROWL* > What if the link is retrained at the same speed/width? Intuitively > I'd compare the speed in the Link Status Register to what is cached > in the cur_bus_speed member of struct pci_bus and print a message > only if the speed has changed. (Don't we need to cache the width as > well?) There are two mechanisms to bring a degraded link back to full BW. 1. Secondary bus reset, which results in the device being tore down along with our cached speed value. 2. Set the PCI_EXP_LNKCTL_LD (Link Disable) bit and clear it. We do that as part of the pciehp teardown path. We'd lose our cached value just like in the first case. >> +static irqreturn_t pcie_bw_notification_irq(int irq, void *context) >> [...] > > You need to hold pci_bus_sem [...] > This may sleep, so request the IRQ with request_threaded_irq() [...] Good catch! Thanks! All other issues you pointed out should be resolved in next version. Alex