On Thu, May 16, 2024 at 08:47:48PM +0000, Smita Koralahalli wrote: > Clear Link Bandwidth Management Status (LBMS) if set, on a hot-remove > event. > > The hot-remove event could result in target link speed reduction if LBMS > is set, due to a delay in Presence Detect State Change (PDSC) happening > after a Data Link Layer State Change event (DLLSC). > > In reality, PDSC and DLLSC events rarely come in simultaneously. Delay in > PDSC can sometimes be too late and the slot could have already been > powered down just by a DLLSC event. And the delayed PDSC could falsely be > interpreted as an interrupt raised to turn the slot on. This false process > of powering the slot on, without a link forces the kernel to retrain the > link if LBMS is set, to a lower speed to restablish the link thereby > bringing down the link speeds [2]. Not sure we need PDSC and DLLSC details to justify clearing LBMS if it has no meaning for an empty slot? > According to PCIe r6.2 sec 7.5.3.8 [1], it is derived that, LBMS cannot > be set for an unconnected link and if set, it serves the purpose of > indicating that there is actually a device down an inactive link. I see that r6.2 added an implementation note about DLLSC, but I'm not a hardware person and can't follow the implication about a device present down an inactive link. I guess it must be related to the fact that LBMS indicates either completion of link retraining or a change in link speed or width (which would imply presence of a downstream device). But in both cases I assume the link would be active. But IIUC LBMS is set by hardware but never cleared by hardware, so if we remove a device and power off the slot, it doesn't seem like LBMS could be telling us anything useful (what could we do in response to LBMS when the slot is empty?), so it makes sense to me to clear it. It seems like pciehp_unconfigure_device() does sort of PCI core and driver-related things and possibly could be something shared by all hotplug drivers, while remove_board() does things more specific to the hotplug model (pciehp, shpchp, etc).