From nobody Wed Apr 15 21:17:11 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 2B972392C3A; Mon, 13 Apr 2026 21:06:20 +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=1776114383; cv=none; b=GWQpyt2f/1pnVMh25yBkDJzsqLErDhVd/YRKNAIGbeZDgU/kngH6bOurtZ1JuyJyAygtAM1euqEZr8xWwtaq9QvkbRh+Q6wWN0feTFMWY+Sd033hwkRaQV4psPaitxJ9adVN/M6++bCXuay7vAG8a4e/ACN+aPYKYM8yoqvvvLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114383; c=relaxed/simple; bh=ZANUHF92z/5D08FuUpzVJ7l0nfqJHG++dU09m9Zu/yg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C2mi181iNFv2omT1AM9Id9N+eblmtcfaqu6iAo5ibEWF79nVzB8ztYjdEfuYLVwOaYCoUV7DWsBogOb3cWl62NnNb3fq8hkTRzodLcqO8MsMCaK5sOddrXQUxzEZLhLBFQafdaf5dP2wK4vj7o0QV6oEu0OCrHeKf5yIa1J00Ts= 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=Vm1Mt5aE; 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="Vm1Mt5aE" 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 63DDWxj43055522; Mon, 13 Apr 2026 21:06:14 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=jQfPUqqA91bdGrgU+ yThItyVt6xMwgVJ/HtFOXJWzEo=; b=Vm1Mt5aEV99EmoNsYfZX1RePbp+Kh2nKR q3VaEsz7iHz9vBlZ2Mefn+oep6xxCiNA+d+3tho+rYUEQMswhpTPs5AchXsXyUAR oh9zWZ2ZaKsm7+2sBqpHfdjSIBT4ZLIQ2GWPH+xTV5DV3CnW4xUs/vn8b4RyOMnw xfL+xz4UgZfeBCbWdNpppdfyVGNfnaq5Hs8/ELkZHQJ2TGge928mulWIvvJ5c50R y1NtRlMlLYBlcjYku59SyfHMdz/V4w8iHWDU+mWHBkczjF7VxsxO2adFfUORVrJ9 yW4tSBvAE+ffDuHvOHWoaULbfVHxezjw3gMYqJ1IXaFK1ptBLrdMg== 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 4dfcqf1c04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:14 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DGnW9t015164; Mon, 13 Apr 2026 21:06:13 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dg0msf0c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:13 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL6Bqa26804976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:06:11 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B06AC5805A; Mon, 13 Apr 2026 21:06:11 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 530CB58054; Mon, 13 Apr 2026 21:06:10 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06: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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, stable@vger.kernel.org Subject: [PATCH v13 1/7] PCI: Allow per function PCI slots to fix slot reset on s390 Date: Mon, 13 Apr 2026 14:06:02 -0700 Message-ID: <20260413210608.2912-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfX/clYHEhBVv08 pgCMhIUu0apayFOu/BPf09Cu4NongGxiRSBH9a4TPzCN13uZ+PKwFHG1jLQyWjY/tBQ9ADXpQ0K f4cbkVntcrZfFIMeD9RPDcPTdOoOITuHG6g9TgN9oUXyMEWA1JTKLw/SOAAnC/slUP8vw7xTyTR rguDXzaFw5iuuIL9bbNSpvHeJoxwZ2zbwSwGewGLsHNDDPLoUngJ+N8XqqZdpzp+sC6JYdVqU63 IQqtwMITGqT8UC3Jgg4iUNxlnJ6tJatLGwJClohevVc9+bpbV1EJ940u586ItS/oSHkwQ7neAii 7rKU8Sx9OrXtafMfrTRTf79+KxC/XuW8wPnszw7pLOnMvR/wxIGQ+X/p62zTghW7ShIU4rktTY5 bqzcxzmf/5jxH+aIHm9p9WZ6hXiPyatC8HdNiD6TESdle0JhdVznN9Z9xLm5d5e9k8ctun8tt2q 0cvEFUuJbO9GIcpZhjQ== X-Proofpoint-GUID: jcbr_TyHDvi1KHh1u12mGMgPiRWeszf5 X-Proofpoint-ORIG-GUID: jcbr_TyHDvi1KHh1u12mGMgPiRWeszf5 X-Authority-Analysis: v=2.4 cv=YemNIQRf c=1 sm=1 tr=0 ts=69dd5ac6 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=9_SSeoq7eJPDN4OswFYA:9 a=O8hF6Hzn-FEA:10 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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 8f7cfcc00090..d0c9f0166af5 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 e0b7fb43423c..3f6e5dce27a0 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 @@ -176,8 +192,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); } @@ -256,7 +271,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 /* @@ -287,6 +302,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); @@ -307,8 +325,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 Wed Apr 15 21:17:11 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 5C72B3939A4; Mon, 13 Apr 2026 21:06:21 +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=1776114382; cv=none; b=tkszk42oyxyGHZo9oXo2ex9m/syt/tgiJDL0E9VZ6iBcwCqcdHcygE87BRPQDWtzm+b2bo/+qV7821YAX4gNi/0RPtSaBqWm43n3fQ4lq8iBp5JPFoBjso+8RN7yEkrHN1XYbEJ8cBfCzuACLIlvaafR8oofuJFeVQVMd9zHzzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114382; c=relaxed/simple; bh=POORsXRkk4nOKnrZRpviXSsULTny9Rnzj8bxogy/6pk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mbz8l0xrZomChCOQ7Y6AHdrnTbTkJymv4Ysk6XSLzwQZoeO/rCT5RzyEvfiKlfJvMD/CzEE2St+hzXbu3Nyv5+zf+quu2W1NjvEoHzxR68ZlwuSPfCwgOG9dMVLDJ003CnMcVt1ROeYb/DG+tY7790bVYygk3dPWvJszjySMldA= 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=o8h+GjpC; 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="o8h+GjpC" 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 63DG3m183430311; Mon, 13 Apr 2026 21:06:15 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=B03ES7Gw4vOtbWqO6 B3bh3UMTVIWbkYsdM5+gP6DaHk=; b=o8h+GjpCCNNspgx4cqSKhQHaZRZb/B8ad FL6EUIwUC0G8xijUWB4YuVnjWlAm3Ei3A3PgzwBl/oE8Lip46/aDHkaamhUjCS9/ rRpThy+M9R37I2mcsVXAnM0sccUo6iGGdmS3JPiQ5ARsS5ygPaBbzDe3aBsdB7fO qjzNoFD9hswRLbUHDNIgK3hY2rkH3wXrQnJ+RtYk3QykDKTZC/94doXctBCWAKC5 PzNY3UfTW6f+FyEWEx84kc+sGcmoY+mWf4opjzkIDm0m7YxHss1mvlvxaoIh9+Tg R7TPU+81tyQpUsnWjljr50yieSCqhUjTlvwl8gvZvjOAgT8vpcUvQ== 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 4dfcqf1c06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:15 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DHF0Xs031106; Mon, 13 Apr 2026 21:06:14 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dg10y6ymr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:14 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL6DWT19792514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:06:13 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3433058054; Mon, 13 Apr 2026 21:06:13 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD0725805A; Mon, 13 Apr 2026 21:06:11 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06:11 +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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Bjorn Helgaas Subject: [PATCH v13 2/7] PCI: Avoid saving config space state if inaccessible Date: Mon, 13 Apr 2026 14:06:03 -0700 Message-ID: <20260413210608.2912-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfXzDHj9vBP0TeQ pXkTOB2W7YPfhOYl099O9D0QX8Rvk1mu+qLTwh7hkI/LIwf6xiRaROPgpu10fjGAcXTDXvVHeP8 ys1Wo8wSnp1Y4SZM1C9VOK4fricwrjcrp4pwwgsBNAqvUrGiAzGmgsAsp9puiNlEh1sEcBA73xW jjFKTqQY2UmJ+veWtfvbT8tRcdnMdLzDts13Vx/ghvEGjAlSXXcrKBs0aaNc9p5y8mQH0iTGKvU /Csq+HludxiB+f7ZTjwiBEXKQpsXo4VH9MHbnpYdZ06jf1tI8rM4FOtGzGxHHCIPcprQF06Thk+ rVTFNswxoH+QNrga93xzI3/vX1Y4JZPPRh1hWdSMKXxYsIjCQwrT7T49ZsHCtV+05jTo3BmDK/q G1mhtZ1HT5Bm9VhCT8bKbd14y96GAITrqoF/VDziDYljOwQmaReLvviWh90nNizJCkoJAf94fH/ pO9JDFEIH+VbtU0mNgQ== X-Proofpoint-GUID: sENcbDER-SnREitPnUnRtymFyQoEx2Iu X-Proofpoint-ORIG-GUID: kfYcxr6v0-NRyAeQK0vVsAsWlu0AbjoH X-Authority-Analysis: v=2.4 cv=YemNIQRf c=1 sm=1 tr=0 ts=69dd5ac7 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=A5OVakUREuEA: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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 d0c9f0166af5..e71b81415392 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 Wed Apr 15 21:17:11 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 B6389395256; Mon, 13 Apr 2026 21:06:31 +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=1776114406; cv=none; b=rm5gRbvOzECq4GccEpbuSECsAmD9ayfvjaGdXdhtqKvrn+U+frvgY+iiuWJJ+fU2+VJI/lPFFMdsHdV5HBrEtmxdmP4luerVKE9OJAqI45EuWy4fJLXACpP2wjPycng2h6v7yKu7lf3HoTCMZuHv8KAuCBWKJIGQ+HE7ZEGCOFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114406; c=relaxed/simple; bh=/A4i7jVvjy73WaQOU6JOmUh4l/ODHy9wJnwVOUgyG1k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JqtydYZxXO4E2x7QEndPYYgjo4CTY11GujY1FD1Qlu4EL//pU/u9oZ/zVb4fnV57tNwpjEIpXTYB83X8CaN9Z/I32E3mrWI71r/5qUdoLnG/ft9JlJ+JMgIhXPoEGyInLSnZnHNGNF6ZGRP024g/TC3GQDzNklvnLID65dfa0dE= 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=U2bEXJjX; 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="U2bEXJjX" 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 63DIPdpv1434207; Mon, 13 Apr 2026 21:06:17 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=Xr+EsZK/+1s603aWr /wUgOxtfADRseSmWFfwoV44DZo=; b=U2bEXJjXiQuYSV96yvTjwcVcwy/41cOVK gVyLy+lLDMJn5l1IZAtMr/Zj2ABYxdO3KkfwgkQK1qsoo7Qrd1wwfeLzypkk9IZH l48Xf8qiasWg4p7EMCxGfym1WY6/ab0mV5YCrM0ej15w/P/RmteYpIw8tlG+xdQq kFwUCdcPDuI7LM6EfnTMO0sby5QlopjcTeXGYvq4mjhQSbOg54Rf+reV1Dj4d81N Bfb6ozvr6lwyTbW8RYQBmNCts72TxqQNCMo6wfxt+DNC5BSv0Xgkr9/Kqi4j7Alc ep7Nk3/l1rmAyI2bovpZe5e2W0L9rbR0KjRMOB+i5d5UyV4h7UCnQ== 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 4dfdt3stq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:17 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DHitiJ003581; Mon, 13 Apr 2026 21:06:15 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dg1mn6uvv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:15 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL5nn721955232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:05:49 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD9425805C; Mon, 13 Apr 2026 21:06:14 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60F2D5805A; Mon, 13 Apr 2026 21:06:13 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06:13 +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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Benjamin Block Subject: [PATCH v13 3/7] PCI: Fail FLR when config space is inaccessible Date: Mon, 13 Apr 2026 14:06:04 -0700 Message-ID: <20260413210608.2912-4-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: 4zPxh-wgXZo_Nm4reROeeWPQYZrckS9D X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfX+wFh33SAYx5/ q+bnS2nraZA7Pec5cKPfP2rGL3n9tkmyKLwy3g4Vf5hYiuZUSaKU5CYxQbNJQ+S4lGAzTl0m38I Vj2tGNQsAh/a8j8N0DedUkXWZ1rGWEqtY9QEhzBl31VNYbJfBCdfT1F8/T1ypau0u/ne1wjiSst HBOQNv8IwfzOd/wZ73xj2TisUdez60wZUg23PbiH/ElTVgReefCXRO3NNbAyxIYXy8YClxB50G2 pMVRKiPj5SaFL34x9ypoDAL+MIcVwY7Npkoz0De8l5viNz2f1ahGUUXKY0hZUFxKQyedly36Aa2 FiWpddV3oWxVM2KnduDKlBOaVT0XIS3I+W145OimIz6OsqIAD8ZOuY7h7fi44B0d8ta3tJwMJre jWY/RMVQckSlOyEQYY4BwlQsZ6IKHScIJnvFI27iw8UNfGN2jpdy9cB46alN8XgnUpSi3+HV45i Mwce3Ai0S+IZ30WCa5g== X-Proofpoint-GUID: 4zPxh-wgXZo_Nm4reROeeWPQYZrckS9D X-Authority-Analysis: v=2.4 cv=WpEb99fv c=1 sm=1 tr=0 ts=69dd5ac9 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=1owyFLT6pZZ0tE0DW5YA: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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 e71b81415392..c50418f5e318 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 Wed Apr 15 21:17:11 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 1E57E3939C2; Mon, 13 Apr 2026 21:06:31 +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=1776114392; cv=none; b=MTWEKv13gz7BDum7IDXeq1m4SD0D4m/HlTTkL9/5RVQqc9tkHW/l1wuYKJK6IunRt0jinJN/2Ue9b0kDrpTVRaQYTYMkY4xDDbRfQRMmMr4jeTZ+tEd/xhQ6K0zHk4CZTwvOm7qd49CYC2cRDk8+OUzqJCIrd/fCjaoiwNAHjkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114392; c=relaxed/simple; bh=7XBd5bcesB91ohH3YRduu0Up3iVNs7BcRGoWM30e79k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TdRJ9OK2schr9vrYCvK80U/zh7Tj36u1EwS+zV8cDq0VbYjCx9H/T/OmWMFn2YudZP8RiLLAg58C1R0wh2SKSWZ0VMS5XnRJmFbphWCAiwF5ZBIiDy1H0MTdBK1W7b1+X3QYrx9PfumCPJPWQDnOMCwvbubSrwfyaCaA5oHkkr8= 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=lqfemZ0W; 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="lqfemZ0W" 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 63D9CNcq2019453; Mon, 13 Apr 2026 21:06:18 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=RPvGE9yDgHIntjRx9 rPf5CLfrprpavTVIkBl/uokYL8=; b=lqfemZ0WvAvXV91CfXGR7ja0eiGVfyl8q jK4UFIYzN8ENyE3Xhso+Fz5CwbBBJyl7TeqlaZawjm2fv8wVgS2JVsp/DmaEzVqt lo6CQDItfwib7UcNDcwKmLLksb3wq+mf0kk5zyr7IOKiEa6U6lP3D25llHmLTyO2 PS8puFaFpL9ACM4v3nE0ya27Kpg45d8js5ft4mu4eEb/C83kkC3VVUMnOyfoRUri I2UUpXstv1ONtkBHqcR9HAZ0zsOsGGhRN3IWQO1lzoHS/NanXKFWkX9nkZmlFmZk vIO4NpDwHSY4mxMN0efEB5BKBigSrkV1RdctqOYVp0Ha3Q448QfJg== 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 4dfdt3stq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:18 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DHG3Dq003514; Mon, 13 Apr 2026 21:06:17 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dg1mn6uw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:17 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL6G9N20579040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:06:16 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E42B5805C; Mon, 13 Apr 2026 21:06:16 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB80B5805A; Mon, 13 Apr 2026 21:06:14 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06:14 +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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com Subject: [PATCH v13 4/7] s390/pci: Store PCI error information for passthrough devices Date: Mon, 13 Apr 2026 14:06:05 -0700 Message-ID: <20260413210608.2912-5-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: e9urMqbnrvezVea886TbRzQCt2l4_Dsr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfX52mx2jSmPZd7 q7QtnDzIXGdRsLjgx3qxnJCNTHzOcDlqNU2X20A2Zpw5SiDxGaWi528d2XjqBeFQamgrShuxaRg UaAXr8CPg4lk5QISFBYcu32jrhWnU7qOKLD214zlQRkif//1XHpQVebbaJuRx6Als5NQXIu3v0D lb6yT0t/xaq2uHAdmiyXDRprGgsqUqZnGiAvAHTGn9I+426N9FR1or9GYqIP6ZYKV06Yll5Ma0M JLXlXT5z8W3pHLxX6x4gQQSoOyOP11d8JfFcO8VaLPH+p3RBCPN9ViqoPjVosb1eOOC7oWSCVN2 dM9h/IbsPmlEuEob/cXR/0YyyOo68MYb2gBMxWuxPoWuEtqsPlXzAHYT0tB0+uo4cI2pWMr3dlm pB09IBTu6iDqcQg14yHkr3J9M+6m3t7IwPYjyRWLamY5/++gXgPD1HG9QyTy4IWeZA/PmSkjgv6 xcjKS6kXix6K4e8rGEQ== X-Proofpoint-GUID: e9urMqbnrvezVea886TbRzQCt2l4_Dsr X-Authority-Analysis: v=2.4 cv=WpEb99fv c=1 sm=1 tr=0 ts=69dd5aca cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe: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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 | 117 +++++++++++++++++-------------- drivers/vfio/pci/vfio_pci_zdev.c | 9 ++- 4 files changed, 105 insertions(+), 52 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index c0ff19dab580..9a6a4eb9d7c1 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 @@ -330,6 +358,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..c279a9f50a64 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,50 @@ static bool is_driver_supported(struct pci_driver *drive= r) return true; } =20 +static void 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; + + if (zdev->pending_errs.count >=3D ZPCI_ERR_PENDING_MAX) { + pr_err("%s: Maximum number (%d) of pending error events queued", + pci_name(pdev), ZPCI_ERR_PENDING_MAX); + return; + } + + 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++; +} + +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) +{ + struct pci_dev *pdev =3D NULL; + + guard(mutex)(&zdev->pending_errs_lock); + zdev->pending_errs.mediated_recovery =3D false; + pdev =3D pci_get_slot(zdev->zbus->bus, zdev->devfn); + if (zdev->pending_errs.count) + pr_info("%s: Unhandled PCI error events count=3D%d", + pci_name(pdev), zdev->pending_errs.count); + memset(&zdev->pending_errs, 0, sizeof(struct zpci_ccdf_pending)); + pci_dev_put(pdev); +} +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,7 +190,8 @@ static pci_ers_result_t zpci_event_do_reset(struct pci_= 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); @@ -194,13 +210,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 +225,24 @@ static pci_ers_result_t zpci_event_attempt_error_reco= very(struct pci_dev *pdev) goto out_unlock; } =20 + zpci_store_pci_error(pdev, ccdf); + 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 + scoped_guard(mutex, &zdev->pending_errs_lock) { + if (zdev->pending_errs.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 +287,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 +345,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..0658095ac5b1 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -148,6 +148,8 @@ int vfio_pci_zdev_open_device(struct vfio_pci_core_devi= ce *vdev) if (!zdev) return -ENODEV; =20 + zpci_start_mediated_recovery(zdev); + if (!vdev->vdev.kvm) return 0; =20 @@ -161,7 +163,12 @@ void vfio_pci_zdev_close_device(struct vfio_pci_core_d= evice *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 Wed Apr 15 21:17:11 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 BA1D5395257; Mon, 13 Apr 2026 21:06:31 +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=1776114406; cv=none; b=UtxWcufdqbqojQIBLrx/t+yIqt1s85fozPqRQfNyT4WA+XJc7P4NdlzraQAFMKfL6sjnnAqCwK3V5rpiDtNkD/jexM1j7+FOok1ijOXZ0gEIb0BstusYVIgkc07wVu6wqXT+fg5fqtlfIgjrQ3ZALKNjIkO4Ri8rHrhN56Wc6k8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114406; c=relaxed/simple; bh=/uEggNkdsC/xW/ltN58wSyCWvJGMRnO5Hfsq66BzRf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TdFLurJXB6CmwGl6yM11OstfteQHKJy0urGQn4Zi4qJIrC4NqJVwC8X4FExo/fAK/YWs9gIW8Pyy5wCsw5XpBya9gzxvU6Ms/6VEX9wGhBVsgNG24vKZ1X+oP6u+tvQlHR36L0I3nmeMfz6oVQEawbOeEfe3I+YVft0UP+OoxEo= 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=k53uyMrg; 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="k53uyMrg" 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 63DEGZlj3188928; Mon, 13 Apr 2026 21:06:20 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=FR64xQJYfeF4fne03 nKK0mFsx4eY3xKNPjFcXnhPzoA=; b=k53uyMrgCK88OUsQmld5NzBKEqgEmPppY xOpyG6R9/4h9Jd9dF6sEuzP5Nb3TgxSPcYAeNufEITB3+bXjzjdmJ+r1iORKcZVB zbQlWdfe7/933bG09U2xr6efdsh9oqQw0674yFpOkn4xvAzaaSe/gfiIGlzvQpIE Ec7AyY1yXpMy0b2sRWEI061gJ+EX1ICAr2o4+tClEWZMdWv9/1PsdnrJmANv9OB+ ThVcFDH0OHtG//rwhyCzfv/DswlJG++CPPRXF7Kpol/U94iOaMiQct5RTno7aahl 00aBv9ozq289H+hTYcTenM6S5uapjWARqqJvb0wTPfI1YhRqN98WQ== 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 4dfe17sr4j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:20 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DIVVV7025621; Mon, 13 Apr 2026 21:06:19 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dg2ujep68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:19 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL6HLM19202638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:06:17 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9164958054; Mon, 13 Apr 2026 21:06:17 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58C365805A; Mon, 13 Apr 2026 21:06:16 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06: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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com Subject: [PATCH v13 5/7] vfio-pci/zdev: Add a device feature for error information Date: Mon, 13 Apr 2026 14:06:06 -0700 Message-ID: <20260413210608.2912-6-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfX7phLIbUIz97l +KyZyLAbt1Er+jeqxm98a7EbUS6tDDSTh3bNM1iDLezZ5KDrPPW+osURzt4am2wSyxxr8nxQbQn BdAJvMRIF8TnkftSv6Z9pO8vab1ezV5kXDwilT8DuLqofXVc305OGfCsqdx43rmTjzPHnQOWnek QMfB2eBs23EsyJjxLj/Dk52yeDL789+zRM73+kubl4OxCKRTCBlh6DMGvGp8MvyNqyHgBICeBFV 9H0LF/bKV2gO9TMvbKRijPMkPiQ6kHwO9e6ov7rCj4gUnkmdkZ+TuccVtg1+T2qCBCXu9hVuaF1 Q7TE5nHoJ59EpB36OZdCNlwIY9cv1D5qSCCxii+flATSO5XWxZDyeT28m+f5ITOZBdRl4EsTbjm b9pwTfx47mB6JqsAFmtjDf07J5Ccqf3w3bLZA9LsGBziH0DZmKSirghTlKnYZ8J/lZBJJrFhDcp S/ZtytyjgmbU4TsjeQQ== X-Proofpoint-ORIG-GUID: 70RhArFj3c9qwd1en8y8QEPT4uTwdvRj X-Proofpoint-GUID: 70RhArFj3c9qwd1en8y8QEPT4uTwdvRj X-Authority-Analysis: v=2.4 cv=SrOgLvO0 c=1 sm=1 tr=0 ts=69dd5acc cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza: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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 Signed-off-by: Farhan Ali --- arch/s390/include/asm/pci.h | 3 +++ 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 | 31 +++++++++++++++++++++++++++++++ include/uapi/linux/vfio.h | 20 ++++++++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 9a6a4eb9d7c1..9c8ee97d7e8a 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -360,6 +360,9 @@ 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); +void zpci_get_pending_error_and_count(struct zpci_dev *zdev, + struct zpci_ccdf_err *ccdf, + int *count); =20 #ifdef CONFIG_NUMA =20 diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index c279a9f50a64..c8714d4a32fa 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -74,6 +74,25 @@ static void zpci_store_pci_error(struct pci_dev *pdev, zdev->pending_errs.count++; } =20 +void zpci_get_pending_error_and_count(struct zpci_dev *zdev, + struct zpci_ccdf_err *ccdf, + int *count) +{ + int head =3D 0; + *count =3D 0; + + guard(mutex)(&zdev->pending_errs_lock); + if (zdev->pending_errs.count) { + 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--; + *count =3D zdev->pending_errs.count; + } +} +EXPORT_SYMBOL_GPL(zpci_get_pending_error_and_count); + 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 ad52abc46c04..5403730786a1 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1534,6 +1534,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 0658095ac5b1..ee1647f0ffe6 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -141,6 +141,37 @@ 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 pending_errors =3D 0; + 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; + + zpci_get_pending_error_and_count(zdev, &ccdf, &pending_errors); + + err.version =3D 1; + err.pec =3D ccdf.pec; + err.pending_errors =3D pending_errors; + 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..2980ca39dd38 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1534,6 +1534,26 @@ 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 s390x. On s390x, PCI error recovery + * involves platform firmware and notification to operating system 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 pending_errors provide any additional errors + * pending for the device, and userspace should read until zero. A value of + * 0 for pending_errors and pec would indicate no pending errors that need + * to be handled. + */ + +struct vfio_device_feature_zpci_err { + __u8 version; + __u8 pending_errors; + __u16 pec; +}; + +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 13 + /* -------- API for Type1 VFIO IOMMU -------- */ =20 /** --=20 2.43.0 From nobody Wed Apr 15 21:17:11 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 9503F395D8B; Mon, 13 Apr 2026 21:06:33 +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=1776114417; cv=none; b=EnSBLXy/TtWLlIvef589A7Du3kDGTbB+yVG7lJBa1ZelQixGXuVL9k4A/xWYO2XE4fdwT1UApQHd7KtUC/RdIW0LnMs2+/HKODijN8XwAL5MvyRUbAjDUEG3uAMo0hpztW1Cht0RfDQXBhXxeJYjk3gsfq0w3+7fFd2RSXcAFtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114417; c=relaxed/simple; bh=RQ7upiRfX+foiPulhHXu+Aw1uutRmHWJ0l3TcJW8bxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p6ShmQBfzEWiZZSp3Fe9jFloCOTYVxJ3WzjQafcWa4N8ZECWPt0zh2V9+kUZ/kL4ZLG5S3pZNrEhQaBMlzNzs+wOQa8cSNVtmiqCd7qoQLa+98hwul3L0KoWNLDJxjxo3XFYsTVbDS3dKlL8KrcAX86Hlax+jsJ+I8S6fqcTqYY= 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=e1h1y/d9; 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="e1h1y/d9" 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 63DEZ1xg3239865; Mon, 13 Apr 2026 21:06: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=l4yp/nvZGr9Da+6Zm RXwpQEFsXLYyw/698zFD8SAETM=; b=e1h1y/d9FYN8S8FHPwT+jc56rCE6cdc3N 5MIlulKICXtWP4hzFqvDYve6uBHCSYhlDVoRKpTE1ZHPh/0WSdkYuDD4kHbQsa31 EBzovO2q2iBYcvvjcTI/Cbubp6zKvGHCJ3nzlMzaAtZErMSEyDBIk3purQ3oWUmi Oehaoq2A1XgEl6F/E4YNeA9POeF4q5DDYpAQBj4qohPMegrDiZdrZh7mFgoxqjPL gfRpZGKzHYOydmpUCyU8beIoT23IW8aQbJcLwxB9LDEhOCb0cwoleERVSvgLpJNw RbtfEdtS9CYgRDzBOxgeKWlUdV6uE9TqZyfLzJAYjD+GnYAhUSVTQ== 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 4dfe17sr4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:21 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DI0ZLu004569; Mon, 13 Apr 2026 21:06:20 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dg24k6sqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:20 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL6J1K26542604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:06:19 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 116705805D; Mon, 13 Apr 2026 21:06:19 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC8D95805A; Mon, 13 Apr 2026 21:06:17 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06: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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Julian Ruess Subject: [PATCH v13 6/7] vfio/pci: Add a reset_done callback for vfio-pci driver Date: Mon, 13 Apr 2026 14:06:07 -0700 Message-ID: <20260413210608.2912-7-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfX/uWGCs6paNcH UGS4aOioLSMmG94g8LQx+X98dtaC8M2pgQIosJe7Yr4dxnoUrq2L2YhUxwOzcABuwefDJCLnn9z lR7iDtlT00ePBKFy/XSE2eA/StH+vj5r9bXieWNIJtN7HYV1Fwzv0s/qM6sKEVtbw2cBxaSK5OG xreDaTkYGfl37oT6WVxHVE3uz4kt+ebHckFFtAxpX9XmSh6iGBj67+PUYUIfpes0ZfwZjl8yomF JVHSGA5O5DDmPex5iZDCRoQjRoOrzLsc64ADkVN4ZpyQJDOPP3R6FNhYRu+Ej+C4ZyS1CPgVllx wWitNLLlKs9gHm7b/VrHXo0dY7HRapz60zNHEdciWdWH06+xS6BEvd4RxHhQoi3dUTTSQXn72L1 abjiK7WFgpReBbhIlNmgxxthenVCybKQpeUCBHgVuwSCW1AdYsBxVkplS01TcKyemJNhTeQKLka s0jtNsJZ8quLFnZzuDQ== X-Proofpoint-ORIG-GUID: 2mCHqnnhgccoAOpnpjXWDmTjpLROSXDB X-Proofpoint-GUID: 2mCHqnnhgccoAOpnpjXWDmTjpLROSXDB X-Authority-Analysis: v=2.4 cv=SrOgLvO0 c=1 sm=1 tr=0 ts=69dd5acd cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=r1p2_3pzAAAA:8 a=hcTHx3Z5Akp3fEzgVBYA: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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 5403730786a1..4485d85e4419 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -2255,6 +2255,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) { @@ -2319,6 +2330,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 Wed Apr 15 21:17:11 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 20902395254; Mon, 13 Apr 2026 21:06:31 +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=1776114403; cv=none; b=M8fqHKGxQgTWEUGEXWv2gzmYw3v5cgw+G2JRlpYIhWkprucwButc58LsOgSB5Qo20Z33AjR20HHJksSZb5i9GVg9wadqE3BbtSW7+G6vzwsxm4ndnCCqXcq2k/jZENANzb+52UxG1Z8mw3CGFXTnlxJL0ImaAR3c7+GSPFMDk0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776114403; c=relaxed/simple; bh=BI37w9SjuKL3yvCM7bDoU4en5ns30NyXBnAazDt1Q0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XGRfQZDk/EBbrLr1e6mv+oWGp+EhuIeLFiHyKTeslwCFqZeZ38NrBsOFwnI21np6SngNxted2BUOP8e0cND1VEipimOIY0XuHkQJGQ8RiXrOJE15XtJgDGotxxIUtN3P+M6OIyga4Op2W4mDWqzNVThowp6xnqA+eVKDqjI8v8Y= 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=iLlC6uLc; 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="iLlC6uLc" 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 63DEYuqS3427021; Mon, 13 Apr 2026 21:06: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=ptCH11AOccuUefO9O 9jqin/FEkhD0OjCVnd7OxBRv5U=; b=iLlC6uLcbE26n48o0XepzwF7Q9EZptPHI 0Cj5k5S6xDW1805uGn1GpGNE87hA6ZBgbyhW+nl67YFK+QMAD4yrAVmerRViEqWK kBTFlDJS0gxkFlrfkAls3MFYsgYhqp0CRLls4uUHttD+vDr21tZBxk/JCGSN5k5c B+crE6EUmg2TnQ3BPPifIQDQq0t0O/8N3076TlVZr7Ob6a5iopvDJ9VOw5TzPobh oKCiT9NjyCE5UBh/A1pFf1hHd+yWd/yA1H+isiaxDurUBu+dronYbmmIuYrbsC+5 SjvAZG6g9SP2XxXZ44zG4+SK9al6dgam26OOHJxewMjwFxpAXLy5Q== 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 4dfdt3stqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:23 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63DHF68e031138; Mon, 13 Apr 2026 21:06:22 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dg10y6yn8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2026 21:06:21 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63DL6KU633292992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Apr 2026 21:06:20 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87F7D58054; Mon, 13 Apr 2026 21:06:20 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3ECB65805F; Mon, 13 Apr 2026 21:06:19 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.131]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Apr 2026 21:06:19 +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, lukas@wunner.de, alex@shazbot.org, clg@redhat.com, kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Julian Ruess Subject: [PATCH v13 7/7] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Date: Mon, 13 Apr 2026 14:06:08 -0700 Message-ID: <20260413210608.2912-8-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413210608.2912-1-alifm@linux.ibm.com> References: <20260413210608.2912-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: 01gz8V8Ky8gYhg-6ytjpBlEhjBTwiVYv X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEzMDIwNSBTYWx0ZWRfX+jsbmIsLaAHv 0kUTzSiPoI6zzTm3Tb7CFFCW9S8tF5g7vq9r9ynoczdrA4mTTGOKVvfv/rtWkR8jreZFukrLAa1 +5k0J8sIngfSsDXJiSUGEwyXO/nEty6jCJQ7lEKqRKYKt777G7BzMO2MMgnunVA1KXZbZf+zj3C 9hlv2qBFlZ7/If3nLfayz6AU2bCf/4QkbnwI/GVOfgf4l7ir6ezD4xG97vbt8L3JgQISe5xg1l4 O65LM3BcmnYSuflnAOZL3z4bp4PhOZ9PV0Z2mdUfhIaDd2VVhBZZCSy7Sk0vGtkyqsTKJOrTZjk 6reWcSoXiDvQUnx137c1MtMzvbeDXHlxp+UWLzZoLJsMhkzb5J0b5tLUjk36j1Zp/H8P//ZA5Jd yPPaYB+TgKhGTTTgz4wUqA8Ek6Y9d/ZXwXwP3bv6/pODMGtN8j9VTMpaB5bfK7EWMbiwktR8AhT RG0wgirIamiIIuCrqaA== X-Proofpoint-GUID: 01gz8V8Ky8gYhg-6ytjpBlEhjBTwiVYv X-Authority-Analysis: v=2.4 cv=WpEb99fv c=1 sm=1 tr=0 ts=69dd5acf cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe: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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604130205 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 4485d85e4419..407be85dd565 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -786,8 +786,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; } @@ -1163,11 +1162,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