summaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2018-06-08 09:31:57 -0400
committerBjorn Helgaas <helgaas@kernel.org>2018-06-11 09:10:27 -0400
commit3c43a64cb3e092bec27c79b67b28bba4a9296a84 (patch)
tree9a01e61c34de48a88a30e035dabf9cf63153eebf /drivers/pci
parent0054ca8e108e6fb5391c4f72b5233ee0c1f0e47e (diff)
PCI/AER: Reorder code to group probe/remove stuff together
Reorder code to group probe/remove stuff together. No functional change intended. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index c6d1b664a6ea..8d3bc28821ba 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -35,6 +35,64 @@ bool pci_aer_available(void)
35 return !pcie_aer_disable && pci_msi_enabled(); 35 return !pcie_aer_disable && pci_msi_enabled();
36} 36}
37 37
38/**
39 * aer_irq - Root Port's ISR
40 * @irq: IRQ assigned to Root Port
41 * @context: pointer to Root Port data structure
42 *
43 * Invoked when Root Port detects AER messages.
44 */
45irqreturn_t aer_irq(int irq, void *context)
46{
47 unsigned int status, id;
48 struct pcie_device *pdev = (struct pcie_device *)context;
49 struct aer_rpc *rpc = get_service_data(pdev);
50 int next_prod_idx;
51 unsigned long flags;
52 int pos;
53
54 pos = pdev->port->aer_cap;
55 /*
56 * Must lock access to Root Error Status Reg, Root Error ID Reg,
57 * and Root error producer/consumer index
58 */
59 spin_lock_irqsave(&rpc->e_lock, flags);
60
61 /* Read error status */
62 pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, &status);
63 if (!(status & (PCI_ERR_ROOT_UNCOR_RCV|PCI_ERR_ROOT_COR_RCV))) {
64 spin_unlock_irqrestore(&rpc->e_lock, flags);
65 return IRQ_NONE;
66 }
67
68 /* Read error source and clear error status */
69 pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_ERR_SRC, &id);
70 pci_write_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, status);
71
72 /* Store error source for later DPC handler */
73 next_prod_idx = rpc->prod_idx + 1;
74 if (next_prod_idx == AER_ERROR_SOURCES_MAX)
75 next_prod_idx = 0;
76 if (next_prod_idx == rpc->cons_idx) {
77 /*
78 * Error Storm Condition - possibly the same error occurred.
79 * Drop the error.
80 */
81 spin_unlock_irqrestore(&rpc->e_lock, flags);
82 return IRQ_HANDLED;
83 }
84 rpc->e_sources[rpc->prod_idx].status = status;
85 rpc->e_sources[rpc->prod_idx].id = id;
86 rpc->prod_idx = next_prod_idx;
87 spin_unlock_irqrestore(&rpc->e_lock, flags);
88
89 /* Invoke DPC handler */
90 schedule_work(&rpc->dpc_handler);
91
92 return IRQ_HANDLED;
93}
94EXPORT_SYMBOL_GPL(aer_irq);
95
38static int set_device_error_reporting(struct pci_dev *dev, void *data) 96static int set_device_error_reporting(struct pci_dev *dev, void *data)
39{ 97{
40 bool enable = *((bool *)data); 98 bool enable = *((bool *)data);
@@ -142,64 +200,6 @@ static void aer_disable_rootport(struct aer_rpc *rpc)
142} 200}
143 201
144/** 202/**
145 * aer_irq - Root Port's ISR
146 * @irq: IRQ assigned to Root Port
147 * @context: pointer to Root Port data structure
148 *
149 * Invoked when Root Port detects AER messages.
150 */
151irqreturn_t aer_irq(int irq, void *context)
152{
153 unsigned int status, id;
154 struct pcie_device *pdev = (struct pcie_device *)context;
155 struct aer_rpc *rpc = get_service_data(pdev);
156 int next_prod_idx;
157 unsigned long flags;
158 int pos;
159
160 pos = pdev->port->aer_cap;
161 /*
162 * Must lock access to Root Error Status Reg, Root Error ID Reg,
163 * and Root error producer/consumer index
164 */
165 spin_lock_irqsave(&rpc->e_lock, flags);
166
167 /* Read error status */
168 pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, &status);
169 if (!(status & (PCI_ERR_ROOT_UNCOR_RCV|PCI_ERR_ROOT_COR_RCV))) {
170 spin_unlock_irqrestore(&rpc->e_lock, flags);
171 return IRQ_NONE;
172 }
173
174 /* Read error source and clear error status */
175 pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_ERR_SRC, &id);
176 pci_write_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, status);
177
178 /* Store error source for later DPC handler */
179 next_prod_idx = rpc->prod_idx + 1;
180 if (next_prod_idx == AER_ERROR_SOURCES_MAX)
181 next_prod_idx = 0;
182 if (next_prod_idx == rpc->cons_idx) {
183 /*
184 * Error Storm Condition - possibly the same error occurred.
185 * Drop the error.
186 */
187 spin_unlock_irqrestore(&rpc->e_lock, flags);
188 return IRQ_HANDLED;
189 }
190 rpc->e_sources[rpc->prod_idx].status = status;
191 rpc->e_sources[rpc->prod_idx].id = id;
192 rpc->prod_idx = next_prod_idx;
193 spin_unlock_irqrestore(&rpc->e_lock, flags);
194
195 /* Invoke DPC handler */
196 schedule_work(&rpc->dpc_handler);
197
198 return IRQ_HANDLED;
199}
200EXPORT_SYMBOL_GPL(aer_irq);
201
202/**
203 * aer_alloc_rpc - allocate Root Port data structure 203 * aer_alloc_rpc - allocate Root Port data structure
204 * @dev: pointer to the pcie_dev data structure 204 * @dev: pointer to the pcie_dev data structure
205 * 205 *