aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Wunner <lukas@wunner.de>2018-09-08 03:59:01 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-09-18 18:52:15 -0400
commitd758714235e7abb7984468370c912ca2f4dc4e57 (patch)
tree8c49e29d5dd2d6abcdde8f442ea464db74318125
parent4ff3126e80fc2db9d961467f783b5c2f4ccd1ca9 (diff)
PCI: pciehp: Reshuffle controller struct for clarity
The members in pciehp's controller struct are arranged in a seemingly arbitrary order and have grown to an amount that I no longer consider easily graspable by contributors. Sort the members into 5 rubrics: * Slot Capabilities register and quirks * Slot Control register access * Slot Status register event handling * state machine * hotplug core interface Obviously, this is just my personal bikeshed color and if anyone has a better idea, please come forward. Any ordering will do as long as the information is presented in a manageable manner. No functional change intended. Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/hotplug/pciehp.h57
1 files changed, 31 insertions, 26 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 39b97e2384c3..3cc88f3e4368 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -60,38 +60,38 @@ do { \
60 60
61/** 61/**
62 * struct controller - PCIe hotplug controller 62 * struct controller - PCIe hotplug controller
63 * @ctrl_lock: serializes writes to the Slot Control register
64 * @pcie: pointer to the controller's PCIe port service device 63 * @pcie: pointer to the controller's PCIe port service device
65 * @reset_lock: prevents access to the Data Link Layer Link Active bit in the
66 * Link Status register and to the Presence Detect State bit in the Slot
67 * Status register during a slot reset which may cause them to flap
68 * @queue: wait queue to wake up on reception of a Command Completed event,
69 * used for synchronous writes to the Slot Control register
70 * @slot_cap: cached copy of the Slot Capabilities register 64 * @slot_cap: cached copy of the Slot Capabilities register
65 * @link_active_reporting: cached copy of Data Link Layer Link Active Reporting
66 * Capable bit in Link Capabilities register; if this bit is zero, the
67 * Data Link Layer Link Active bit in the Link Status register will never
68 * be set and the driver is thus confined to wait 1 second before assuming
69 * the link to a hotplugged device is up and accessing it
71 * @slot_ctrl: cached copy of the Slot Control register 70 * @slot_ctrl: cached copy of the Slot Control register
72 * @poll_thread: thread to poll for slot events if no IRQ is available, 71 * @ctrl_lock: serializes writes to the Slot Control register
73 * enabled with pciehp_poll_mode module parameter
74 * @cmd_started: jiffies when the Slot Control register was last written; 72 * @cmd_started: jiffies when the Slot Control register was last written;
75 * the next write is allowed 1 second later, absent a Command Completed 73 * the next write is allowed 1 second later, absent a Command Completed
76 * interrupt (PCIe r4.0, sec 6.7.3.2) 74 * interrupt (PCIe r4.0, sec 6.7.3.2)
77 * @cmd_busy: flag set on Slot Control register write, cleared by IRQ handler 75 * @cmd_busy: flag set on Slot Control register write, cleared by IRQ handler
78 * on reception of a Command Completed event 76 * on reception of a Command Completed event
79 * @link_active_reporting: cached copy of Data Link Layer Link Active Reporting 77 * @queue: wait queue to wake up on reception of a Command Completed event,
80 * Capable bit in Link Capabilities register; if this bit is zero, the 78 * used for synchronous writes to the Slot Control register
81 * Data Link Layer Link Active bit in the Link Status register will never 79 * @pending_events: used by the IRQ handler to save events retrieved from the
82 * be set and the driver is thus confined to wait 1 second before assuming 80 * Slot Status register for later consumption by the IRQ thread
83 * the link to a hotplugged device is up and accessing it
84 * @notification_enabled: whether the IRQ was requested successfully 81 * @notification_enabled: whether the IRQ was requested successfully
85 * @power_fault_detected: whether a power fault was detected by the hardware 82 * @power_fault_detected: whether a power fault was detected by the hardware
86 * that has not yet been cleared by the user 83 * that has not yet been cleared by the user
87 * @pending_events: used by the IRQ handler to save events retrieved from the 84 * @poll_thread: thread to poll for slot events if no IRQ is available,
88 * Slot Status register for later consumption by the IRQ thread 85 * enabled with pciehp_poll_mode module parameter
89 * @state: current state machine position 86 * @state: current state machine position
90 * @state_lock: protects reads and writes of @state; 87 * @state_lock: protects reads and writes of @state;
91 * protects scheduling, execution and cancellation of @button_work 88 * protects scheduling, execution and cancellation of @button_work
92 * @button_work: work item to turn the slot on or off after 5 seconds 89 * @button_work: work item to turn the slot on or off after 5 seconds
93 * in response to an Attention Button press 90 * in response to an Attention Button press
94 * @hotplug_slot: pointer to the structure registered with the PCI hotplug core 91 * @hotplug_slot: pointer to the structure registered with the PCI hotplug core
92 * @reset_lock: prevents access to the Data Link Layer Link Active bit in the
93 * Link Status register and to the Presence Detect State bit in the Slot
94 * Status register during a slot reset which may cause them to flap
95 * @request_result: result of last user request submitted to the IRQ thread 95 * @request_result: result of last user request submitted to the IRQ thread
96 * @requester: wait queue to wake up on completion of user request, 96 * @requester: wait queue to wake up on completion of user request,
97 * used for synchronous slot enable/disable request via sysfs 97 * used for synchronous slot enable/disable request via sysfs
@@ -100,23 +100,28 @@ do { \
100 * unlike other drivers, the two aren't represented by separate structures. 100 * unlike other drivers, the two aren't represented by separate structures.
101 */ 101 */
102struct controller { 102struct controller {
103 struct mutex ctrl_lock;
104 struct pcie_device *pcie; 103 struct pcie_device *pcie;
105 struct rw_semaphore reset_lock; 104
106 wait_queue_head_t queue; 105 u32 slot_cap; /* capabilities and quirks */
107 u32 slot_cap;
108 u16 slot_ctrl;
109 struct task_struct *poll_thread;
110 unsigned long cmd_started; /* jiffies */
111 unsigned int cmd_busy:1;
112 unsigned int link_active_reporting:1; 106 unsigned int link_active_reporting:1;
107
108 u16 slot_ctrl; /* control register access */
109 struct mutex ctrl_lock;
110 unsigned long cmd_started;
111 unsigned int cmd_busy:1;
112 wait_queue_head_t queue;
113
114 atomic_t pending_events; /* event handling */
113 unsigned int notification_enabled:1; 115 unsigned int notification_enabled:1;
114 unsigned int power_fault_detected; 116 unsigned int power_fault_detected;
115 atomic_t pending_events; 117 struct task_struct *poll_thread;
116 u8 state; 118
119 u8 state; /* state machine */
117 struct mutex state_lock; 120 struct mutex state_lock;
118 struct delayed_work button_work; 121 struct delayed_work button_work;
119 struct hotplug_slot *hotplug_slot; 122
123 struct hotplug_slot *hotplug_slot; /* hotplug core interface */
124 struct rw_semaphore reset_lock;
120 int request_result; 125 int request_result;
121 wait_queue_head_t requester; 126 wait_queue_head_t requester;
122}; 127};