Skip to content

Commit f5d3ca6

Browse files
committed
Merge branch 'pci/errors'
- Add PCI_ERROR_RESPONSE and related definitions for signaling and checking for transaction errors on PCI (Naveen Naidu) - Fabricate PCI_ERROR_RESPONSE data (~0) in config read wrappers, instead of in host controller drivers, when transactions fail on PCI (Naveen Naidu) - Use PCI_POSSIBLE_ERROR() to check for possible failure of config reads (Naveen Naidu) * pci/errors: PCI: xgene: Use PCI_ERROR_RESPONSE to identify config read errors PCI: hv: Use PCI_ERROR_RESPONSE to identify config read errors PCI: keystone: Use PCI_ERROR_RESPONSE to identify config read errors PCI: Use PCI_ERROR_RESPONSE to identify config read errors PCI: cpqphp: Use PCI_POSSIBLE_ERROR() to check config reads PCI/PME: Use PCI_POSSIBLE_ERROR() to check config reads PCI/DPC: Use PCI_POSSIBLE_ERROR() to check config reads PCI: pciehp: Use PCI_POSSIBLE_ERROR() to check config reads PCI: vmd: Use PCI_POSSIBLE_ERROR() to check config reads PCI/ERR: Use PCI_POSSIBLE_ERROR() to check config reads PCI: rockchip-host: Drop error data fabrication when config read fails PCI: rcar-host: Drop error data fabrication when config read fails PCI: altera: Drop error data fabrication when config read fails PCI: mvebu: Drop error data fabrication when config read fails PCI: aardvark: Drop error data fabrication when config read fails PCI: kirin: Drop error data fabrication when config read fails PCI: histb: Drop error data fabrication when config read fails PCI: exynos: Drop error data fabrication when config read fails PCI: mediatek: Drop error data fabrication when config read fails PCI: iproc: Drop error data fabrication when config read fails PCI: thunder: Drop error data fabrication when config read fails PCI: Drop error data fabrication when config read fails PCI: Use PCI_SET_ERROR_RESPONSE() for disconnected devices PCI: Set error response data when config read fails PCI: Add PCI_ERROR_RESPONSE and related definitions
2 parents da43f08 + c78b9a9 commit f5d3ca6

24 files changed

+88
-120
lines changed

drivers/pci/access.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ int noinline pci_bus_read_config_##size \
4242
if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
4343
pci_lock_config(flags); \
4444
res = bus->ops->read(bus, devfn, pos, len, &data); \
45-
*value = (type)data; \
45+
if (res) \
46+
PCI_SET_ERROR_RESPONSE(value); \
47+
else \
48+
*value = (type)data; \
4649
pci_unlock_config(flags); \
4750
return res; \
4851
}
@@ -80,10 +83,8 @@ int pci_generic_config_read(struct pci_bus *bus, unsigned int devfn,
8083
void __iomem *addr;
8184

8285
addr = bus->ops->map_bus(bus, devfn, where);
83-
if (!addr) {
84-
*val = ~0;
86+
if (!addr)
8587
return PCIBIOS_DEVICE_NOT_FOUND;
86-
}
8788

8889
if (size == 1)
8990
*val = readb(addr);
@@ -122,10 +123,8 @@ int pci_generic_config_read32(struct pci_bus *bus, unsigned int devfn,
122123
void __iomem *addr;
123124

124125
addr = bus->ops->map_bus(bus, devfn, where & ~0x3);
125-
if (!addr) {
126-
*val = ~0;
126+
if (!addr)
127127
return PCIBIOS_DEVICE_NOT_FOUND;
128-
}
129128

130129
*val = readl(addr);
131130

@@ -228,7 +227,10 @@ int pci_user_read_config_##size \
228227
ret = dev->bus->ops->read(dev->bus, dev->devfn, \
229228
pos, sizeof(type), &data); \
230229
raw_spin_unlock_irq(&pci_lock); \
231-
*val = (type)data; \
230+
if (ret) \
231+
PCI_SET_ERROR_RESPONSE(val); \
232+
else \
233+
*val = (type)data; \
232234
return pcibios_err_to_errno(ret); \
233235
} \
234236
EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
@@ -410,9 +412,9 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
410412
if (pcie_capability_reg_implemented(dev, pos)) {
411413
ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val);
412414
/*
413-
* Reset *val to 0 if pci_read_config_word() fails, it may
414-
* have been written as 0xFFFF if hardware error happens
415-
* during pci_read_config_word().
415+
* Reset *val to 0 if pci_read_config_word() fails; it may
416+
* have been written as 0xFFFF (PCI_ERROR_RESPONSE) if the
417+
* config read failed on PCI.
416418
*/
417419
if (ret)
418420
*val = 0;
@@ -445,9 +447,9 @@ int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)
445447
if (pcie_capability_reg_implemented(dev, pos)) {
446448
ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val);
447449
/*
448-
* Reset *val to 0 if pci_read_config_dword() fails, it may
449-
* have been written as 0xFFFFFFFF if hardware error happens
450-
* during pci_read_config_dword().
450+
* Reset *val to 0 if pci_read_config_dword() fails; it may
451+
* have been written as 0xFFFFFFFF (PCI_ERROR_RESPONSE) if
452+
* the config read failed on PCI.
451453
*/
452454
if (ret)
453455
*val = 0;
@@ -523,7 +525,7 @@ EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
523525
int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
524526
{
525527
if (pci_dev_is_disconnected(dev)) {
526-
*val = ~0;
528+
PCI_SET_ERROR_RESPONSE(val);
527529
return PCIBIOS_DEVICE_NOT_FOUND;
528530
}
529531
return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
@@ -533,7 +535,7 @@ EXPORT_SYMBOL(pci_read_config_byte);
533535
int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
534536
{
535537
if (pci_dev_is_disconnected(dev)) {
536-
*val = ~0;
538+
PCI_SET_ERROR_RESPONSE(val);
537539
return PCIBIOS_DEVICE_NOT_FOUND;
538540
}
539541
return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
@@ -544,7 +546,7 @@ int pci_read_config_dword(const struct pci_dev *dev, int where,
544546
u32 *val)
545547
{
546548
if (pci_dev_is_disconnected(dev)) {
547-
*val = ~0;
549+
PCI_SET_ERROR_RESPONSE(val);
548550
return PCIBIOS_DEVICE_NOT_FOUND;
549551
}
550552
return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);

drivers/pci/controller/dwc/pci-exynos.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,8 @@ static int exynos_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
216216
{
217217
struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
218218

219-
if (PCI_SLOT(devfn)) {
220-
*val = ~0;
219+
if (PCI_SLOT(devfn))
221220
return PCIBIOS_DEVICE_NOT_FOUND;
222-
}
223221

224222
*val = dw_pcie_read_dbi(pci, where, size);
225223
return PCIBIOS_SUCCESSFUL;

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,9 @@ static int ks_pcie_config_legacy_irq(struct keystone_pcie *ks_pcie)
747747

748748
#ifdef CONFIG_ARM
749749
/*
750-
* When a PCI device does not exist during config cycles, keystone host gets a
751-
* bus error instead of returning 0xffffffff. This handler always returns 0
752-
* for this kind of faults.
750+
* When a PCI device does not exist during config cycles, keystone host
751+
* gets a bus error instead of returning 0xffffffff (PCI_ERROR_RESPONSE).
752+
* This handler always returns 0 for this kind of fault.
753753
*/
754754
static int ks_pcie_fault(unsigned long addr, unsigned int fsr,
755755
struct pt_regs *regs)

drivers/pci/controller/dwc/pcie-histb.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,8 @@ static int histb_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
127127
{
128128
struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
129129

130-
if (PCI_SLOT(devfn)) {
131-
*val = ~0;
130+
if (PCI_SLOT(devfn))
132131
return PCIBIOS_DEVICE_NOT_FOUND;
133-
}
134132

135133
*val = dw_pcie_read_dbi(pci, where, size);
136134
return PCIBIOS_SUCCESSFUL;

drivers/pci/controller/dwc/pcie-kirin.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,8 @@ static int kirin_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
530530
{
531531
struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
532532

533-
if (PCI_SLOT(devfn)) {
534-
*val = ~0;
533+
if (PCI_SLOT(devfn))
535534
return PCIBIOS_DEVICE_NOT_FOUND;
536-
}
537535

538536
*val = dw_pcie_read_dbi(pci, where, size);
539537
return PCIBIOS_SUCCESSFUL;

drivers/pci/controller/pci-aardvark.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
10371037
u32 reg;
10381038
int ret;
10391039

1040-
if (!advk_pcie_valid_device(pcie, bus, devfn)) {
1041-
*val = 0xffffffff;
1040+
if (!advk_pcie_valid_device(pcie, bus, devfn))
10421041
return PCIBIOS_DEVICE_NOT_FOUND;
1043-
}
10441042

10451043
if (pci_is_root_bus(bus))
10461044
return pci_bridge_emul_conf_read(&pcie->bridge, where,

drivers/pci/controller/pci-hyperv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus)
20302030
* If the memory enable bit is already set, Hyper-V silently ignores
20312031
* the below BAR updates, and the related PCI device driver can not
20322032
* work, because reading from the device register(s) always returns
2033-
* 0xFFFFFFFF.
2033+
* 0xFFFFFFFF (PCI_ERROR_RESPONSE).
20342034
*/
20352035
list_for_each_entry(hpdev, &hbus->children, list_entry) {
20362036
_hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command);

drivers/pci/controller/pci-mvebu.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,20 +814,16 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
814814
int ret;
815815

816816
port = mvebu_pcie_find_port(pcie, bus, devfn);
817-
if (!port) {
818-
*val = 0xffffffff;
817+
if (!port)
819818
return PCIBIOS_DEVICE_NOT_FOUND;
820-
}
821819

822820
/* Access the emulated PCI-to-PCI bridge */
823821
if (bus->number == 0)
824822
return pci_bridge_emul_conf_read(&port->bridge, where,
825823
size, val);
826824

827-
if (!mvebu_pcie_link_up(port)) {
828-
*val = 0xffffffff;
825+
if (!mvebu_pcie_link_up(port))
829826
return PCIBIOS_DEVICE_NOT_FOUND;
830-
}
831827

832828
/* Access the real PCIe interface */
833829
ret = mvebu_pcie_hw_rd_conf(port, bus, devfn,

drivers/pci/controller/pci-thunder-ecam.c

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus,
4141
}
4242
if (where_a == 0x4) {
4343
addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */
44-
if (!addr) {
45-
*val = ~0;
44+
if (!addr)
4645
return PCIBIOS_DEVICE_NOT_FOUND;
47-
}
46+
4847
v = readl(addr);
4948
v &= ~0xf;
5049
v |= 2; /* EA entry-1. Base-L */
@@ -56,10 +55,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus,
5655
u32 barl_rb;
5756

5857
addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */
59-
if (!addr) {
60-
*val = ~0;
58+
if (!addr)
6159
return PCIBIOS_DEVICE_NOT_FOUND;
62-
}
60+
6361
barl_orig = readl(addr + 0);
6462
writel(0xffffffff, addr + 0);
6563
barl_rb = readl(addr + 0);
@@ -72,10 +70,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus,
7270
}
7371
if (where_a == 0xc) {
7472
addr = bus->ops->map_bus(bus, devfn, bar + 4); /* BAR 1 */
75-
if (!addr) {
76-
*val = ~0;
73+
if (!addr)
7774
return PCIBIOS_DEVICE_NOT_FOUND;
78-
}
75+
7976
v = readl(addr); /* EA entry-3. Base-H */
8077
set_val(v, where, size, val);
8178
return PCIBIOS_SUCCESSFUL;
@@ -104,10 +101,8 @@ static int thunder_ecam_p2_config_read(struct pci_bus *bus, unsigned int devfn,
104101
}
105102

106103
addr = bus->ops->map_bus(bus, devfn, where_a);
107-
if (!addr) {
108-
*val = ~0;
104+
if (!addr)
109105
return PCIBIOS_DEVICE_NOT_FOUND;
110-
}
111106

112107
v = readl(addr);
113108

@@ -135,21 +130,17 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
135130
int where_a = where & ~3;
136131

137132
addr = bus->ops->map_bus(bus, devfn, 0xc);
138-
if (!addr) {
139-
*val = ~0;
133+
if (!addr)
140134
return PCIBIOS_DEVICE_NOT_FOUND;
141-
}
142135

143136
v = readl(addr);
144137

145138
/* Check for non type-00 header */
146139
cfg_type = (v >> 16) & 0x7f;
147140

148141
addr = bus->ops->map_bus(bus, devfn, 8);
149-
if (!addr) {
150-
*val = ~0;
142+
if (!addr)
151143
return PCIBIOS_DEVICE_NOT_FOUND;
152-
}
153144

154145
class_rev = readl(addr);
155146
if (class_rev == 0xffffffff)
@@ -176,10 +167,8 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
176167
}
177168

178169
addr = bus->ops->map_bus(bus, devfn, 0);
179-
if (!addr) {
180-
*val = ~0;
170+
if (!addr)
181171
return PCIBIOS_DEVICE_NOT_FOUND;
182-
}
183172

184173
vendor_device = readl(addr);
185174
if (vendor_device == 0xffffffff)
@@ -196,10 +185,9 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
196185
bool is_tns = (vendor_device == 0xa01f177d);
197186

198187
addr = bus->ops->map_bus(bus, devfn, 0x70);
199-
if (!addr) {
200-
*val = ~0;
188+
if (!addr)
201189
return PCIBIOS_DEVICE_NOT_FOUND;
202-
}
190+
203191
/* E_CAP */
204192
v = readl(addr);
205193
has_msix = (v & 0xff00) != 0;
@@ -211,10 +199,9 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
211199
}
212200
if (where_a == 0xb0) {
213201
addr = bus->ops->map_bus(bus, devfn, where_a);
214-
if (!addr) {
215-
*val = ~0;
202+
if (!addr)
216203
return PCIBIOS_DEVICE_NOT_FOUND;
217-
}
204+
218205
v = readl(addr);
219206
if (v & 0xff00)
220207
pr_err("Bad MSIX cap header: %08x\n", v);
@@ -268,10 +255,9 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
268255

269256
if (where_a == 0x70) {
270257
addr = bus->ops->map_bus(bus, devfn, where_a);
271-
if (!addr) {
272-
*val = ~0;
258+
if (!addr)
273259
return PCIBIOS_DEVICE_NOT_FOUND;
274-
}
260+
275261
v = readl(addr);
276262
if (v & 0xff00)
277263
pr_err("Bad PCIe cap header: %08x\n", v);

drivers/pci/controller/pci-thunder-pem.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ static int thunder_pem_bridge_read(struct pci_bus *bus, unsigned int devfn,
4141
struct pci_config_window *cfg = bus->sysdata;
4242
struct thunder_pem_pci *pem_pci = (struct thunder_pem_pci *)cfg->priv;
4343

44-
if (devfn != 0 || where >= 2048) {
45-
*val = ~0;
44+
if (devfn != 0 || where >= 2048)
4645
return PCIBIOS_DEVICE_NOT_FOUND;
47-
}
4846

4947
/*
5048
* 32-bit accesses only. Write the address to the low order

0 commit comments

Comments
 (0)