Skip to content

Commit 658f7ec

Browse files
Naveenaidubjorn-helgaas
authored andcommitted
PCI: thunder: Drop error data fabrication when config read fails
If config pci_ops.read() methods return failure, the PCI_OP_READ() and PCI_USER_READ_CONFIG() wrappers use PCI_SET_ERROR_RESPONSE() to set the data value, so there's no need to set it in the pci_ops.read() methods themselves. Drop the unnecessary data value fabrication when pci_ops.read() fails. Link: https://lore.kernel.org/r/22f471b638276422926c49f3d42ac41bc7b28b3d.1637243717.git.naveennaidu479@gmail.com Signed-off-by: Naveen Naidu <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 316df70 commit 658f7ec

File tree

2 files changed

+17
-33
lines changed

2 files changed

+17
-33
lines changed

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)