Thread (42 messages) 42 messages, 6 authors, 2021-10-14

Re: [PATCH 02/22] PCI: Unify PCI error response checking

From: Rob Herring <robh@kernel.org>
Date: 2021-10-11 22:06:04
Also in: linux-pci, lkml

On Mon, Oct 11, 2021 at 11:08:32PM +0530, Naveen Naidu wrote:
quoted hunk ↗ jump to hunk
An MMIO read from a PCI device that doesn't exist or doesn't respond
causes a PCI error.  There's no real data to return to satisfy the
CPU read, so most hardware fabricates ~0 data.

Use SET_PCI_ERROR_RESPONSE() to set the error response and
RESPONSE_IS_PCI_ERROR() to check the error response during hardware
read.

These definitions make error checks consistent and easier to find.

Signed-off-by: Naveen Naidu <redacted>
---
 drivers/pci/access.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 46935695cfb9..e1954bbbd137 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -81,7 +81,7 @@ int pci_generic_config_read(struct pci_bus *bus, unsigned int devfn,
 
 	addr = bus->ops->map_bus(bus, devfn, where);
 	if (!addr) {
-		*val = ~0;
+		SET_PCI_ERROR_RESPONSE(val);
This to me doesn't look like kernel style. I'd rather see a define 
replace just '~0', but I defer to Bjorn.
 		return PCIBIOS_DEVICE_NOT_FOUND;
Neither does this using custom error codes rather than standard Linux 
errno. I point this out as I that's were I'd start with the config 
accessors. Though there are lots of occurrences so we'd need a way to do 
this in manageable steps.

Can't we make PCI_OP_READ and PCI_USER_READ_CONFIG set the data value 
and delete the drivers all doing this? Then we have 2 copies (in source) 
rather than the many this series modifies. Though I'm not sure if there 
are other cases of calling pci_bus.ops.read() which expect to get ~0.

Rob
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help