Skip to content

Commit 207b074

Browse files
committed
Merge branches 'pci/host-xgene' and 'pci/hotplug' into next
* pci/host-xgene: PCI: xgene: Allow config access to Root Port even when link is down PCI: xgene: Disable Configuration Request Retry Status for v1 silicon * pci/hotplug: PCI: pciehp: Inline the "handle event" functions into the ISR PCI: pciehp: Rename queue_interrupt_event() to pciehp_queue_interrupt_event() PCI: pciehp: Make queue_interrupt_event() void PCI: pciehp: Clean up debug logging
3 parents 9f3d162 + ae4fa5f + 4f092fe commit 207b074

File tree

5 files changed

+98
-239
lines changed

5 files changed

+98
-239
lines changed

drivers/pci/host/pci-xgene.c

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
#define SZ_1T (SZ_1G*1024ULL)
6060
#define PIPE_PHY_RATE_RD(src) ((0xc000 & (u32)(src)) >> 0xe)
6161

62+
#define ROOT_CAP_AND_CTRL 0x5C
63+
64+
/* PCIe IP version */
65+
#define XGENE_PCIE_IP_VER_UNKN 0
66+
#define XGENE_PCIE_IP_VER_1 1
67+
6268
struct xgene_pcie_port {
6369
struct device_node *node;
6470
struct device *dev;
@@ -67,6 +73,7 @@ struct xgene_pcie_port {
6773
void __iomem *cfg_base;
6874
unsigned long cfg_addr;
6975
bool link_up;
76+
u32 version;
7077
};
7178

7279
static inline u32 pcie_bar_low_val(u32 addr, u32 flags)
@@ -130,19 +137,45 @@ static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
130137
static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
131138
int offset)
132139
{
133-
struct xgene_pcie_port *port = bus->sysdata;
134-
135-
if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up ||
140+
if ((pci_is_root_bus(bus) && devfn != 0) ||
136141
xgene_pcie_hide_rc_bars(bus, offset))
137142
return NULL;
138143

139144
xgene_pcie_set_rtdid_reg(bus, devfn);
140145
return xgene_pcie_get_cfg_base(bus) + offset;
141146
}
142147

148+
static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
149+
int where, int size, u32 *val)
150+
{
151+
struct xgene_pcie_port *port = bus->sysdata;
152+
153+
if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) !=
154+
PCIBIOS_SUCCESSFUL)
155+
return PCIBIOS_DEVICE_NOT_FOUND;
156+
157+
/*
158+
* The v1 controller has a bug in its Configuration Request
159+
* Retry Status (CRS) logic: when CRS is enabled and we read the
160+
* Vendor and Device ID of a non-existent device, the controller
161+
* fabricates return data of 0xFFFF0001 ("device exists but is not
162+
* ready") instead of 0xFFFFFFFF ("device does not exist"). This
163+
* causes the PCI core to retry the read until it times out.
164+
* Avoid this by not claiming to support CRS.
165+
*/
166+
if (pci_is_root_bus(bus) && (port->version == XGENE_PCIE_IP_VER_1) &&
167+
((where & ~0x3) == ROOT_CAP_AND_CTRL))
168+
*val &= ~(PCI_EXP_RTCAP_CRSVIS << 16);
169+
170+
if (size <= 2)
171+
*val = (*val >> (8 * (where & 3))) & ((1 << (size * 8)) - 1);
172+
173+
return PCIBIOS_SUCCESSFUL;
174+
}
175+
143176
static struct pci_ops xgene_pcie_ops = {
144177
.map_bus = xgene_pcie_map_bus,
145-
.read = pci_generic_config_read32,
178+
.read = xgene_pcie_config_read32,
146179
.write = pci_generic_config_write32,
147180
};
148181

@@ -500,6 +533,10 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
500533
port->node = of_node_get(pdev->dev.of_node);
501534
port->dev = &pdev->dev;
502535

536+
port->version = XGENE_PCIE_IP_VER_UNKN;
537+
if (of_device_is_compatible(port->node, "apm,xgene-pcie"))
538+
port->version = XGENE_PCIE_IP_VER_1;
539+
503540
ret = xgene_pcie_map_reg(port, pdev);
504541
if (ret)
505542
return ret;

drivers/pci/hotplug/pciehp.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,7 @@ struct controller {
132132

133133
int pciehp_sysfs_enable_slot(struct slot *slot);
134134
int pciehp_sysfs_disable_slot(struct slot *slot);
135-
u8 pciehp_handle_attention_button(struct slot *p_slot);
136-
u8 pciehp_handle_switch_change(struct slot *p_slot);
137-
u8 pciehp_handle_presence_change(struct slot *p_slot);
138-
u8 pciehp_handle_power_fault(struct slot *p_slot);
139-
void pciehp_handle_linkstate_change(struct slot *p_slot);
135+
void pciehp_queue_interrupt_event(struct slot *slot, u32 event_type);
140136
int pciehp_configure_device(struct slot *p_slot);
141137
int pciehp_unconfigure_device(struct slot *p_slot);
142138
void pciehp_queue_pushbutton_work(struct work_struct *work);

drivers/pci/hotplug/pciehp_core.c

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ static int reset_slot (struct hotplug_slot *slot, int probe);
7777
*/
7878
static void release_slot(struct hotplug_slot *hotplug_slot)
7979
{
80-
struct slot *slot = hotplug_slot->private;
81-
82-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
83-
__func__, hotplug_slot_name(hotplug_slot));
84-
8580
kfree(hotplug_slot->ops);
8681
kfree(hotplug_slot->info);
8782
kfree(hotplug_slot);
@@ -129,14 +124,10 @@ static int init_slot(struct controller *ctrl)
129124
slot->hotplug_slot = hotplug;
130125
snprintf(name, SLOT_NAME_SIZE, "%u", PSN(ctrl));
131126

132-
ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:00 sun=%x\n",
133-
pci_domain_nr(ctrl->pcie->port->subordinate),
134-
ctrl->pcie->port->subordinate->number, PSN(ctrl));
135127
retval = pci_hp_register(hotplug,
136128
ctrl->pcie->port->subordinate, 0, name);
137129
if (retval)
138-
ctrl_err(ctrl,
139-
"pci_hp_register failed with error %d\n", retval);
130+
ctrl_err(ctrl, "pci_hp_register failed: error %d\n", retval);
140131
out:
141132
if (retval) {
142133
kfree(ops);
@@ -158,9 +149,6 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
158149
{
159150
struct slot *slot = hotplug_slot->private;
160151

161-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
162-
__func__, slot_name(slot));
163-
164152
pciehp_set_attention_status(slot, status);
165153
return 0;
166154
}
@@ -170,9 +158,6 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
170158
{
171159
struct slot *slot = hotplug_slot->private;
172160

173-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
174-
__func__, slot_name(slot));
175-
176161
return pciehp_sysfs_enable_slot(slot);
177162
}
178163

@@ -181,19 +166,13 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
181166
{
182167
struct slot *slot = hotplug_slot->private;
183168

184-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
185-
__func__, slot_name(slot));
186-
187169
return pciehp_sysfs_disable_slot(slot);
188170
}
189171

190172
static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
191173
{
192174
struct slot *slot = hotplug_slot->private;
193175

194-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
195-
__func__, slot_name(slot));
196-
197176
pciehp_get_power_status(slot, value);
198177
return 0;
199178
}
@@ -202,9 +181,6 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
202181
{
203182
struct slot *slot = hotplug_slot->private;
204183

205-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
206-
__func__, slot_name(slot));
207-
208184
pciehp_get_attention_status(slot, value);
209185
return 0;
210186
}
@@ -213,9 +189,6 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
213189
{
214190
struct slot *slot = hotplug_slot->private;
215191

216-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
217-
__func__, slot_name(slot));
218-
219192
pciehp_get_latch_status(slot, value);
220193
return 0;
221194
}
@@ -224,9 +197,6 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
224197
{
225198
struct slot *slot = hotplug_slot->private;
226199

227-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
228-
__func__, slot_name(slot));
229-
230200
pciehp_get_adapter_status(slot, value);
231201
return 0;
232202
}
@@ -235,9 +205,6 @@ static int reset_slot(struct hotplug_slot *hotplug_slot, int probe)
235205
{
236206
struct slot *slot = hotplug_slot->private;
237207

238-
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
239-
__func__, slot_name(slot));
240-
241208
return pciehp_reset_slot(slot, probe);
242209
}
243210

@@ -272,14 +239,14 @@ static int pciehp_probe(struct pcie_device *dev)
272239
if (rc == -EBUSY)
273240
ctrl_warn(ctrl, "Slot already registered by another hotplug driver\n");
274241
else
275-
ctrl_err(ctrl, "Slot initialization failed\n");
242+
ctrl_err(ctrl, "Slot initialization failed (%d)\n", rc);
276243
goto err_out_release_ctlr;
277244
}
278245

279246
/* Enable events after we have setup the data structures */
280247
rc = pcie_init_notification(ctrl);
281248
if (rc) {
282-
ctrl_err(ctrl, "Notification initialization failed\n");
249+
ctrl_err(ctrl, "Notification initialization failed (%d)\n", rc);
283250
goto err_out_free_ctrl_slot;
284251
}
285252

0 commit comments

Comments
 (0)