PCI: pciehp: Track enable/disable status
handle_button_press_event() currently determines whether the slot has been turned on or off by looking at the Power Controller Control bit in the Slot Control register. This assumes that an attention button implies presence of a power controller even though that's not mandated by the spec. Moreover the Power Controller Control bit is unreliable when a power fault occurs (PCIe r4.0, sec 6.7.1.8). This issue has existed since the driver was introduced in 2004. Fix by replacing STATIC_STATE with ON_STATE and OFF_STATE and tracking whether the slot has been turned on or off. This is also a required ingredient to make pciehp resilient to missed events, which is the object of an upcoming commit. Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:

committed by
Bjorn Helgaas

parent
774d446b0f
commit
9590192f25
@@ -122,11 +122,24 @@ struct controller {
|
||||
atomic_t pending_events;
|
||||
};
|
||||
|
||||
#define STATIC_STATE 0
|
||||
/**
|
||||
* DOC: Slot state
|
||||
*
|
||||
* @OFF_STATE: slot is powered off, no subordinate devices are enumerated
|
||||
* @BLINKINGON_STATE: slot will be powered on after the 5 second delay,
|
||||
* green led is blinking
|
||||
* @BLINKINGOFF_STATE: slot will be powered off after the 5 second delay,
|
||||
* green led is blinking
|
||||
* @POWERON_STATE: slot is currently powering on
|
||||
* @POWEROFF_STATE: slot is currently powering off
|
||||
* @ON_STATE: slot is powered on, subordinate devices have been enumerated
|
||||
*/
|
||||
#define OFF_STATE 0
|
||||
#define BLINKINGON_STATE 1
|
||||
#define BLINKINGOFF_STATE 2
|
||||
#define POWERON_STATE 3
|
||||
#define POWEROFF_STATE 4
|
||||
#define ON_STATE 5
|
||||
|
||||
#define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_ABP)
|
||||
#define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PCP)
|
||||
|
Reference in New Issue
Block a user