From nobody Sun May 24 22:35:49 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 07D01277C88; Wed, 20 May 2026 17:11:22 +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=1779297084; cv=none; b=mEsKhmLU8NeOhS+3qOvNBqnwfHWP259Z2SmonFpc6D+lbOdh66bk1Uu9hKVWZ1eGSCfcrMObDhs3ddBN4Zo8obFkbiQU7JRIzYE+L6R/UOiixoqnHopzpIAti1GZaXmBy165q/dmbHN9a+gcXukXAZF4Vg2aiQISk3OqOlvCINY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297084; c=relaxed/simple; bh=k4KMELZOZMjReqUINd6UWjfPtFpSJBooYrdFY9fuOQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ghawdw2iZ3mCRJ6YtODUZEnYvIcLW2eoDbKSutRI7IWqwLEib2q84cRbeIO2SSVUW2TJ7e2K71JQ4IdBAeMsdRh2ewfynp6rN1dSn1wyp9uEVRTzE4EZC/EcBuz0ZAYv1QxsS3PNfPQZsXpzcBnrXglPUv/e7wPXmAhQeKamoY8= 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=qJRNy+xf; 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="qJRNy+xf" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KCPslF4002074; Wed, 20 May 2026 17:11:19 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=SsYY2v5J0FFWddj+V ekcEqqu1s6FY7VRl+LYEUz+cfQ=; b=qJRNy+xf4ou7+htYgJT/+ZXg1EYOao69L q5Xgo6yMnPbP4Av5BfpU4bylX1sVrkQutUr+WcXMyhyED77u5xGp+UJs5z7XjF4X 2bNgYxMiOyfIepqd3muz+yiNX+ulCrvqiMDNjpwK9053NkXkfnqu+An6s61x9pSY RmdjqlbtbIuZjLUZHxVRbobANAHdpmNNizyVR2tZj+Jmemm5H3GOPwIyL0W2GLLY kQPW4zpOz27CcHOuw6wqWnUkMUs3DYYg+ciMO8QDpIedqx+DZBvX2o8eIB9KxBJL eIvOImnBYYSyGILSs0HuDiSE0BvgCYn/1UVLpHxapbigfKs+q7mcg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h9y37cq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:18 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64KH94CR022634; Wed, 20 May 2026 17:11:18 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e72wq8hhk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:18 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBGd167043824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:16 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A0C558063; Wed, 20 May 2026 17:11:16 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 651B358055; Wed, 20 May 2026 17:11:15 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:15 +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 v17 1/7] PCI: Allow per function PCI slots to fix slot reset on s390 Date: Wed, 20 May 2026 10:11:07 -0700 Message-ID: <20260520171113.1111-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfX7vfA+62mpLPU A/gW8RLAXhhc+T+Bh+LacWGqy36nEygqCGqn8cjQ3KDieHrPuMM2MZodYJd550tHAh7lD+eSswO CmfZSNKqctTR/w2+Rmjdn7LYDOFfclMRzrHzsMnel2JoTIx35x7p5CDp0AriHXn3qz7wp75+RBL 5J9RsyP7MkdNFzDVvVLQ9MFs0eH1YSmAHOxa/OZpBeIoUtPghVPOtI1peqdwiVkcF/QSehLpwfd bcoMgzB2ntlVAVWhYcJVuhsQjnuq1ccXieKuGRKXwN923qMxIl++jbgp0pmT2x0Uc/s3PHXJ7uw USxjdaimA9f6h1fnq7+pSAYs4//CU2YYLe1RyoBA4ol6ILNN9O2UtezW7s5577QwMOIxf8PwbyJ Dm8i9pBdzxognDYQyMY7XR97QqI+0BViSasqyTArYWV248UW0W3IXwJmkQirBwz0AKwZSepaajA +6C3dDc3iGnXsjJUZyg== X-Authority-Analysis: v=2.4 cv=BNuDalQG c=1 sm=1 tr=0 ts=6a0deb36 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=9_SSeoq7eJPDN4OswFYA:9 a=O8hF6Hzn-FEA:10 X-Proofpoint-ORIG-GUID: BKYDTmnLMs7ufXX1OeHxu3kTj6LQy7s8 X-Proofpoint-GUID: BKYDTmnLMs7ufXX1OeHxu3kTj6LQy7s8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 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 kernel's PCI_SLOT() macro 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 d34266651ad0..f5f8291482b0 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4865,8 +4865,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 2c4454583c11..d58982aa8730 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -78,14 +78,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 Sun May 24 22:35:49 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 7AEBC3D75D3; Wed, 20 May 2026 17:11:23 +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=1779297085; cv=none; b=JU04Pt8zjuNNXaYdGXxYARVuDXPhx2dcwNVFKcnE7mfcYxOWWBiCOJ2B+RfYfqNnxf3+cH9JU1YRAb2BnNGb8QJOSLYJLIqQS8mR95oEXH1rmPTvY0Bu5KRuk/6sTlo9coSFO52fgUbrNyB9tzhGJ6wLER0/ihKe9m8E2AOh6p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297085; c=relaxed/simple; bh=kDMLUv+qGFXTZff8n7B9SWz1eb0xmrDVNGip6EZGbB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rpziV/uNPOg2EkjwKF5g8daRBfRNg3Ei6QTqWtuNYvPpG+B2sT1I2Nt4aoafWl7XsC4keQlCYQKhuwHKvwz5++qVvMyi6u3SwTLBb9LYumI+xzzSh4fbOIXkVhT2ZqT4SVQOlxn7P6QIrgo/B6V8UE74qcxtVxTcmpl2i5ez+Yo= 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=kWDzuTT8; 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="kWDzuTT8" 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 64KBXoMv685729; Wed, 20 May 2026 17:11:19 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=RsjEQ+ztMbfg0FMP3 X8XOwCXQZzCQzdBTpV6PYewqs8=; b=kWDzuTT89qWyaOQHDHPtn19CxQa6DQG8B FRecaBXKqYKqAWQb4AN0CxQYKXyGl8hhpUsK6Xn/BWr+RJPbr1qbDK/uJavovw0H 01sEDNa7fbb4G4+FdqhyN3I6era+TYi4/FS/TxWMJIZjh5ol6H9IOK/KdDaqE8hU EsUf3kb9SAnZB4Lp+hPXn0tpB5G2A+w/3yQJAIc/ge7jG8DTtDZatPKRRaVlxhD2 Tv7h0fvcPqkc3zniCOAImHFV65cabkvXDn/olsNTffWE4jcTyYIhxDl6SEu3J4wp vq4BRIpeF4SizxKUeHO2KKejMzogowcRevCwPj5nIjxAidgOgT6ZQ== 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 4e6h88j51e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:19 +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 64KH94gK006673; Wed, 20 May 2026 17:11:18 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e739w0dtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:18 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBH3X23266046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:17 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97CFE58055; Wed, 20 May 2026 17:11:17 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9766F58065; Wed, 20 May 2026 17:11:16 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:16 +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 v17 2/7] PCI: Avoid saving config space state if inaccessible Date: Wed, 20 May 2026 10:11:08 -0700 Message-ID: <20260520171113.1111-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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-ORIG-GUID: dTSkuoIwsT6r_4pnnZTyrJqIwm2ArIRq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfXzbUUA9rcyFss tTvmpR0hoE4wvWs9RXdiJGtok9icfL0whkWAGyM1wz4La2FcGY803hVCz6BSaRL51fWUSc1mi3T IDVvB4jbR3iGKowwpKdmhdMNSq4iXETwEA2r2Yh0dsGFy2uxn80Z7RhzJsQAuRjFemk7WYQQOPq luGLYYCNr4voM5+UWQT7vJ6kWF5gHLFA5AqsU5miOyhFhDJ97INc7o8lVGYjibwjg+vgv83GFrR KwK6nRrIuR5VuQQ6+7+fNbvbBy6/+B238Sln3+TnQuGoVBucAL/tkXSKJ+ff+G4yXrc3mnvci2Q JdxPfaDlVxm6ceIV6b3VjtTn8FiENvM3yYxewKM2NUxZ9ugsZdRE2UzHbSPodUujMfDcqry4mRI mQTFMfTzCm526WRfBk7znql2gWbN92ORMPmT8hqe+5Hs5jUqy4gkm/9Ri5v+Gn9dhNERvbNPY9M vBrSOKejDRz4ty+9+xw== X-Proofpoint-GUID: 9DPUXEWcdtktxtkbPdpLUkbh8SCODS5r X-Authority-Analysis: v=2.4 cv=apyCzyZV c=1 sm=1 tr=0 ts=6a0deb37 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=1XWaLZrsAAAA:8 a=qS04rNcGil1I7-YeviAA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 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 f5f8291482b0..973d23e41c48 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -722,6 +722,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 @@ -5027,6 +5048,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 Sun May 24 22:35:49 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 0FCD23F1AA4; Wed, 20 May 2026 17:11:24 +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=1779297086; cv=none; b=GUbDj60UkNPG/hUEBHjmFB/w57ftL/sPrnK3Rjs5RLZhw149CT4Zadeg/8Jy4nUDwmFI9Zh38EPm93rDyvLweOCWx+zva+ltZUlFgLSbzjknJYscsU4c8Vw0egzGxvXdBut9ClokWWmVCFr3wQwL0djMDy67xbvWPn8kfjTHgjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297086; c=relaxed/simple; bh=RQ+lhbs/20dpjDWkfLkvzRoH5lgweVzoQtY2ETnzPfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B71gQIas+JRLfZMIEFUTezNRzlXlyiBh+ycK1cdM1zPMJEnE4vvDcWT46VpBCBU14WjD/h+Rw/UrtVuuaNXrA9o7UnWL29nkxG+N1HWU41UBmlHDefhZzMqpLmQlRYOv+aQXWw0L7HNkfvTfF94TpSBEOHAOc8iBk6QlEBe7eew= 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=LRkX5AL/; 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="LRkX5AL/" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64K7e9iA883231; Wed, 20 May 2026 17:11:21 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=cFYGaeCjhi1C6NNXk 0q/9v/1B4HO6gGEzVR0sxD8XXU=; b=LRkX5AL/hiFT4fZLZH3z/CCvIbz52+67T iVAssRR0nAuwJLtsfi1c6qv3GGnc/TH4apfWjW25VaZFBi3/L6nY3Jjqrl8ISBY8 79hQk0D9TZC/67uv8gtr6XpUaToGilbDds2ArcRjAxMO5o1RmsKrTDUlChRnbDBR YSIGXJBV1tveGnKO48V3ZtDsnKpLNRRsIMG9wLNiQiuhEJQMbOyQgdrODjYw470D KOalzQdvj2N4jzQ77846Dj31d3xOh7zGD4hhiFzJ1T3Wj7ZV3Mr/vOBG3ZmPwTcb cVWXibxX8UoOpWJuLTsSheWgcoeZhhJgl9CZqpih6GEJuD8MW9WvQ== 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 4e6h8mu4f2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:21 +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 64KGsDqV013522; Wed, 20 May 2026 17:11:20 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e73wk8ag3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:20 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBJBA23331360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:19 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA7C258059; Wed, 20 May 2026 17:11:18 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C22B85804B; Wed, 20 May 2026 17:11:17 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:17 +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 v17 3/7] PCI: Fail FLR when config space is inaccessible Date: Wed, 20 May 2026 10:11:09 -0700 Message-ID: <20260520171113.1111-4-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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-GUID: vg75slbuDjjo0r2g7M-lBTuet-cZeqIb X-Authority-Analysis: v=2.4 cv=GYMnWwXL c=1 sm=1 tr=0 ts=6a0deb39 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=1owyFLT6pZZ0tE0DW5YA:9 X-Proofpoint-ORIG-GUID: vg75slbuDjjo0r2g7M-lBTuet-cZeqIb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfX12pik4cOmkzb E9E3ExY4p1CxxJrVRGC+8YFIAJWSxvEy2uC17HOolz5EFRFnJD9T+GGwIFywwqpUBiVUWe6K0W4 DlHp5ZlDyIg+xJ0OvMVjkJAYsRWFPbiHobW68EUYa3y086wiw/X04CjvFSExJH3HGLBSCPpoTiZ ELMh6Mj86AoRC5m2HeIygS8iOiALrbxlLHkwVPEReTFprN76eXYd1b2y+AJ3oZM8HzttE/xSGW0 c8RRKVYmaQ6zrNF691heNC36vRYfHcitJWCFVxdwVeq+v4ejozBwKFOR4eEOa4smqqp+wzJUZIb vDa4kUj6CJwikpX5j6Lc/iUXBFe8QDkH3wGDDUr8Yb6311NaSTlsRqUq4nEaf/tk/rLPbpZXlCS wAZnhmt5MtKclQguXbmhFIh4p7Na3EQfiHLiXc29RVBFb8Uc+R5UJHdgBuQnUf30+mw2jLlQXpa Mx5C0xlyidRZsDj+6aQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 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 973d23e41c48..061dfcd1472e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4396,6 +4396,9 @@ int pcie_reset_flr(struct pci_dev *dev, bool probe) if (!(dev->devcap & PCI_EXP_DEVCAP_FLR)) return -ENOTTY; =20 + if (!pci_dev_config_accessible(dev, "FLR")) + return -ENOTTY; + if (probe) return 0; =20 --=20 2.43.0 From nobody Sun May 24 22:35:49 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 7F3BA3F39F5; Wed, 20 May 2026 17:11:26 +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=1779297088; cv=none; b=dWO1+PVcf+hrzD79l2b7+Q71cDD1DtbVRZtebxLXhlQWN18rjL4Fine5vclAO2OiHVEXnvc8bMMclyelaraaVs4Wf8Quvb6uq6QbLqPAlVfNE4Lt6lOEWmgizzmo2Dz0zUtwQaWei/no7A/9KMtaYqEz/hW98fEeVTGu+nIJ3tY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297088; c=relaxed/simple; bh=/K0re95tuAvXvBRxYf7nAMZMpA/UEc7CJ+C+RJi5stY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HdvwilRTflGvJSVGfW4nUNmPRjLTVI48VcIAqB8jkdJYt9rOEm7fVV9hlzqgnVkbumqC3jRtKkIWoGBZ4Y3eq/v13I+k7MC9CEcJIRugXVrlCXCZosB9rHPYv2IWQJia2eXr1FVGKTKVkjcpM1QLE1sPScDjVQ8VYvhjH2/Z18c= 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=ijRlUOqU; 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="ijRlUOqU" 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 64KEfqSe3905763; Wed, 20 May 2026 17:11:22 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=2ITSSoR6v0fUTufT0 GQfjxhgkFkHZLuJdwaKADhTah8=; b=ijRlUOqUsKNLoXZ1y3Sm4K5oqpmrb9SPp 4pDwgBjtBBDqn1vRbkEFC9sV3sJ9LJHmvDqbROMPe7YHQFFdz5YQsflohFDof1r2 innef4uc51WgZBdwobPLPqxvteAVAMpinB8pQVwl6I7drBuWeBJONUlk5L4/r0md 99UIpQ7GES9OEgnh4G5QPWt9vVxTC0wmnECMzFGhqiTCX2HAF4bRROToR0898xd3 sBy4dhtOYnLya7geiJtG6aFr3XtiNFdgKFbkyfsUs2MIGVl2d2FvrJSgszpOH+rh a42Y9w6cO8JmRAW3lqdTxqXcWkY+JRYejXhTozqcXH7DpjmhuohWg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6hb8j46u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:22 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64KH9845022657; Wed, 20 May 2026 17:11:21 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e72wq8hhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:21 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBKn529229628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:20 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B55358067; Wed, 20 May 2026 17:11:20 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1714158063; Wed, 20 May 2026 17:11:19 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:18 +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 Subject: [PATCH v17 4/7] s390/pci: Store PCI error information for passthrough devices Date: Wed, 20 May 2026 10:11:10 -0700 Message-ID: <20260520171113.1111-5-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfXx1DsWVB4YHvX /yvVsxCRV3GHO8uIrD2Of4XIcSmdlj4SKV0Xdva0oFCVoQg709m8i3zua7q4sUrBibk51HUGhxN HvGvi2q4568CTDzdtUDNgyqOygyhX5VZ7DVD++xlR2P0G7KMtN5yCrBdUWZZX0UzyDNfL+uXQ97 bsowJGBBoaoEKTm5vqkj78hUEPw8VxY/ofU1bABCwZsDNSTOFPl9dELGO83bTP0errPKETT/HRt HJrE2s+gPv4Sy1nsx4wsECfy3NN95BcmjzvFnMQ2TJNMx7eafv7aWhi7RWbpp9Fb8CM4yqSTtE9 VyGzhtvsSbK+XgT8yKhPTB+uvRJcNuZic/4UIiIwTNZ6AfHneKgE+lzZHHNNcW0SVxKtve0W9er FSeCexeZx9A1esuPTUqnWcIdfL2rQXT68BHn3YtdTN1CgSiyNEjXGi1puJoR9e67syXGCEYYLcv cFhK510AJKX30hJMyeg== X-Proofpoint-GUID: 6tZk11wB7oCWT4i8aQR0ds8eHb8XLVAV X-Proofpoint-ORIG-GUID: 6tZk11wB7oCWT4i8aQR0ds8eHb8XLVAV X-Authority-Analysis: v=2.4 cv=aYBRWxot c=1 sm=1 tr=0 ts=6a0deb3a cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=PQMJTAmWB74Go-Ie6_gA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 Content-Type: text/plain; charset="utf-8" For a passthrough device we need co-operation from user space to recover the device. This would require to bubble up any error information to user space. Let's store this error information for passthrough devices, so it can be retrieved later. We can now have userspace drivers (vfio-pci based) on s390x. The userspace drivers will not have any KVM fd and so no kzdev associated with them. So we need to update the logic for detecting passthrough devices to not depend on struct kvm_zdev. Reviewed-by: Matthew Rosato Signed-off-by: Farhan Ali --- arch/s390/include/asm/pci.h | 30 ++++++++ arch/s390/pci/pci.c | 1 + arch/s390/pci/pci_event.c | 116 +++++++++++++++++-------------- drivers/vfio/pci/vfio_pci_zdev.c | 18 ++++- 4 files changed, 111 insertions(+), 54 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 5dcf35f0f325..016386f7ef4a 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -118,6 +118,32 @@ struct zpci_bus { enum pci_bus_speed max_bus_speed; }; =20 +/* Content Code Description for PCI Function Error */ +struct zpci_ccdf_err { + u32 reserved1; + u32 fh; /* function handle */ + u32 fid; /* function id */ + u32 ett : 4; /* expected table type */ + u32 mvn : 12; /* MSI vector number */ + u32 dmaas : 8; /* DMA address space */ + u32 reserved2 : 6; + u32 q : 1; /* event qualifier */ + u32 rw : 1; /* read/write */ + u64 faddr; /* failing address */ + u32 reserved3; + u16 reserved4; + u16 pec; /* PCI event code */ +} __packed; + +#define ZPCI_ERR_PENDING_MAX 4 +struct zpci_ccdf_pending { + bool mediated_recovery; + u8 count; + u8 head; + u8 tail; + struct zpci_ccdf_err err[ZPCI_ERR_PENDING_MAX]; +}; + /* Private data per function */ struct zpci_dev { struct zpci_bus *zbus; @@ -192,6 +218,8 @@ struct zpci_dev { struct iommu_domain *s390_domain; /* attached IOMMU domain */ struct kvm_zdev *kzdev; struct mutex kzdev_lock; + struct zpci_ccdf_pending pending_errs; + struct mutex pending_errs_lock; spinlock_t dom_lock; /* protect s390_domain change */ }; =20 @@ -334,6 +362,8 @@ void zpci_debug_exit_device(struct zpci_dev *); int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *); int zpci_clear_error_state(struct zpci_dev *zdev); int zpci_reset_load_store_blocked(struct zpci_dev *zdev); +void zpci_start_mediated_recovery(struct zpci_dev *zdev); +void zpci_stop_mediated_recovery(struct zpci_dev *zdev); =20 #ifdef CONFIG_NUMA =20 diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 39bd2adfc240..2d377c2e194d 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -842,6 +842,7 @@ struct zpci_dev *zpci_create_device(u32 fid, u32 fh, en= um zpci_state state) mutex_init(&zdev->state_lock); mutex_init(&zdev->fmb_lock); mutex_init(&zdev->kzdev_lock); + mutex_init(&zdev->pending_errs_lock); =20 return zdev; =20 diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index 839bd91c056e..cf2ffa21ab8c 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -17,23 +17,6 @@ #include "pci_bus.h" #include "pci_report.h" =20 -/* Content Code Description for PCI Function Error */ -struct zpci_ccdf_err { - u32 reserved1; - u32 fh; /* function handle */ - u32 fid; /* function id */ - u32 ett : 4; /* expected table type */ - u32 mvn : 12; /* MSI vector number */ - u32 dmaas : 8; /* DMA address space */ - u32 : 6; - u32 q : 1; /* event qualifier */ - u32 rw : 1; /* read/write */ - u64 faddr; /* failing address */ - u32 reserved3; - u16 reserved4; - u16 pec; /* PCI event code */ -} __packed; - /* Content Code Description for PCI Function Availability */ struct zpci_ccdf_avail { u32 reserved1; @@ -60,18 +43,6 @@ static inline bool ers_result_indicates_abort(pci_ers_re= sult_t ers_res) } } =20 -static bool is_passed_through(struct pci_dev *pdev) -{ - struct zpci_dev *zdev =3D to_zpci(pdev); - bool ret; - - mutex_lock(&zdev->kzdev_lock); - ret =3D !!zdev->kzdev; - mutex_unlock(&zdev->kzdev_lock); - - return ret; -} - static bool is_driver_supported(struct pci_driver *driver) { if (!driver || !driver->err_handler) @@ -81,6 +52,47 @@ static bool is_driver_supported(struct pci_driver *drive= r) return true; } =20 +static int zpci_store_pci_error(struct pci_dev *pdev, + struct zpci_ccdf_err *ccdf) +{ + struct zpci_dev *zdev =3D to_zpci(pdev); + int i; + + guard(mutex)(&zdev->pending_errs_lock); + if (!zdev->pending_errs.mediated_recovery) + return -EINVAL; + + if (zdev->pending_errs.count >=3D ZPCI_ERR_PENDING_MAX) { + pr_err("%s: Maximum number (%d) of pending error events queued\n", + pci_name(pdev), ZPCI_ERR_PENDING_MAX); + return -ENOMEM; + } + + i =3D zdev->pending_errs.tail % ZPCI_ERR_PENDING_MAX; + memcpy(&zdev->pending_errs.err[i], ccdf, sizeof(struct zpci_ccdf_err)); + zdev->pending_errs.tail++; + zdev->pending_errs.count++; + return 0; +} + +void zpci_start_mediated_recovery(struct zpci_dev *zdev) +{ + guard(mutex)(&zdev->pending_errs_lock); + zdev->pending_errs.mediated_recovery =3D true; +} +EXPORT_SYMBOL_GPL(zpci_start_mediated_recovery); + +void zpci_stop_mediated_recovery(struct zpci_dev *zdev) +{ + guard(mutex)(&zdev->pending_errs_lock); + zdev->pending_errs.mediated_recovery =3D false; + if (zdev->pending_errs.count) + pr_info("Unhandled PCI error events count=3D%d for PCI function 0x%x\n", + zdev->pending_errs.count, zdev->fid); + memset(&zdev->pending_errs, 0, sizeof(struct zpci_ccdf_pending)); +} +EXPORT_SYMBOL_GPL(zpci_stop_mediated_recovery); + static pci_ers_result_t zpci_event_notify_error_detected(struct pci_dev *p= dev, struct pci_driver *driver) { @@ -175,12 +187,15 @@ static pci_ers_result_t zpci_event_do_reset(struct pc= i_dev *pdev, * and the platform determines which functions are affected for * multi-function devices. */ -static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *= pdev) +static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *= pdev, + struct zpci_ccdf_err *ccdf) { pci_ers_result_t ers_res =3D PCI_ERS_RESULT_DISCONNECT; struct zpci_dev *zdev =3D to_zpci(pdev); + bool mediated_recovery =3D false; char *status_str =3D "success"; struct pci_driver *driver; + int rc; =20 /* * Ensure that the PCI function is not removed concurrently, no driver @@ -194,13 +209,6 @@ static pci_ers_result_t zpci_event_attempt_error_recov= ery(struct pci_dev *pdev) } pdev->error_state =3D pci_channel_io_frozen; =20 - if (is_passed_through(pdev)) { - pr_info("%s: Cannot be recovered in the host because it is a pass-throug= h device\n", - pci_name(pdev)); - status_str =3D "failed (pass-through)"; - goto out_unlock; - } - driver =3D to_pci_driver(pdev->dev.driver); if (!is_driver_supported(driver)) { if (!driver) { @@ -216,12 +224,24 @@ static pci_ers_result_t zpci_event_attempt_error_reco= very(struct pci_dev *pdev) goto out_unlock; } =20 + rc =3D zpci_store_pci_error(pdev, ccdf); + if (!rc || rc =3D=3D -ENOMEM) + mediated_recovery =3D true; + ers_res =3D zpci_event_notify_error_detected(pdev, driver); if (ers_result_indicates_abort(ers_res)) { status_str =3D "failed (abort on detection)"; goto out_unlock; } =20 + if (mediated_recovery) { + pr_info("%s: Leaving recovery of pass-through device to user-space\n", + pci_name(pdev)); + ers_res =3D PCI_ERS_RESULT_RECOVERED; + status_str =3D "in progress"; + goto out_unlock; + } + if (ers_res !=3D PCI_ERS_RESULT_NEED_RESET) { ers_res =3D zpci_event_do_error_state_clear(pdev, driver); if (ers_result_indicates_abort(ers_res)) { @@ -266,25 +286,19 @@ static pci_ers_result_t zpci_event_attempt_error_reco= very(struct pci_dev *pdev) * @pdev: PCI function for which to report * @es: PCI channel failure state to report */ -static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_= t es) +static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_= t es, + struct zpci_ccdf_err *ccdf) { struct pci_driver *driver; =20 pci_dev_lock(pdev); pdev->error_state =3D es; - /** - * While vfio-pci's error_detected callback notifies user-space QEMU - * reacts to this by freezing the guest. In an s390 environment PCI - * errors are rarely fatal so this is overkill. Instead in the future - * we will inject the error event and let the guest recover the device - * itself. - */ - if (is_passed_through(pdev)) - goto out; + + zpci_store_pci_error(pdev, ccdf); driver =3D to_pci_driver(pdev->dev.driver); if (driver && driver->err_handler && driver->err_handler->error_detected) driver->err_handler->error_detected(pdev, pdev->error_state); -out: + pci_dev_unlock(pdev); } =20 @@ -330,12 +344,12 @@ static void __zpci_event_error(struct zpci_ccdf_err *= ccdf) break; case 0x0040: /* Service Action or Error Recovery Failed */ case 0x003b: - zpci_event_io_failure(pdev, pci_channel_io_perm_failure); + zpci_event_io_failure(pdev, pci_channel_io_perm_failure, ccdf); break; default: /* PCI function left in the error state attempt to recover */ - ers_res =3D zpci_event_attempt_error_recovery(pdev); + ers_res =3D zpci_event_attempt_error_recovery(pdev, ccdf); if (ers_res !=3D PCI_ERS_RESULT_RECOVERED) - zpci_event_io_failure(pdev, pci_channel_io_perm_failure); + zpci_event_io_failure(pdev, pci_channel_io_perm_failure, ccdf); break; } pci_dev_put(pdev); diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_z= dev.c index 0990fdb146b7..78a28db00c6d 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -144,24 +144,36 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_= device *vdev, int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev) { struct zpci_dev *zdev =3D to_zpci(vdev->pdev); + int ret; =20 if (!zdev) return -ENODEV; =20 + zpci_start_mediated_recovery(zdev); + if (!vdev->vdev.kvm) return 0; =20 + ret =3D -ENOENT; if (zpci_kvm_hook.kvm_register) - return zpci_kvm_hook.kvm_register(zdev, vdev->vdev.kvm); + ret =3D zpci_kvm_hook.kvm_register(zdev, vdev->vdev.kvm); =20 - return -ENOENT; + if (ret) + zpci_stop_mediated_recovery(zdev); + + return ret; } =20 void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev) { struct zpci_dev *zdev =3D to_zpci(vdev->pdev); =20 - if (!zdev || !vdev->vdev.kvm) + if (!zdev) + return; + + zpci_stop_mediated_recovery(zdev); + + if (!vdev->vdev.kvm) return; =20 if (zpci_kvm_hook.kvm_unregister) --=20 2.43.0 From nobody Sun May 24 22:35:49 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 40D913F4DFC; Wed, 20 May 2026 17:11:27 +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=1779297088; cv=none; b=AjncLDmLj4XKamjMQV+aLZ+Imr64sKL18y/pHf73ZHTQ1OuzcBseHlsgnOxpT62xJTmKl+r3D9wNyVBSxQSPz+fSzQWf3QUMdLYrj0y+hv9ULmC1dwfH80a6CsQy7cDUV0rlNStdBJWZUfiG0pyXL9qUEfGhWHrV9rMcmOFRoAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297088; c=relaxed/simple; bh=/kIM2xrGi6evIrfIvhiKLKZ3XPuO1l8u98/mVdN19IA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u6c7jejdHVPIiqjhqOE/gHBLp3FBQjNB04oqlnNtQGPf4MZTqjLqIfFx6SVIj6QGHv+BO5TUp5bR7rQAi+2I05A59MZJ9XQLpmmQRKDZ3AdY3T18b3k9xUuZKH9iXKWdchWAZ3vIrA5rcYtFrwIuZz8l3/UXhJqLF5E+uC758yE= 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=Q6z36xif; 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="Q6z36xif" 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 64KFlF1m610903; Wed, 20 May 2026 17:11:23 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=yqoHho9AVuw9klT6Z piEzs6Usrf9jV0bdlCiigguf4g=; b=Q6z36xifeirleTwBZh9LM10zFxKRkugIk mV88fYrkUoMnmEetSYjDcGTzb9uMGz/TrLoUdUyWjWohDWczQ7a0K6T8G/Shpkfv CPciSovjdd33tYW8ieWIGJhoBd9jGA4kemrnP+8D7zb43R6MhyrMw9RiRWAY3q+Z LPg7wqNm/0DqyPZpvgT7yiLQWVhY4l/VWN3Y6oyzOPuNOu1xmKle4FXTEDmQJ1fs PVRMSZHxdMjB9ws3+eCGeWXjLrjoMY/oI5ycZuV+aEZg+saxC35VgXH6Tbumn2wz wMuMee2NQn2qXHdkbnRGtlfG/yO6rvLEtJMoBICwmdYNPKej23M9g== 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 4e6hb8j46x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:23 +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 64KH96q1014263; Wed, 20 May 2026 17:11:22 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e754gg30j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:22 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBLP420578820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:21 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30F1858063; Wed, 20 May 2026 17:11:21 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4627E58055; Wed, 20 May 2026 17:11:20 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:20 +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 Subject: [PATCH v17 5/7] vfio-pci/zdev: Add a device feature for error information Date: Wed, 20 May 2026 10:11:11 -0700 Message-ID: <20260520171113.1111-6-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfX7me+ZYq/7e5J l42szH7VtTVXPZswby4MGyUHqWvdC0yLLGKFhRejNU4h9HmEIYUAPs+EhGl7gZUSMnlOqN/TT1r BgkVEp4IM7N+A7pmX8gXDCjZFbO6NFdm7S9Bj0ebCRvBnB0lcczUn574XhSZyO97T9U+BamvsGr Ute4fDe7Fk2ELfHV2pbaTY5ODBnOxvh91p2YrvdgKjc3/O1emmfGFQbIoc2Ik4oT54sJ9qMKbg2 c5ykhvkCA397DaCPBm1iLdOPHXzFYYBU/fGa43giuXkn6YXIXu1p8D39jjlP9R3ZkzwK6RAVwz5 3zkZ8o6E0n/jPDR0fnKPmcPuzhV0DUYk03sMEi1eVBPdXZQfTMyKi+AAouo9t258Lz5bJhOYmCG 2xVwfuTrFY/Z8+tp4k2+7bmV27FEvClS9j44vd/OFGOWp+LPF9EghhtikYrAmP4Yufaew6w7Dri AZzMZDaALtJPat3vb3A== X-Proofpoint-GUID: ccdtr2LvGyyb-Vx0LpbG_c1N95i_n1mL X-Proofpoint-ORIG-GUID: ccdtr2LvGyyb-Vx0LpbG_c1N95i_n1mL X-Authority-Analysis: v=2.4 cv=aYBRWxot c=1 sm=1 tr=0 ts=6a0deb3b cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=sIuuyFDGXZ7lsjPJAw8A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 Content-Type: text/plain; charset="utf-8" For zPCI devices, we have platform specific error information. The platform firmware provides this error information to the operating system in an architecture specific mechanism. To enable recovery from userspace for these devices, we want to expose this error information to userspace. Add a new device feature to expose this information. Reviewed-by: Matthew Rosato Reviewed-by: Niklas Schnelle Signed-off-by: Farhan Ali --- arch/s390/include/asm/pci.h | 2 ++ arch/s390/pci/pci_event.c | 19 ++++++++++++++++ drivers/vfio/pci/vfio_pci_core.c | 2 ++ drivers/vfio/pci/vfio_pci_priv.h | 9 ++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 39 ++++++++++++++++++++++++++++++++ include/uapi/linux/vfio.h | 30 ++++++++++++++++++++++++ 6 files changed, 101 insertions(+) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 016386f7ef4a..88a125b92bdd 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -364,6 +364,8 @@ int zpci_clear_error_state(struct zpci_dev *zdev); int zpci_reset_load_store_blocked(struct zpci_dev *zdev); void zpci_start_mediated_recovery(struct zpci_dev *zdev); void zpci_stop_mediated_recovery(struct zpci_dev *zdev); +int zpci_get_pending_error(struct zpci_dev *zdev, + struct zpci_ccdf_err *ccdf); =20 #ifdef CONFIG_NUMA =20 diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index cf2ffa21ab8c..db1b44baf8fa 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -75,6 +75,25 @@ static int zpci_store_pci_error(struct pci_dev *pdev, return 0; } =20 +int zpci_get_pending_error(struct zpci_dev *zdev, + struct zpci_ccdf_err *ccdf) +{ + int head =3D 0; + + guard(mutex)(&zdev->pending_errs_lock); + + if (!zdev->pending_errs.count) + return -ENOMSG; + + head =3D zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX; + memcpy(ccdf, &zdev->pending_errs.err[head], + sizeof(struct zpci_ccdf_err)); + zdev->pending_errs.head++; + zdev->pending_errs.count--; + return 0; +} +EXPORT_SYMBOL_GPL(zpci_get_pending_error); + void zpci_start_mediated_recovery(struct zpci_dev *zdev) { guard(mutex)(&zdev->pending_errs_lock); diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_c= ore.c index 050e7542952e..27642f10fe97 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1569,6 +1569,8 @@ int vfio_pci_core_ioctl_feature(struct vfio_device *d= evice, u32 flags, return vfio_pci_core_feature_token(vdev, flags, arg, argsz); case VFIO_DEVICE_FEATURE_DMA_BUF: return vfio_pci_core_feature_dma_buf(vdev, flags, arg, argsz); + case VFIO_DEVICE_FEATURE_ZPCI_ERROR: + return vfio_pci_zdev_feature_err(device, flags, arg, argsz); default: return -ENOTTY; } diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_p= riv.h index fca9d0dfac90..4e7162234a2e 100644 --- a/drivers/vfio/pci/vfio_pci_priv.h +++ b/drivers/vfio/pci/vfio_pci_priv.h @@ -93,6 +93,8 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_devi= ce *vdev, struct vfio_info_cap *caps); int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev); void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev); +int vfio_pci_zdev_feature_err(struct vfio_device *device, u32 flags, + void __user *arg, size_t argsz); #else static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device = *vdev, struct vfio_info_cap *caps) @@ -107,6 +109,13 @@ static inline int vfio_pci_zdev_open_device(struct vfi= o_pci_core_device *vdev) =20 static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device = *vdev) {} + +static inline int vfio_pci_zdev_feature_err(struct vfio_device *device, + u32 flags, void __user *arg, + size_t argsz) +{ + return -ENOTTY; +} #endif =20 static inline bool vfio_pci_is_vga(struct pci_dev *pdev) diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_z= dev.c index 78a28db00c6d..cc148123a97b 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -141,6 +141,45 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_d= evice *vdev, return ret; } =20 +int vfio_pci_zdev_feature_err(struct vfio_device *device, u32 flags, + void __user *arg, size_t argsz) +{ + struct vfio_device_feature_zpci_err err =3D {}; + struct vfio_pci_core_device *vdev; + struct zpci_ccdf_err ccdf =3D {}; + struct zpci_dev *zdev; + int ret; + + vdev =3D container_of(device, struct vfio_pci_core_device, vdev); + zdev =3D to_zpci(vdev->pdev); + if (!zdev) + return -ENODEV; + + ret =3D vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_GET, + sizeof(err)); + if (ret !=3D 1) + return ret; + + ret =3D zpci_get_pending_error(zdev, &ccdf); + if (ret) + return ret; + + err.fh =3D ccdf.fh; + err.fid =3D ccdf.fid; + err.ett =3D ccdf.ett; + err.mvn =3D ccdf.mvn; + err.dmaas =3D ccdf.dmaas; + err.q =3D ccdf.q; + err.rw =3D ccdf.rw; + err.faddr =3D ccdf.faddr; + err.pec =3D ccdf.pec; + + if (copy_to_user(arg, &err, sizeof(err))) + return -EFAULT; + + return 0; +} + int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev) { struct zpci_dev *zdev =3D to_zpci(vdev->pdev); diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 5de618a3a5ee..3eead86a00ab 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1534,6 +1534,36 @@ struct vfio_device_feature_dma_buf { */ #define VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 12 =20 +/** + * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to + * userspace for vfio-pci devices on s390. On s390, PCI error recovery + * involves platform firmware and notification to operating systems is done + * by architecture specific mechanism. Exposing this information to + * userspace allows it to take appropriate actions to handle an + * error on the device. The ioctl returns -ENOMSG if there are no pending + * PCI errors. + */ + +struct vfio_device_feature_zpci_err { + __u32 feature_flags; /* Indicate future features */ + __u32 reserved1; + __u32 fh; /* function handle */ + __u32 fid; /* function id */ + __u32 ett : 4; /* expected table type */ + __u32 mvn : 12; /* MSI vector number */ + __u32 dmaas : 8; /* DMA address space */ + __u32 reserved2 : 6; + __u32 q : 1; /* event qualifier */ + __u32 rw : 1; /* read/write */ + __u64 faddr; /* failing address */ + __u32 reserved3; + __u16 reserved4; + __u16 pec; /* PCI event code */ + __u8 reserved5[28]; /* Allow for future expansion */ +}; + +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 13 + /* -------- API for Type1 VFIO IOMMU -------- */ =20 /** --=20 2.43.0 From nobody Sun May 24 22:35:49 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 371033F5BE1; Wed, 20 May 2026 17:11:28 +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=1779297089; cv=none; b=C2bXSlx4hY4H5Nw1utsZhzIaQ5Wa1I4p10CgzbzWw0s1iL3NoEI/T1x9sA+TxElbMbl+ZGTngAm37//E8kLLYQ7XfaNNsi1S2YEtmBkkC8ehMRmrzHt5H2hxzeif/fY4Abp5gpHmsYrLX8jkp4s+X4xXFGb606nLKItOjXdN7hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297089; c=relaxed/simple; bh=DPuQiBFXmj6qUVY/YkNJPHp+MeEXaiSp/X7OtW8VYs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VzP7nsQu4yDEoWb0v615QgsJYZP1wLy8HpIcOD1S8bpZe2ojg2/AwBByqMJgMjB4k2jPjPx0POkSafFKYkiK7FD9DX9i3C+Pcc4oHYYDkMxVCrZE5ebD4vSAQDSSCS3CrLfqXY/MLNNJFsAPV3gV7ezJEZ5JLYFeMcK4zGYRsLc= 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=fYuYGY/P; 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="fYuYGY/P" 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 64KBXoN1685729; Wed, 20 May 2026 17:11:24 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=RGkv2CTMss9f/2VtB 3Jlrn9K0Sa5hXqXwOD6mlaP8jA=; b=fYuYGY/PylYHDgLJwmDS3UTYi7tOsBJj/ 5wJ3ytQpn56FAW00bct735WwJsiH+hABu4KEOzFKrtw+5HpjxaZUcmWUy8yrDFKN NAV81ExfVSCofgBKvwL5w2DqnWOEeDaTj1zOo/ZvJegLXMlEZ5MzZoxCf6JbHD4m rTXr6AfGhOAlN50ehZUa3BUQFR/JlRVeWnwHll0MfQ5pcpDYlbBz9751ZbZBHjuC qCAsPVhzc6RexOkNoGFKhVSP3qfbbSDD54ztyqVC+XtmtlFz+TKrj5n8g8yrWfr0 hHSqFJuVwGEnJAebA7PZi7rys2bh4EMnrX+fWUPWHLFJA97tK3Yeg== 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 4e6h88j51y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:24 +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 64KGsA9n013500; Wed, 20 May 2026 17:11:23 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e73wk8agc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:23 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBM4Y28377808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:22 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E5B45804B; Wed, 20 May 2026 17:11:22 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D19D58055; Wed, 20 May 2026 17:11:21 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:21 +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, Julian Ruess Subject: [PATCH v17 6/7] vfio/pci: Add a reset_done callback for vfio-pci driver Date: Wed, 20 May 2026 10:11:12 -0700 Message-ID: <20260520171113.1111-7-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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: 3gS-ICtnaATCTbyQVeOR8JsakyBDLE1X X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfXzBWnZVkmoMkv UI2tw3/ctZGeREQqIZjv58fY9PRXAjqELd5f9Dectu7VWvY9DnyIpmZIpl/vUt3pWNipUNiSmub 6LvujH8SB1SIQOAV8eSPtnFLiJjup1yHGN2nvlG17ViYL1jUBdtV88ZYfmVWzmnUNuCcX4as/TN T+YhdNfzPHME+yXlKW07OcT6DaBih9LjGg4ccotqJExLMlF/RMKCugEIPbKbHk4UeyxP4qU3kU/ JJkzk/uLBFnDUeaN5XWcQotnGjg6/rjoXPD/BwHQJq+RyyxIS7xO7ThL88ktuPWjYmrBiyz9zvm qIRN2yY3dhuW1blmyxAlFcw2Lz4BpXCQTytFfb/2WuY92C2wuIr4EiLodhYFV+sXVClZQU6JsZI mAhPkAHgVVcWShkbMckVguLcqQZqEueNOh5yY1sEURSs4wGKkyAUeKbKXmekKdiCPtZ7/0FLoUe zVOHFBJLsK6W/Z84uGg== X-Proofpoint-GUID: 3gS-ICtnaATCTbyQVeOR8JsakyBDLE1X X-Authority-Analysis: v=2.4 cv=apyCzyZV c=1 sm=1 tr=0 ts=6a0deb3c cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=r1p2_3pzAAAA:8 a=hcTHx3Z5Akp3fEzgVBYA:9 a=+jEqtf1s3R9VXZ0wqowq2kgwd+I=:19 a=r_pkcD-q9-ctt7trBg_g:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 Content-Type: text/plain; charset="utf-8" On error recovery for a PCI device bound to vfio-pci driver, we want to recover the state of the device to its last known saved state. The callback restores the state of the device to its initial saved state. Reviewed-by: Julian Ruess Reviewed-by: Niklas Schnelle Acked-by: Alex Williamson Reviewed-by: Matthew Rosato Signed-off-by: Farhan Ali --- drivers/vfio/pci/vfio_pci_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_c= ore.c index 27642f10fe97..95af3e827ee0 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -2290,6 +2290,17 @@ pci_ers_result_t vfio_pci_core_aer_err_detected(stru= ct pci_dev *pdev, } EXPORT_SYMBOL_GPL(vfio_pci_core_aer_err_detected); =20 +static void vfio_pci_core_aer_reset_done(struct pci_dev *pdev) +{ + struct vfio_pci_core_device *vdev =3D dev_get_drvdata(&pdev->dev); + + if (!vdev->pci_saved_state) + return; + + pci_load_saved_state(pdev, vdev->pci_saved_state); + pci_restore_state(pdev); +} + int vfio_pci_core_sriov_configure(struct vfio_pci_core_device *vdev, int nr_virtfn) { @@ -2354,6 +2365,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_sriov_configure); =20 const struct pci_error_handlers vfio_pci_core_err_handlers =3D { .error_detected =3D vfio_pci_core_aer_err_detected, + .reset_done =3D vfio_pci_core_aer_reset_done, }; EXPORT_SYMBOL_GPL(vfio_pci_core_err_handlers); =20 --=20 2.43.0 From nobody Sun May 24 22:35:49 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 47AAE3F7A85; Wed, 20 May 2026 17:11:29 +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=1779297090; cv=none; b=b3uYTZM05MG2DAWJ0OuGkKcd1UryWwNI4oUll84mtqGAzX2bPqEmfRIHnagbjpJrWz1cp+eHDV+bj+ddRdKFNwA3NoEMG5SNh7Cd1gF/WIiHIEYyMH24Ed088UyPl6bqLh2S3rqRbd5e0Evv4QUqBvgc/W09ondwmIlQJCmmLOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297090; c=relaxed/simple; bh=Q49eZSf2vr8VwDmj/kMzowyUpNcywD0X7zghuEPtmnM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RyYwtyZRv1jc8FZGfrpCKOSKItyVRovrOno3JgdFjjC0/8DHx5nFkyY87DjUCz8nsO94y7IGzTUTGhvkBf7LfXXOxVsTUgBvflABMR5TQ2tbCYDYt2Bm2LYajBkHp2A1bI142aXM/lgpoH0ledUjZ1Fp2xZ3c7VNBNQOY5ED6gk= 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=diHbZVwP; 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="diHbZVwP" 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 64K6mead1594906; Wed, 20 May 2026 17:11:25 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=MKCsaNqwmGnMeVjkj BHNF9wk50yw3yiA3EhZNBhzZkw=; b=diHbZVwPhSdbwiwIWs9TVIQ/TXaz1Rc+H gL3C9eyTloFiK3WQtj80CL2oR9Oy8sJvpJRNvyc62ro6XS79n4FE4GGThzXh4sJp FD4WWNw0cg8dergLWH53q5wEo6Kpagw9lkLBOxC+vAVwU7rHqj/NmuXk8Hkv0uUV g427EOi0FI9TiNlxjq5RUuY4XnfK9tjZepergLOld+0sAd67btxbHAxQqpPnrstv +dkGCcmAZijm2lWkaeBlssVvpr51nPbZhoQsbiZ/bGriA03/7vYJcXBi9pokm1kE kxgpVgkNLCQ27hvZDTfODheqsFOYZTGfc3UWRjgDFYdD77BOOhnVA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6hb8j472-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:25 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64KH9846022657; Wed, 20 May 2026 17:11:24 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e72wq8hhs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2026 17:11:24 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64KHBN1B28377704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2026 17:11:23 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BF215804B; Wed, 20 May 2026 17:11:23 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A57A58063; Wed, 20 May 2026 17:11:22 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.46]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 May 2026 17:11:22 +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, Julian Ruess Subject: [PATCH v17 7/7] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Date: Wed, 20 May 2026 10:11:13 -0700 Message-ID: <20260520171113.1111-8-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520171113.1111-1-alifm@linux.ibm.com> References: <20260520171113.1111-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-Spam-Details-Enc: AW1haW4tMjYwNTIwMDE2NiBTYWx0ZWRfX6X0Wu9AMyMyl 14lG6T8qrNhfjp5rtSg7matWTGpX4HOt24cEBca4dLBR8Q0Ukcpoj7q+WEux2Bg+x0OgAxfHaoP 0mcDzi57C5f2tdkIgJuqPixImcczicL2wPwMv3TmKLHACcqjMXUypNUaMjkdXdrUZo//c2Y1gF2 GWs8BG7e8mNk+0sXFyIlZNy6uguftufWYNZMg9CGiAK5z3EXBaFpkFF7ZiJqpD30516UUXFhs1K bKVSZAkYcKELXdN+Wiqh0PRV1LpOAwLOXcTgpwq82ZRqsVpR5u04qj3uvMYpYF4QkW9+uidtT3I UfRtrL7Kq9wJ3iy06xVRz2tijRGnJ8RXtfsruPbKV/LL5vuusw/BEIG7/JvG2tEEujU0B0fM+uc XZnn9CQgdGwH6R3JkeRLqNx8HSNcG6gDLqZc6dSZa7d5OhqjGMeyf/ZXpjMVdmVQPQzia+QyUBU 9IwYtffZu2m+W/mb78A== X-Proofpoint-GUID: GWttA6zLkRx3ZFIbtLfEuSO40uGf2Jyf X-Proofpoint-ORIG-GUID: GWttA6zLkRx3ZFIbtLfEuSO40uGf2Jyf X-Authority-Analysis: v=2.4 cv=aYBRWxot c=1 sm=1 tr=0 ts=6a0deb3d cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=r1p2_3pzAAAA:8 a=bf5i11FZjm5gBOpVircA:9 a=r_pkcD-q9-ctt7trBg_g:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605200166 Content-Type: text/plain; charset="utf-8" The error signaling is configured for the vast majority of devices and it's extremely rare that it fires anyway. Removing the pcie check will allow userspace to be notified on errors for legacy PCI devices. The Internal Shared Memory (ISM) device on s390 is one such device. For PCI devices on IBM s390 error recovery involves platform firmware and notification to operating system is done by architecture specific way. So the ISM device can still be recovered when notified of an error. Reviewed-by: Julian Ruess Reviewed-by: Niklas Schnelle Reviewed-by: Alex Williamson Signed-off-by: Farhan Ali --- drivers/vfio/pci/vfio_pci_core.c | 8 ++------ drivers/vfio/pci/vfio_pci_intrs.c | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_c= ore.c index 95af3e827ee0..e41669fa045f 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -821,8 +821,7 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_= device *vdev, int irq_typ return (flags & PCI_MSIX_FLAGS_QSIZE) + 1; } } else if (irq_type =3D=3D VFIO_PCI_ERR_IRQ_INDEX) { - if (pci_is_pcie(vdev->pdev)) - return 1; + return 1; } else if (irq_type =3D=3D VFIO_PCI_REQ_IRQ_INDEX) { return 1; } @@ -1198,11 +1197,8 @@ static int vfio_pci_ioctl_get_irq_info(struct vfio_p= ci_core_device *vdev, switch (info.index) { case VFIO_PCI_INTX_IRQ_INDEX ... VFIO_PCI_MSIX_IRQ_INDEX: case VFIO_PCI_REQ_IRQ_INDEX: - break; case VFIO_PCI_ERR_IRQ_INDEX: - if (pci_is_pcie(vdev->pdev)) - break; - fallthrough; + break; default: return -EINVAL; } diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_= intrs.c index 33944d4d9dc4..64f80f64ff57 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -859,8 +859,7 @@ int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device= *vdev, uint32_t flags, case VFIO_PCI_ERR_IRQ_INDEX: switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) { case VFIO_IRQ_SET_ACTION_TRIGGER: - if (pci_is_pcie(vdev->pdev)) - func =3D vfio_pci_set_err_trigger; + func =3D vfio_pci_set_err_trigger; break; } break; --=20 2.43.0