From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7791531715B; Sat, 28 Feb 2026 17:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300580; cv=none; b=g1eCNwuVCOM3tHr01wh3M6P8wQFtc3vaKyl+4H8ZalGnZ7r5DB1ehB9uV64cT8CF3b8YsSdraWS4esxO8EgebHYCvJ9mZllJv0TZRZV+RKPDQjU1HzBKLaiaaUCXnUDx9KkevASYMBcbhRcA1LW1DCFIhOEbvZcam81JenVfSy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300580; c=relaxed/simple; bh=UpEB/ASggR2f9TqfQpGKFDO7+IOK8UAr5GCaJxEYp/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IWh/2vq7g/g4qpueS5x6BPPEn+FteG9Jp/ac0VdT+vXDF3FczRZ5ygxuXgex3UofUqS1U0z7vAVfQa8nO9a7TWeX6DAy5rUzk8Oblx5P6sZ0NLW1C2ZVGpsh6OAFIptviu6XLLruGr72CGhIr6MTQKMA4oEl5yVE/M+OX5I/ptw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mM/iver5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mM/iver5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9480DC19423; Sat, 28 Feb 2026 17:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300580; bh=UpEB/ASggR2f9TqfQpGKFDO7+IOK8UAr5GCaJxEYp/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mM/iver5b/jUUf+Wy+2yvqjzIYUCmFQqd1/in5SUtC8W28BwZ5zE1bxHRq2cPfXck gddVw5kaTSBNWUIwG0REumJckSu5ciPBvl6nwyawBdils5ZDBcTyt4+hkh8yCa9P52 VGz8ZaWRMFMSuJqEUmq3YXrKEsOYFbhxpNCWvMX4r5azgWfCAwoJfuwpfcRxIfwDw7 9AXS56g2olDdTekdFF0RAsy3TmVtzFj9o76oHot5tkiGr+loiGGTbNa3WjyJZvWqlH mgBgyUc2hF5clvfKgG3JaoAZ7RicC6obPbKNdIu17c1VBngqwmcisgy+zHCvv5M2Gg IR81iqRlsdJ5Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Niklas Schnelle , Benjamin Block , Farhan Ali , Heiko Carstens , Sasha Levin Subject: [PATCH 6.19 621/844] s390/pci: Handle futile config accesses of disabled devices directly Date: Sat, 28 Feb 2026 12:28:54 -0500 Message-ID: <20260228173244.1509663-622-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Niklas Schnelle [ 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 Reviewed-by: Benjamin Block Reviewed-by: Farhan Ali Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/pci/pci.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 57f3980b98a92..7f44b0644a20e 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -231,24 +231,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); -- 2.51.0