From nobody Sat Jul 25 01:52:22 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 661C63976A7; Mon, 20 Jul 2026 19:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575516; cv=none; b=U0rP+PWnxDwGEFqhJgk3oJ4sQa/eigPqVrNLhkOWoXfLnQHWst6Ue43f2G+N3b1ov5rBPHBhPJOLsqvtl8b7v7isGO0tyqcMyiTU9hnRnfnq7RmyMOxOyzkjrImlJixF38Aa8GQTK7Zhf7YKri+GtfydtPyEJNPFQlub9JkB9Jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575516; c=relaxed/simple; bh=6CRJnd0/Ymbiy3TKzN1Eum5qPgq+Fefp0E09H7dsQoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JS30kiQZ8dwUCJYodJ/cjLHPl0FV7cYRMWUYWSN5dkFy5HHSoJN+Tm8tTi9UMrUmExhwZpSv5Og0RzSptd2NfGVVp1mXdIpHBAeLrF2yT9Lyx4QbxsZM/+b260jRyHVQfwrWUfjgYXvvQMcHGhehdEZyEOxqP+4fbs/t1nZZI6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=phdLzT/l; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="phdLzT/l" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66KHBkdY2816018; Mon, 20 Jul 2026 19:25:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=kHEufnb1gKWmIpNJc HNQTLEhjMPk//7ya5bzvIwvv8c=; b=phdLzT/limwNbOfB7Yd/18E/IJIFQMGA0 ntNcEWVRF8W9cVvOBHXv0n1Bsb65wwnBrKZi3O8XLP1e8AdtrxgevgZYqOXBDD05 FuImvOBAQEcjkMx+IqopgjIAR30/fr8cS1T9+V+svz4CToSxXesGzx6W9QFQ9lbw pM78WfN1qSuFMESd4eAuTBi5uXNLE61vK1sxLhtbhUSrZcu5xLDeTpMWO6CDtzD2 SjrGoOPRkSYngXPzGKMUUYgZ3b8MVhMxIv8jeTziKXJXvrBgJgAttc2urJKs8nbQ R6kCSzTDXdofuMFaZLUWuAJstWEaUnVO6Pslqt5DJDmg5ovRFnRFQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fg790s56t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:10 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66KJ4bFU014874; Mon, 20 Jul 2026 19:25:09 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fgmtjq11m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:09 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66KJP7Xf13369918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jul 2026 19:25:08 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE6335805C; Mon, 20 Jul 2026 19:25:07 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEF4658058; Mon, 20 Jul 2026 19:25:06 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.209]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Jul 2026 19:25:06 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, stable@vger.kernel.org Subject: [PATCH v22 1/4] PCI: Allow per function PCI slots to fix slot reset on s390 Date: Mon, 20 Jul 2026 12:25:02 -0700 Message-ID: <20260720192505.2957-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720192505.2957-1-alifm@linux.ibm.com> References: <20260720192505.2957-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7EKvy9ykML73rqI7o2edkAi4PgIzOOyw X-Authority-Analysis: v=2.4 cv=V6RNF+ni c=1 sm=1 tr=0 ts=6a5e7616 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=9_SSeoq7eJPDN4OswFYA:9 a=O8hF6Hzn-FEA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfX0DuK3ex/U0Jf yQu5tzzupcNHfVyrdSKjHBXXhaYKheBZLrSYhQe9xG62Hge9buErByIqm0taWMwnSVUW3pq2eKS xL4hUV7smlGDf1So37cp3wVvmTUiLiI= X-Proofpoint-GUID: 7EKvy9ykML73rqI7o2edkAi4PgIzOOyw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfX2rNHjYIhQyrn 9ZbjOhoJo8SPmo9iLbC9ZpLayBeQNrauH029Hn4I2EL2Mfl9HIuimbLOIgnHTpH9YrOTo6qhk6C aZVyq2mEoOTAvOQxDLCRTxo7dHPCNyRe+ZXgx5vX3/99zLYjvoHLwZOmP3Ebxxt198zmPDRbpfp L3Y6P/IEvpl8olY0HHQity4o1l0BDLlu9Z+7lhYt5acboT4D/JeIe7vrexubhfi+jcWcMVNJzKc IWaJIGKhiFJKVyWw/6sk0O0BMDBN4DXqi00ltSnsqyHnmr1kQVQ8iOEXrDuJFO4wYSa2X3XAJW0 LqxD+o6BoTQwOPUYkmSum63juAhfN6FMwesngXs2v/YBKL/JoSmkUmHCf5FxfqVgrkpLkAEIVD+ 7yd/+US5y2Bq8Uiorp5lduQ4X9L3J/7UDvZ31PZl9A+plFXVA/uKX8yJelh1ooQe6zO+fgpKJMp y7RlB1Jk5IFViyGEHbA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-20_04,2026-07-20_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607200209 Content-Type: text/plain; charset="utf-8" On s390 systems, which use a machine level hypervisor, PCI devices are always accessed through a form of PCI pass-through which fundamentally operates on a per PCI function granularity. This is also reflected in the s390 PCI hotplug driver which creates hotplug slots for individual PCI functions. Its reset_slot() function, which is a wrapper for zpci_hot_reset_device(), thus also resets individual functions. Currently, the pci_create_slot() assigns the same pci_slot object to multifunction devices. This approach worked fine on s390 systems that only exposed virtual functions as individual PCI domains to the operating system. Since commit 44510d6fa0c0 ("s390/pci: Handling multifunctions") s390 supports exposing the topology of multifunction PCI devices by grouping them in a shared PCI domain. This creates a problem when resetting a function through the hotplug driver's slot_reset() interface. When attempting to reset a function through the hotplug driver, the shared slot assignment causes the wrong function to be reset instead of the intended one. It also leaks memory as we do create a pci_slot object for the function, but don't correctly free it in pci_slot_release(). Add a flag for struct pci_slot to allow per function PCI slots for functions managed through a hypervisor, which exposes individual PCI functions while retaining the topology. Since we can use all 8 bits for slot 'number' (for ARI devices), change slot 'number' u16 to account for special values -1 and PCI_SLOT_ALL_DEVICES. Fixes: 44510d6fa0c0 ("s390/pci: Handling multifunctions") Cc: stable@vger.kernel.org Suggested-by: Niklas Schnelle Reviewed-by: Niklas Schnelle Signed-off-by: Farhan Ali --- drivers/pci/hotplug/rpaphp_slot.c | 2 +- drivers/pci/pci.c | 5 +++-- drivers/pci/slot.c | 33 +++++++++++++++++++++++-------- include/linux/pci.h | 8 ++++++-- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp= _slot.c index 67362e5b9971..92eabf5f61b9 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c @@ -84,7 +84,7 @@ int rpaphp_register_slot(struct slot *slot) struct hotplug_slot *php_slot =3D &slot->hotplug_slot; u32 my_index; int retval; - int slotno =3D -1; + int slotno =3D PCI_SLOT_PLACEHOLDER; =20 dbg("%s registering slot:path[%pOF] index[%x], name[%s] pdomain[%x] type[= %d]\n", __func__, slot->dn, slot->index, slot->name, diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 77b17b13ee61..350bae907ebf 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4897,8 +4897,9 @@ static int pci_reset_hotplug_slot(struct hotplug_slot= *hotplug, bool probe) =20 static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe) { - if (dev->multifunction || dev->subordinate || !dev->slot || - dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET) + if (dev->subordinate || !dev->slot || + dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET || + (dev->multifunction && !dev->slot->per_func_slot)) return -ENOTTY; =20 return pci_reset_hotplug_slot(dev->slot->hotplug, probe); diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index 6d5cd37bfb1e..894d6213ed30 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c @@ -37,7 +37,7 @@ static const struct sysfs_ops pci_slot_sysfs_ops =3D { =20 static ssize_t address_read_file(struct pci_slot *slot, char *buf) { - if (slot->number =3D=3D 0xff) + if (slot->number =3D=3D (u16)PCI_SLOT_PLACEHOLDER) return sysfs_emit(buf, "%04x:%02x\n", pci_domain_nr(slot->bus), slot->bus->number); @@ -72,6 +72,23 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot= , char *buf) return bus_speed_read(slot->bus->cur_bus_speed, buf); } =20 +static bool pci_dev_matches_slot(struct pci_dev *dev, struct pci_slot *slo= t) +{ + if (slot->per_func_slot) + return dev->devfn =3D=3D slot->number; + + return slot->number =3D=3D PCI_SLOT_ALL_DEVICES || + PCI_SLOT(dev->devfn) =3D=3D slot->number; +} + +static bool pci_slot_enabled_per_func(void) +{ + if (IS_ENABLED(CONFIG_S390)) + return true; + + return false; +} + static void pci_slot_release(struct kobject *kobj) { struct pci_dev *dev; @@ -82,8 +99,7 @@ static void pci_slot_release(struct kobject *kobj) =20 down_read(&pci_bus_sem); list_for_each_entry(dev, &slot->bus->devices, bus_list) - if (slot->number =3D=3D PCI_SLOT_ALL_DEVICES || - PCI_SLOT(dev->devfn) =3D=3D slot->number) + if (pci_dev_matches_slot(dev, slot)) dev->slot =3D NULL; up_read(&pci_bus_sem); =20 @@ -187,8 +203,7 @@ void pci_dev_assign_slot(struct pci_dev *dev) =20 mutex_lock(&pci_slot_mutex); list_for_each_entry(slot, &dev->bus->slots, list) - if (slot->number =3D=3D PCI_SLOT_ALL_DEVICES || - PCI_SLOT(dev->devfn) =3D=3D slot->number) + if (pci_dev_matches_slot(dev, slot)) dev->slot =3D slot; mutex_unlock(&pci_slot_mutex); } @@ -267,7 +282,7 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent= , int slot_nr, =20 mutex_lock(&pci_slot_mutex); =20 - if (slot_nr =3D=3D -1) + if (slot_nr =3D=3D PCI_SLOT_PLACEHOLDER) goto placeholder; =20 /* @@ -298,6 +313,9 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent= , int slot_nr, slot->bus =3D pci_bus_get(parent); slot->number =3D slot_nr; =20 + if (pci_slot_enabled_per_func()) + slot->per_func_slot =3D 1; + slot->kobj.kset =3D pci_slots_kset; =20 slot_name =3D make_slot_name(name); @@ -318,8 +336,7 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent= , int slot_nr, =20 down_read(&pci_bus_sem); list_for_each_entry(dev, &parent->devices, bus_list) - if (slot_nr =3D=3D PCI_SLOT_ALL_DEVICES || - PCI_SLOT(dev->devfn) =3D=3D slot_nr) + if (pci_dev_matches_slot(dev, slot)) dev->slot =3D slot; up_read(&pci_bus_sem); =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index 64b308b6e61c..6141787f7417 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -79,14 +79,18 @@ * and, if ARI Forwarding is enabled, functions may appear to be on multip= le * devices. */ -#define PCI_SLOT_ALL_DEVICES 0xfe +#define PCI_SLOT_ALL_DEVICES 0xfeff + +/* Used to identify a slot as a placeholder */ +#define PCI_SLOT_PLACEHOLDER -1 =20 /* pci_slot represents a physical slot */ struct pci_slot { struct pci_bus *bus; /* Bus this slot is on */ struct list_head list; /* Node in list of slots */ struct hotplug_slot *hotplug; /* Hotplug info (move here) */ - unsigned char number; /* Device nr, or PCI_SLOT_ALL_DEVICES */ + u16 number; /* Device nr, or PCI_SLOT_ALL_DEVICES */ + unsigned int per_func_slot:1; /* Allow per function slot */ struct kobject kobj; }; =20 --=20 2.43.0 From nobody Sat Jul 25 01:52:22 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 C9FB33AC0F0; Mon, 20 Jul 2026 19:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575517; cv=none; b=BkKBCSVfV19gFtERxqVHfY/DLX6Na4F3D+8qC6gMDlZdV6BsMb0Aci5OAJlwAVIplvoka5AFSjy3SBg3DDcNe113zEskJtm9QNk0XmLSLKFfCcxGzLXvwdO8ciT7nchMp4TbvJBhg4O+JLa43VRzGVZuOlBE2reJ/P5ozJyivow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575517; c=relaxed/simple; bh=S2J6GfTA17MRPi8hVmy1uCqMXutp4PYcAl3ULfkwQ5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J9QS7lYzJP/zsyilzcXA+bqFmd4fkyDmQ/ankS8PHQB91bupMhII3C0uq8lMBEJ3K/KsQO/NWr08V+CqwL/RmqerneOCWeyxmJwcJg0PkKVCgD6iLymw/FYuG8Q3Q8EvdJ/pKp62sqnAEg//mJu4s6N0KQhzKWBFsihEOXpAI5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=OZ4vWrEp; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="OZ4vWrEp" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66KHBlca2713249; Mon, 20 Jul 2026 19:25:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=12J8MB6C2cv981QXO JBi1IBshXR9vjAE306Ivlw7e6Y=; b=OZ4vWrEpPT6vUbAlWlGg7U9SfcPj49h+M y1kh3hLZUojTEeNnEGx7YZrCdDqLF5xvSetqti1M854cylNZHOfoyoMrwHcdrJkA YblbaXQOwv6hSjk/ycK/uinwdDd5zcdFhxFaptHmyOGFIOzzGtnuW8dFfBOsq9Uc dnW4XT2k+zb8UHXlLVs6N5ATl5aQ7qyyDjKoTG+CSguNRAt6oqp5yJLNBe+LX9X+ VQzg6pbmXs9N5/bZTfsePTy5imfspkKIu3QLDXlSH4MzwZFuU+1nRzBtkYRL55yg Q5lS6hTas7C1eVAAHAbvumaHfgbpCTDMxNeVtAts1EGeNUNRQTOzA== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fg78g0u17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:11 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66KJJj07031559; Mon, 20 Jul 2026 19:25:10 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fgnagxypc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:10 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66KJP9W217629856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jul 2026 19:25:09 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15B9058059; Mon, 20 Jul 2026 19:25:09 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AA7658058; Mon, 20 Jul 2026 19:25:08 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.209]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Jul 2026 19:25:07 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Bjorn Helgaas Subject: [PATCH v22 2/4] PCI: Avoid saving config space state if inaccessible Date: Mon, 20 Jul 2026 12:25:03 -0700 Message-ID: <20260720192505.2957-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720192505.2957-1-alifm@linux.ibm.com> References: <20260720192505.2957-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfX7sREyUsQcyUF raefviX4KSF+Ek0V8Kt/CUpVoTQa7guo6B+d9erxIVIdZnmyYcaS5sJ0yUyW9kTf8I1V18uE9WB Fs7P+nvJAHu1Na1Te7SEN+wjU7yUW0Nn3Qjcqu45WeYWzE2UXBzzl3Rzk6kWFrUJGji2j8/ek0N h3wc/iut9dXW0kdg2uYG211QB54d8XZYZhoO81TfanJEf3q7hyIYmNDRJX+MIi3DLEtnMuw/iM6 4uQNNGGlsI/8ZNgk5Jg0gIFwrqp0WQM5FigZHTZKHVxJ4RqPVHU7pCLvjUtgxs1k5GPQQ1/beOI eFYBzeNB3AWvgDJy6zihhnUqoPu7n8k+yq7gRLu6xO9DBwoKluaUeMF17Ydn5plmKOzVcCgiNP1 Ahw+k26MB4rq/tSWgra6s+Q44pU3epG9Td523gdQCDcBsltKK6sdhcfx42xWgSTH2gEGaqBzkqr whuhC3FKPApt+Cr9/5A== X-Proofpoint-GUID: FxK6uxDDzsXrxsanppR8FXEokdRY4pUM X-Authority-Analysis: v=2.4 cv=MelcfZ/f c=1 sm=1 tr=0 ts=6a5e7617 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=1XWaLZrsAAAA:8 a=qS04rNcGil1I7-YeviAA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfX3WVSfM3Vqw2d yKjl4ZJwVY5JFYlXVNMMJtOx0CI8pWclY9/dreol5PM29ZG9hzjaBuQvn65mm41hP5rh08NvUnq HuVqMu0TUxHyy80JXe1KWPgYwzWBZrI= X-Proofpoint-ORIG-GUID: Xw6RySL16AKrwomTYiDoKYbPajI0ovp2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-20_04,2026-07-20_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 spamscore=0 clxscore=1015 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607200209 Content-Type: text/plain; charset="utf-8" The current reset process saves the device's config space state before reset and restores it afterward. However errors may occur unexpectedly and it may then be impossible to save config space because the device may be inaccessible (e.g. DPC). This results in saving invalid values that get written back to the device during state restoration. With a reset we want to recover/restore the device into a functional state. So avoid saving the state of the config space when the device config space is inaccessible. Reviewed-by: Niklas Schnelle Reviewed-by: Bjorn Helgaas Signed-off-by: Farhan Ali --- drivers/pci/pci.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 350bae907ebf..e8d7de77241a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -713,6 +713,27 @@ u16 pci_find_dvsec_capability(struct pci_dev *dev, u16= vendor, u16 dvsec) } EXPORT_SYMBOL_GPL(pci_find_dvsec_capability); =20 +static bool pci_dev_config_accessible(struct pci_dev *dev, char *msg) +{ + u32 val; + + /* + * If device's config space is inaccessible it can return ~0 for + * any reads. Since VFs can also return ~0 for Device and Vendor ID + * check Command and Status registers. Note that this is racy + * because the device may become inaccessible partway through + * next access. + */ + pci_read_config_dword(dev, PCI_COMMAND, &val); + if (PCI_POSSIBLE_ERROR(val)) { + pci_warn(dev, "Device config space inaccessible; unable to %s\n", + msg); + return false; + } + + return true; +} + /** * pci_find_parent_resource - return resource region of parent bus of given * region @@ -5059,6 +5080,9 @@ static void pci_dev_save_and_disable(struct pci_dev *= dev) */ pci_set_power_state(dev, PCI_D0); =20 + if (!pci_dev_config_accessible(dev, "save state")) + return; + pci_save_state(dev); /* * Disable the device by clearing the Command register, except for --=20 2.43.0 From nobody Sat Jul 25 01:52:22 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 A78C83ABD8E; Mon, 20 Jul 2026 19:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575521; cv=none; b=D1JBPpHUbR4MbmY98kQNkNZmY4IARMZAi8vfiPTIWFjKJfA6LyhhFT1ursm5UU+iM2sOylvdfoGQqgz5g83U8hBcG4WfoQ2C/rJAhX77ZpI37OHVxqvckoCOPSyvBOUOk1MHEQa6o4zTig5kXKKmiqaNCQmaBKvPnnqBJq7lJsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575521; c=relaxed/simple; bh=cX5TZtvSZwarWBI5c6PMZ7i7miA4OLjgPxAssK4YgaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nJ29+no5LWLf6EqO508SZA80jrrNkUgST/UJ3/FsgHf6i+d+33PfQ+ww+pp/9aWycePtsybDB3A3iSzolHA2E1kcEEu3GTkfYQ6E/4W6IAM9Ec/f3kCPoLY8lZI7ouIDPJtyxd23XKUOJ4QWcvt++NPrkWm77l+Rf2yqzuxyWEg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=T0Kkbw9Y; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="T0Kkbw9Y" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66KHBwxW2731473; Mon, 20 Jul 2026 19:25:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=vXU3DidQiGyzHYE/9 ch2T/ZRaHPRlcHfwPGBi3+olgE=; b=T0Kkbw9YL+WQKZY6n1b3YLqsY7mNyQTrj xz3d7anMUc8iUiAnjLZkJMvQBa1rgC3+xUdV34WrEy6o1WJSDosPC6/rPC4w8Z/M g2BmiMIXAuP4MHgHXlPDt7IrrE7PX25ArsDi4MhSK9T8rLv/3Pbl8Xelkc8wgJo3 5Uylbm0l67lOfDcQRDL/0Uoovsy1GA43snTNi6j4i1tFP35sa521twektnqDGshu pO3YqUarBexgBeLHyyiav9tUTuN7hckj9DtMeLYxJ4NOGhOYqsimVN2MIVnxPNmB 8BBtIdoQoJ7YtpZrq35mtjgoI/cBgOAB9Ck34nJEplYMr+2pHPK4A== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fg77k0v67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:12 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66KJJZWK019247; Mon, 20 Jul 2026 19:25:11 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fgm6vy517-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:11 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66KJPAio328444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jul 2026 19:25:10 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 445915805B; Mon, 20 Jul 2026 19:25:10 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C8B858058; Mon, 20 Jul 2026 19:25:09 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.209]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Jul 2026 19:25:09 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Benjamin Block Subject: [PATCH v22 3/4] PCI: Fail FLR when config space is inaccessible Date: Mon, 20 Jul 2026 12:25:04 -0700 Message-ID: <20260720192505.2957-4-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720192505.2957-1-alifm@linux.ibm.com> References: <20260720192505.2957-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=HJXz0Itv c=1 sm=1 tr=0 ts=6a5e7618 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=1owyFLT6pZZ0tE0DW5YA:9 a=zgiPjhLxNE0A:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfXzKKmhqlBXQgu XLnIP88UDV6RaWll19UvC9MBChhuAy9SDDJf76K/pk06RpDHPKFi774SYf9Rz8UM84Dft32LkLd uCU0Tm5+A2qKGujfMXshaGtXpuBjAaz4PqlqUHP/yy9t9EywWRTnlIAIELhJlqHQkSuMXDHYIli h52ZQCjUrCurYQH5LAInh69/gEXZ9emk881WbPpMA26bvOISGji7vTioeHXZCUWykCYCJyiDqO4 umpHDKm1qFKwSE7VflVGzfxmNjubdHk+TKLAptNtvqjP3xrAdFPcAkQBn7foiCDNgBhg8oIh/i2 tQwxDrRGCnpA/zcimtnyesRBCC2vW2km7iXn7s4iYCUG2jWY8hl7My40KVtPOm1xZv+o82E68Kh aPLpCHZa84S2kzxIolAGE3vr+wjY6DhicU3FnoWW5aNK/xtOFnFspuZwuNKNfKYrcLnA6zpqORA EKCGBO8kqEcUr8QS/3Q== X-Proofpoint-ORIG-GUID: V-BKkZF64b8tfOnZYXBHFbm4Np-9dLcz X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfX1SIC8xyQU7cL dCsqv7Dqm63vliJHBYzmtnlI+riVe/LDxZz9Khj4IvxT2lSkOD86EoEXTmZnnUJaXGDLK9Jf7Mk cozqNtdb0TkVGeE9FESJWg24dPr7oW8= X-Proofpoint-GUID: V-BKkZF64b8tfOnZYXBHFbm4Np-9dLcz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-20_04,2026-07-20_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 malwarescore=0 impostorscore=0 clxscore=1015 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607200209 Content-Type: text/plain; charset="utf-8" If a device is in an error state, then it's config space may not be accssible. Add additional check to validate if a device's config space is accessible before doing an FLR reset. Reviewed-by: Benjamin Block Reviewed-by: Niklas Schnelle Signed-off-by: Farhan Ali --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e8d7de77241a..9a9d021301c4 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4384,6 +4384,9 @@ int pcie_flr(struct pci_dev *dev) { int ret; =20 + if (!pci_dev_config_accessible(dev, "FLR")) + return -ENOTTY; + if (!pci_wait_for_pending_transaction(dev)) pci_err(dev, "timed out waiting for pending transaction; performing func= tion level reset anyway\n"); =20 --=20 2.43.0 From nobody Sat Jul 25 01:52:22 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 F27903AC0E4; Mon, 20 Jul 2026 19:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575521; cv=none; b=lZ/Y8LR34gXD1xyw+ccw5DbdJvi3oy8+r/Jj4K3m16xxZQ6KyaQ49D5/HsaM9ID04+q55CGzhHTPESMZFSSo/rEiBIfSttDt8b+xLxaKV6L1ALc1hICLjCGj48XkrdR/xd9q5aIolXpl87lhQjgr9AD9hYSjvmpO5qYXQ55fRnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784575521; c=relaxed/simple; bh=gKQYf74xPpytI8rbZnvPeewbN3H/KzF0nc088tK6OYs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CfxPKfIBJYhyTU0BK+OPSd3U5Nqb37vgnyccYLcnPTgQkSj2IsTn06o2aYGdz7PwXXwauWNVjHEEcFu94xif9mY8dc1cG2du8jjJT5KSlE9Nuj/gNs9Zo7R3eBYA1y3lKFmOXduXX2fJCVF+kTJhS5K9tZv1Xp9JsrFTi8tg+UU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=P28roB36; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="P28roB36" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66KHBhJY2810925; Mon, 20 Jul 2026 19:25:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=q3mWEO+m7Q0z7JDH5 ZGSHJF5tisumNe9dB4cIXGURIs=; b=P28roB36tWt0OAZwdpubO0IfOHngdfLN6 L8UQavWBwn1QULINcft3H5tU3R9BYrojIr1xkWYIVyB8cP14dDZ/IjQ/fQULQkMD 1nO9nMYyTbGFGMD4h2S4+dzo5suQH0PEO0wMTi8mLwFXm9X9u2q7oEWhGTlcL/Z4 k88J4DD/RWpfodrYRk0iaLzAdodLjbqZiZDxLdorvfgRb9yacBnwPSWO3cEPRUrH dPXGeqE3C2muBEYPeRREef2KaUay1XxQ74OKlN/Qbwtm2yVMKShWoTw6QxZkJQpV JY/K4aKISY6wmau8XDF14Ttx7zcRNobc2gryioIrG5jMgbCX8tWow== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fg7ah0u2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:13 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66KJJiXM015870; Mon, 20 Jul 2026 19:25:12 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4fgp1g6u21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2026 19:25:12 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66KJPBwA24510990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jul 2026 19:25:11 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85A1A5805B; Mon, 20 Jul 2026 19:25:11 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7083958061; Mon, 20 Jul 2026 19:25:10 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.209]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Jul 2026 19:25:10 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, stable@vger.kernel.org, Thomas Gleixner Subject: [PATCH v22 4/4] PCI/MSI: Enable memory decoding before restoring MSI-X messages Date: Mon, 20 Jul 2026 12:25:05 -0700 Message-ID: <20260720192505.2957-5-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720192505.2957-1-alifm@linux.ibm.com> References: <20260720192505.2957-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: IgoQ5nNaDeEei3wx9TEk3XecY-FOnh7K X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfX7qa2XaBjK0fu gddfoajBFQTVs0Fg5Q19OFFXID/+o9ZucDnrlMdDmVu8vqK7L+3nfnmZpspThvWUHY9NKle1OOj lR1VS46f7uwBR/CBtFtWleghDRPmnFxNLv+7LYeCtLGlaYHzKPp2p5BzVVNK4uBtXqCf93j93rr gbx8/pmIkkswVr+xA7JWkFtzkTHNPGfwjn3CxB1IwWbCkea7uHH7hPFIQs/cM0U0gYhNEYsOIAG TskAqToZIlBsTFjb585x5ph3RUUNv0pHAewtz7TUlCdqyXFxabaMavViWl6SggUOdHwbVmp6QRV 3s6WeiebwZ15bs0Ovd8pdtnXtRuLpUV07YjyzZVymlgpoencZv5sr7hDgYoGYt26I8iY5Tqt4Dm Fhj1GLZHpK5pZuFyXHpMHBu0H4iMeQHvU4FTwXJlLWfLzKSGhUPRN49JqGf504PdmeVPZnLB33s hd7pXvlGITa1fHu1vNg== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIwMDIwOSBTYWx0ZWRfXx5WdqgslS806 llWygAz3HDOCTjosWPEudO0DAMxAxlHSLWJ6W27d26QBwysqrsw4sNOs06HhZAXSFp+V8zBGD32 B2iz7okkL8OVcsDPoZX2fXcZmGDmwVo= X-Proofpoint-GUID: IgoQ5nNaDeEei3wx9TEk3XecY-FOnh7K X-Authority-Analysis: v=2.4 cv=SM5ykuvH c=1 sm=1 tr=0 ts=6a5e7619 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=di-imCqyroNM6h0WoG0A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-20_04,2026-07-20_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 priorityscore=1501 phishscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607200209 Content-Type: text/plain; charset="utf-8" The current MSI-X restoration path assumes the Command register Memory bit is enabled when writing MSI-X messages. But it's possible the last saved and restored state of a device may not have the Memory bit enabled, even if a device driver later enables Memory bit and MSI-X. Attempting to access Memory space without Memory bit enabled can lead to Unsupported Request (UR) from the device. Fix this by enabling Memory bit and restore it afterwards. Fixes: 41017f0cac92 ("[PATCH] PCI: MSI(X) save/restore for suspend/resume") Cc: stable@vger.kernel.org Reviewed-by: Thomas Gleixner Reviewed-by: Niklas Schnelle Signed-off-by: Farhan Ali --- drivers/pci/msi/msi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 209373c92e9e..79c7e84d314b 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -870,6 +870,7 @@ void __pci_restore_msix_state(struct pci_dev *dev) { struct msi_desc *entry; bool write_msg; + u16 cmd; =20 if (!dev->msix_enabled) return; @@ -879,6 +880,14 @@ void __pci_restore_msix_state(struct pci_dev *dev) pci_msix_clear_and_set_ctrl(dev, 0, PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL); =20 + /* + * The restored device state may not have Memory decoding enabled + * in the Command register. Since the MSI-X was enabled for the + * device, enable Memory decoding before restoring MSI-X. + */ + pci_read_config_word(dev, PCI_COMMAND, &cmd); + pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY); + write_msg =3D arch_restore_msi_irqs(dev); =20 scoped_guard (msi_descs_lock, &dev->dev) { @@ -889,6 +898,7 @@ void __pci_restore_msix_state(struct pci_dev *dev) } } =20 + pci_write_config_word(dev, PCI_COMMAND, cmd); pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0); } =20 --=20 2.43.0