hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/pci/pcie/portdrv_pci.c
....@@ -29,12 +29,20 @@
2929 */
3030 bool pcie_ports_native;
3131
32
+/*
33
+ * If the user specified "pcie_ports=dpc-native", use the Linux DPC PCIe
34
+ * service even if the platform hasn't given us permission.
35
+ */
36
+bool pcie_ports_dpc_native;
37
+
3238 static int __init pcie_port_setup(char *str)
3339 {
3440 if (!strncmp(str, "compat", 6))
3541 pcie_ports_disabled = true;
3642 else if (!strncmp(str, "native", 6))
3743 pcie_ports_native = true;
44
+ else if (!strncmp(str, "dpc-native", 10))
45
+ pcie_ports_dpc_native = true;
3846
3947 return 1;
4048 }
....@@ -45,12 +53,10 @@
4553 #ifdef CONFIG_PM
4654 static int pcie_port_runtime_suspend(struct device *dev)
4755 {
48
- return to_pci_dev(dev)->bridge_d3 ? 0 : -EBUSY;
49
-}
56
+ if (!to_pci_dev(dev)->bridge_d3)
57
+ return -EBUSY;
5058
51
-static int pcie_port_runtime_resume(struct device *dev)
52
-{
53
- return 0;
59
+ return pcie_port_device_runtime_suspend(dev);
5460 }
5561
5662 static int pcie_port_runtime_idle(struct device *dev)
....@@ -73,7 +79,7 @@
7379 .restore_noirq = pcie_port_device_resume_noirq,
7480 .restore = pcie_port_device_resume,
7581 .runtime_suspend = pcie_port_runtime_suspend,
76
- .runtime_resume = pcie_port_runtime_resume,
82
+ .runtime_resume = pcie_port_device_runtime_resume,
7783 .runtime_idle = pcie_port_runtime_idle,
7884 };
7985
....@@ -95,12 +101,14 @@
95101 static int pcie_portdrv_probe(struct pci_dev *dev,
96102 const struct pci_device_id *id)
97103 {
104
+ int type = pci_pcie_type(dev);
98105 int status;
99106
100107 if (!pci_is_pcie(dev) ||
101
- ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
102
- (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
103
- (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))
108
+ ((type != PCI_EXP_TYPE_ROOT_PORT) &&
109
+ (type != PCI_EXP_TYPE_UPSTREAM) &&
110
+ (type != PCI_EXP_TYPE_DOWNSTREAM) &&
111
+ (type != PCI_EXP_TYPE_RC_EC)))
104112 return -ENODEV;
105113
106114 status = pcie_port_device_register(dev);
....@@ -109,8 +117,8 @@
109117
110118 pci_save_state(dev);
111119
112
- dev_pm_set_driver_flags(&dev->dev, DPM_FLAG_SMART_SUSPEND |
113
- DPM_FLAG_LEAVE_SUSPENDED);
120
+ dev_pm_set_driver_flags(&dev->dev, DPM_FLAG_NO_DIRECT_COMPLETE |
121
+ DPM_FLAG_SMART_SUSPEND);
114122
115123 if (pci_bridge_d3_possible(dev)) {
116124 /*
....@@ -140,10 +148,17 @@
140148 }
141149
142150 static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev,
143
- enum pci_channel_state error)
151
+ pci_channel_state_t error)
144152 {
145153 /* Root Port has no impact. Always recovers. */
146154 return PCI_ERS_RESULT_CAN_RECOVER;
155
+}
156
+
157
+static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
158
+{
159
+ pci_restore_state(dev);
160
+ pci_save_state(dev);
161
+ return PCI_ERS_RESULT_RECOVERED;
147162 }
148163
149164 static pci_ers_result_t pcie_portdrv_mmio_enabled(struct pci_dev *dev)
....@@ -177,14 +192,19 @@
177192 /*
178193 * LINUX Device Driver Model
179194 */
180
-static const struct pci_device_id port_pci_ids[] = { {
195
+static const struct pci_device_id port_pci_ids[] = {
181196 /* handle any PCI-Express port */
182
- PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0),
183
- }, { /* end: all zeroes */ }
197
+ { PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0) },
198
+ /* subtractive decode PCI-to-PCI bridge, class type is 060401h */
199
+ { PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x01), ~0) },
200
+ /* handle any Root Complex Event Collector */
201
+ { PCI_DEVICE_CLASS(((PCI_CLASS_SYSTEM_RCEC << 8) | 0x00), ~0) },
202
+ { },
184203 };
185204
186205 static const struct pci_error_handlers pcie_portdrv_err_handler = {
187206 .error_detected = pcie_portdrv_error_detected,
207
+ .slot_reset = pcie_portdrv_slot_reset,
188208 .mmio_enabled = pcie_portdrv_mmio_enabled,
189209 .resume = pcie_portdrv_err_resume,
190210 };