summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Schnelle <schnelle@linux.ibm.com>2026-01-08 16:45:53 +0100
committerSasha Levin <sashal@kernel.org>2026-03-04 07:20:47 -0500
commit7e70c349d46c7ac17c65ea9956d9f487c7cf2515 (patch)
tree292c0ff71932a30e8fee5009e56fdb26ddbc0005
parentdcb2d43ae73ce2893cfc2882c2c84164e0cc74f6 (diff)
s390/pci: Handle futile config accesses of disabled devices directly
[ Upstream commit 84d875e69818bed600edccb09be4a64b84a34a54 ] On s390 PCI busses and slots with multiple functions may have holes because PCI functions are passed-through by the hypervisor on a per function basis and some functions may be in standby or reserved. This fact is indicated by returning true from the hypervisor_isolated_pci_functions() helper and triggers common code to scan all possible devfn values. Via pci_scan_single_device() this in turn causes config reads for the device and vendor IDs, even for PCI functions which are in standby and thereofore disabled. So far these futile config reads, as well as potentially writes, which can never succeed were handled by the PCI load/store instructions themselves. This works as the platform just returns an error for a disabled and thus not usable function handle. It does cause spamming of error logs and additional overhead though. Instead check if the used function handle is enabled in zpci_cfg_load() and zpci_cfg_write() and if not enable directly return -ENODEV. Also refactor zpci_cfg_load() and zpci_cfg_store() slightly to accommodate the new logic while meeting modern kernel style guidelines. Cc: stable@vger.kernel.org Fixes: a50297cf8235 ("s390/pci: separate zbus creation from scanning") Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Reviewed-by: Benjamin Block <bblock@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/s390/pci/pci.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 394c69fda399..606a664457b6 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -206,24 +206,33 @@ int zpci_fmb_disable_device(struct zpci_dev *zdev)
static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len)
{
u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
+ int rc = -ENODEV;
u64 data;
- int rc;
+
+ if (!zdev_enabled(zdev))
+ goto out_err;
rc = __zpci_load(&data, req, offset);
- if (!rc) {
- data = le64_to_cpu((__force __le64) data);
- data >>= (8 - len) * 8;
- *val = (u32) data;
- } else
- *val = 0xffffffff;
+ if (rc)
+ goto out_err;
+ data = le64_to_cpu((__force __le64)data);
+ data >>= (8 - len) * 8;
+ *val = (u32)data;
+ return 0;
+
+out_err:
+ PCI_SET_ERROR_RESPONSE(val);
return rc;
}
static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len)
{
u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
+ int rc = -ENODEV;
u64 data = val;
- int rc;
+
+ if (!zdev_enabled(zdev))
+ return rc;
data <<= (8 - len) * 8;
data = (__force u64) cpu_to_le64(data);