Commit f4f7eb43 authored by Naveen Naidu's avatar Naveen Naidu Committed by Bjorn Helgaas
Browse files

PCI: Set error response data when config read fails



When a PCI config read fails, most PCI host bridges fabricate ~0 data to
complete the CPU read.  But some host bridges do not; their drivers may
only return an error from the pci_ops.read() method.

In PCI_OP_READ() and PCI_USER_READ_CONFIG(), use PCI_SET_ERROR_RESPONSE()
to set the data value to indicate an error when pci_ops.read() fails.

This means the host bridge driver no longer needs to fabricate error data
when they detect errors.

This makes error response fabrication consistent and helps in removal of a
lot of repeated code.

Suggested-by: default avatarRob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/4188fc5465631ce0d472d1423de3d9fb2f09b8ff.1637243717.git.naveennaidu479@gmail.com


Signed-off-by: default avatarNaveen Naidu <naveennaidu479@gmail.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
Reviewed-by: default avatarPali Rohár <pali@kernel.org>
parent 57bdeef4
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ int noinline pci_bus_read_config_##size \
	if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;	\
	pci_lock_config(flags);						\
	res = bus->ops->read(bus, devfn, pos, len, &data);		\
	if (res)							\
		PCI_SET_ERROR_RESPONSE(value);				\
	else								\
		*value = (type)data;					\
	pci_unlock_config(flags);					\
	return res;							\
@@ -228,6 +231,9 @@ int pci_user_read_config_##size \
	ret = dev->bus->ops->read(dev->bus, dev->devfn,			\
					pos, sizeof(type), &data);	\
	raw_spin_unlock_irq(&pci_lock);				\
	if (ret)							\
		PCI_SET_ERROR_RESPONSE(val);				\
	else								\
		*val = (type)data;					\
	return pcibios_err_to_errno(ret);				\
}									\