linux/arch/s390
Niklas Schnelle d693d896a6 s390/pci: Handle futile config accesses of disabled devices directly
[ Upstream commit 84d875e698 ]

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: a50297cf82 ("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>
History 2026-03-04 07:20:29 -05:00
..
appldata s390/appldata: use struct_size() helper 2020-06-29 16:32:34 +02:00
boot s390/boot: Remove alt_stfle_fac_list from decompressor 2024-06-16 13:39:41 +02:00
configs s390: update defconfigs 2021-09-15 14:29:21 +02:00
crypto crypto: s390/aes - Fix buffer overread in CTR mode 2024-02-23 08:54:24 +01:00
hypfs s390/hypfs: Enable limited access during lockdown 2025-08-28 16:24:39 +02:00
include s390/time: Use monotonic clock in get_cycles() 2025-08-28 16:24:20 +02:00
kernel s390/perf: Disable register readout on sampling events 2026-03-04 07:19:59 -05:00
kvm KVM: s390: Don't use %pK through tracepoints 2025-05-02 07:44:36 +02:00
lib s390/uaccess: add missing earlyclobber annotations to __clear_user() 2023-04-05 11:25:01 +02:00
mm mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd() 2025-08-28 16:24:32 +02:00
net s390/bpf: Store backchain even for leaf progs 2025-06-27 11:05:13 +01:00
pci s390/pci: Handle futile config accesses of disabled devices directly 2026-03-04 07:20:29 -05:00
purgatory s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS 2026-03-04 07:19:57 -05:00
tools s390/disassembler: add instructions 2021-07-27 09:39:19 +02:00
Kbuild s390/numa: move code to arch/s390/kernel 2020-08-11 18:16:55 +02:00
Kconfig s390: remove unneeded 'select BUILD_BIN2C' 2022-07-07 17:53:27 +02:00
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile Makefile.compiler: replace cc-ifversion with compiler-specific macros 2025-12-07 06:09:32 +09:00