From nobody Fri Jun 12 12:43:37 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 6AC4826FA7A; Thu, 14 May 2026 18:01:11 +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=1778781672; cv=none; b=ONhG9pF7CtnHzk0E+FYh7e4kwG7Ld3J6wNfu0k0Nj4TCebygSh/c13Hg1n7+Ft2X0Gx7IL1J5AYSlPGemPWTdMBNFgHfI4iQZOLdJfANjZ33kFMMWCH3tRf/jnaJgBJ5IljdJVrxNRIYWJ/jTeVTrnZ5E/5NkH7i5wcKAhXjUuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781672; c=relaxed/simple; bh=k4KMELZOZMjReqUINd6UWjfPtFpSJBooYrdFY9fuOQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mg0AQkNz4pY4JQZClooadNO3aVc5g9aV9ZMahAyXZT2UJjD/tpiLDmR7A6u+CFjTi/D4Mmf8QOcTl3kN5W8EQ1V+Y7SKvEuYaRWHCDx/+3lMR2QXLygkyrSXqTVGqNgSJbofhDlw3L17eYaBOUnnidlNgwavU8Eb3ntWomzEgNc= 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=ScEeQI2b; 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="ScEeQI2b" 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 64E6cQWa3185046; Thu, 14 May 2026 18:01:07 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=ScEeQI2bu/eplbwuC90Bf+3rhJSCE5B6P oNklVsxDUeeueWmIYo5Sa5kAfHp+4s0sxi10H4izQog8gPGg8FapPXZ1yTivgPs8 8cz2JyaYhhxavw/sYR9+iQlOSqG++dEB//tc4xMlJOQqn1BcdYs2qa7D67NIvFCa xMAIoF6o+Yj4xD6c7Or+vaTsG/cOUcJh7QpGgd/6vzFlCTVqBTDoSVgvJMVMDSjN EC16lWHyeSyqZctSQBzMIp++HncsU/i50C51Vm/Em2s4zmAgMB64pRhXMcpLrYkW VxEZikMdTFrGJk7OD16P1xe1q+AvDitTU/K5ziUwbqWj4Xk1iPSUg== 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 4e3nv5nuu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:06 +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 64EHsWLT029409; Thu, 14 May 2026 18:01:05 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfh5keu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:05 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI14VK10158708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:04 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BAF058054; Thu, 14 May 2026 18:01:04 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45DBA58050; Thu, 14 May 2026 18:01:03 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:03 +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 v16 1/7] PCI: Allow per function PCI slots to fix slot reset on s390 Date: Thu, 14 May 2026 11:00:53 -0700 Message-ID: <20260514180059.1553-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=cPHQdFeN c=1 sm=1 tr=0 ts=6a060de2 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==: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: kWlFgyau5h5KGjymVy7G4gG1-o4uRywj X-Proofpoint-GUID: kWlFgyau5h5KGjymVy7G4gG1-o4uRywj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfX7TkbkgRoNZ2C H4JYqj83mRQOi0BxvJCTqkUgSKuDYx0z5WArQdcV646mE8gdm+Ef4iDrRgupFfURikFrOplv30h +eBtQ4IKGge/MhJLQZ0yb5vm0z5dHf+5NsDM1+rmb3FI3mIerIuZonRiJ63Kp51i8tEc8JUlgiI s9/1/trkhsHiWFOCv5xsukKRDp/yfmJoL9b3rnB+NUsBR7HTmRxA9CbZ1RCqDvwUXxSmxYulzMt bNnPq0s4A+1H/xL/C6KipU3omjdk+ZbqTCJWGw4NP1sUq5wAqf7isq0RHW3xO7A3f9OP11iUcbn I0w1yA3k/LS9oBsilFgr+2dMnzxlWgt7KGQV4bA8f8VQH31M4EdQgqsl1XjUJGmI6H3YgHgU5mt dRRCaYkCejHGhp0868dSCQdrraCbfhEKa0qF7DqgMLyeLhK7/jZbJFqXGqYVKC0YHdqeZgE9Ksd UR9xPcHELzEzgEcHb1Q== 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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 Fri Jun 12 12:43:37 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 8FC70389E07; Thu, 14 May 2026 18:01:12 +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=1778781673; cv=none; b=t5McArjBui1FibGL23vOfIBJC35kY9Cx3QfiYyfjqDGpUpAPvRpoytUNusSWLzp2Ly+U3rQ5ejLZCD0B3SjOhnl/HnLkWzEJUFTBY/t/MRxJfgM8mP1EDXNamFxBOho793nN6Ztr5fGpbFpdmgzAyjZjyKpojdcFSs3xCsPP45Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781673; c=relaxed/simple; bh=kDMLUv+qGFXTZff8n7B9SWz1eb0xmrDVNGip6EZGbB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tiwV7iDsr62HC9RvxVyOVjVaD07EOilyUHsDN2xlA1nlOjeWB9YI56ko+nE/c0I8phFn6RAFpOpnfsO4y+2/e8l0YtQD41eYRUwYsO9fUKi8Ai7egKu6M4SOtVFhxKhsZsKZG9AQ1nYixve92KuG+9cvcsfZUbp4vZJxb2RODvU= 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=WBYvJsMy; 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="WBYvJsMy" 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 64E7mXC93186674; Thu, 14 May 2026 18:01:08 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=WBYvJsMyOHwRXbg1DQexBc2VgZy6zChxv eT0KXjn0Qh7wo+YiKDMB1TOwyvg+rGdSLeKjphXGtP93UpYRFo+q1u0n8miA00TE n6fA8UleeP08yBVfz9CyoIwT23eNUoxZ/jG8MR8Hy/1U0R0Wl7WsOCXORvl8cDZX xR3+av+wIeEgxjblV9mHH+pey0sHHIeI+g6+MP5MSZLOgEuoDEjSxB+4Uk3C4xye bOsqZPaoFSh9H/PhOl4u2hCzqOx5QjZMhWMZ2QdTIUk5Ft8X1GlTo0tB/SR2ivw3 TzmZK6wxwEHy83jWK6y5hGa9+lQPFZZLfyBJHgcWRKxJp8Qu8bEuw== 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 4e3nv5nuu7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:07 +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 64EHsUCI009299; Thu, 14 May 2026 18:01:06 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgwjra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:06 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI15xf19661502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:05 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EC5E58045; Thu, 14 May 2026 18:01:05 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7948C58050; Thu, 14 May 2026 18:01:04 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:04 +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 v16 2/7] PCI: Avoid saving config space state if inaccessible Date: Thu, 14 May 2026 11:00:54 -0700 Message-ID: <20260514180059.1553-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-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-Authority-Analysis: v=2.4 cv=cPHQdFeN c=1 sm=1 tr=0 ts=6a060de4 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=1XWaLZrsAAAA:8 a=qS04rNcGil1I7-YeviAA:9 X-Proofpoint-ORIG-GUID: QMf3C7PdemcaBX480hwyCkQwKvLer5D0 X-Proofpoint-GUID: QfCtP6nNE0shYgRYuZNpwYgVRV_tbQha X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfX3O/kgijq806E 6n2q0LrCls8goPT9X7f01rRhVv9diqDbYOjV6DWdzB4+YNxDQC7v0KE/cTjIRDcC6Pw3cB2xA8Y f19w0QD9dcx9jdycJSUacNSY0tEkOLDjZNACXhtNLkFWBs75sSSk3vqUGjyOuqBhnC+nYxMJgXv jedaXo8vX0yMADq1bLp7qqJhPEPfimX3CiHgVc19fHG55jJMeW+oucdVeauUPnl/MidNG08hs7X iR767h0nLACPDGuJ/Ll3zvXneuGGsygZA8//9B8MMWc3JAh8uvbB6ODO5Xf9B+vbDxpUqn04Mmw 2wIUni3s3SfHvelHiafxiwk6ynjLm1CiyqJqbax50cG9IcYOKDzLGtIJz/P5KJiI9N80vncjib+ OlEIq/kEv6vzd1dMMClGbWcaXkqhzqDSHWuYcAcpoFd5uEdJRECRmrTriYv9l/GIvMfSoBfCvjh 2l6pvxsFeYYCpCTu9pg== 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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 Fri Jun 12 12:43:37 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 64C3D396D25; Thu, 14 May 2026 18:01:13 +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=1778781674; cv=none; b=PUpEKHW/sOCa2wYK2uq031C2dt2z2T2GJO5NtM/SVJTRzI+axLolxTxnIUZ7+ZOYXsoXzLv64D+E+f4uh6gghHQp+5NIhCxX5D6Xb8ec9pZC4gkMMBY6V+S0bEOt3WL843qaLOCbZKQDq4OUeIdsInBjiyB9fszoCnHcOU9WXFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781674; c=relaxed/simple; bh=RQ+lhbs/20dpjDWkfLkvzRoH5lgweVzoQtY2ETnzPfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GG6UFQdS85VGRLnIu3llfm9k9ogy8tWoyYLw7UwyRseAsiJqRNIJDBkEif6zuN4ZmvDC8FmEfh0tJhev2xu1fbPZs5Sk5JM7rHFG92tQmIgmf1zUleD131PXn3O5R6lvMllciqC3NZNNOgq66xZRTnuNR9oJB6vw5TB2NI+/0tQ= 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=XfwZf/se; 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="XfwZf/se" 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 64E6hhH72611844; Thu, 14 May 2026 18:01:09 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=XfwZf/seM1Mf9ywuAHWum/PwWUurr0fuu 4+hMnthGTsqftKhywLuIbFBBEDzQqUjn1n7cLyveQxU2eDdHQDi0xjRJJFZrxUw9 nIHnPYAJjxy/xFCmYIjFPRFQwqP6IE+IcObsyJRcPm0Xz7LkUSQYngK4ZNS+k7fm VqeeEqaNUyrnEy9hpeLJ8LUbU2fLThf9JJigCQgc6bGZ0OYG00LySf4rq+nZJ3cy xmPkQjzLyV0TbbaWBHzTY2YdUJyorOEcq2UQknRviWsB+uIzpQoX+tBoP0AdYMOe 9Oz+oZvMZAdF1QHujB01a/JnhAuEfvoNb3EXBEWyKY88o8LAOhg9A== 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 4e3nve5tkq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:09 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64EHsTXa019443; Thu, 14 May 2026 18:01:08 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgwh1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:08 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI16Nu25297430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:07 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D325B58054; Thu, 14 May 2026 18:01:06 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC13058045; Thu, 14 May 2026 18:01:05 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:05 +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 v16 3/7] PCI: Fail FLR when config space is inaccessible Date: Thu, 14 May 2026 11:00:55 -0700 Message-ID: <20260514180059.1553-4-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=Y/XIdBeN c=1 sm=1 tr=0 ts=6a060de5 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=1owyFLT6pZZ0tE0DW5YA:9 X-Proofpoint-GUID: 53k3f6ojS3dfNen6T93vXGAyZMpXPTaF X-Proofpoint-ORIG-GUID: 53k3f6ojS3dfNen6T93vXGAyZMpXPTaF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfX/KQU0Kzx8+/V di65qktpnchYPU1TiKXpBJkIlp9KgDEDPMAsOXpPzUGXdMh257bHz9T/TvCRawdkaERFPTeTDbO 3CTejT13Zg9v+hDUIycj+tnMDj0GDJ9tioIsVzxobOmZVDQjbY18Sj+2hGFisbhBjYLltInJETC cEv+emoExXbtsjAScl8fvAA3YTP0ooPq2IYuluXQE2+asxvQW43VPHN4UfaoGXeH0Rwvovk2e6G XJ0Ksfn5QwlOTnb5uhuDIAuLniVsUp7WDAJbJiJPbq9fyW5GyqxHru7mBsTsL3doUEUdyX+n9Rm HNXR3IEJHTl+upQyxUdQ+tjH035ZynkfykL9xVZMjj+XACyoa1ttKussG6y5s2xAe+FzfMsloUL 854LP9q04m+4olosoxHkZoX0v8hH1TpZa7ZQjKLjOKYZLO3svYo+AazbofN/4Q9RMa92r8PjYar 7HwkJOjya8I6YwhXwgQ== 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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 Fri Jun 12 12:43:37 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 3F38839BFE7; Thu, 14 May 2026 18:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781679; cv=none; b=Ov5i5IIsJN0LPrGg1TtZu024NzMsGG9shP4Cx7sRk2o69duOrx3zZBhHyS9ME+Hv4Izgr5mBB7VfX8Et6buJuPt/A4Hz1HRb06+SgvAfODaZfyjnpsJiw/JGOLanfAAt0SUPSBClD5QrRpVxhbN1sG2N+2ApdQHNMyHW+fUs2ck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781679; c=relaxed/simple; bh=lp5tp8gK/RgUll/Chh8qB16vIXhgsp/YF+gY5cQ9e0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tBNPPJ1YEy0Z1C9ZkAUPsh58xnJgDeqAD3iepA4vq67v+pWuiHDEWFHcIGtmv4hCvFXHhOFyHlZRPCWdQYEntz8Nh4rlWjpwah4PuU24Fo7F9hrH3Tayqg81rypU1rXPlsqFsToxPLXI30hAT2Dg7KcVKyWaNbbFLfuxK0Dh5rY= 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=BReI/p8Y; 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="BReI/p8Y" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64E6gj7R2758961; Thu, 14 May 2026 18:01:10 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=tVF9hkxm9hcMQHeGY I/d7v9gPUhZJNj9+1NI1ZQEJ5o=; b=BReI/p8YKp+R9Mh+Q2RyypIk1TqnZn8YL BDE00H2pk4T1mXi1G9Ya42poXuDK0Cf8jWA0nlGD3PxsXVcmHHIrDUoqlxTuoHv+ nNNEH+uPow/K5uWqTCujq68GpWeh2Fbl7mRf+WMbz8wm9hZAbwnYItXpTr7CUXss w0Zng9eyY50ydCEmlW9YVS3iLN+2EQQ2ALSync1Y19JcKMPbLqc+qh1R+ELjFHE5 nvkiXToqPq7C/YHwnl77rh9F6A6KyK44ma/LfyBA3XHIVRDkAo8gP46c9B06TJS1 sCyFh31je3uFGTOnXAYxNFs1vjaYy8lypH/c2/I4knsxlsR6Qi2VQ== 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 4e3nv6w7ag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:10 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64EHsVAA019461; Thu, 14 May 2026 18:01:09 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgwh1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:09 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI18Sm16515714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:08 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 152315805E; Thu, 14 May 2026 18:01:08 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E67A58050; Thu, 14 May 2026 18:01:07 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:06 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com Subject: [PATCH v16 4/7] s390/pci: Store PCI error information for passthrough devices Date: Thu, 14 May 2026 11:00:56 -0700 Message-ID: <20260514180059.1553-5-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-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: Ve7BB6ZK56bwapvMSliviHmnp0AMUGHF X-Proofpoint-GUID: Ve7BB6ZK56bwapvMSliviHmnp0AMUGHF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfX7mwRybvIS/fN 6NARD2siEbMQEOL1PhzSpYlVf0xElE69v+pTjw9clufc4kzUyCzduWxK3ysw6FZVay7Aym2Gcs1 WnRlQ8pk4x2oy5Qv9P8JXvj/6EbEYKxHe3SXvSN0vM5+AwytLWyLcmFcp4MF9eWKDSRbqa6xQuW mqEMg6yjhSnz6GXdByIWWk9NwMScioIUGjIl/LbM+LjV+fOasyMSOSdeAp3ltkxp8kuFJrCJk/s r8d+6OZMcMkwbCqW21Ao7mhVSCJ2IGNMXP3rQMrChlzB106JZUvgif/L8ylsu4Vr5JhL9I8Mt3Q osIXTNnZFTJaMPENCwye4cS5SYRelVVjT7TClJE4ItAWvO1OosZFeTRjyhLDWq+KuKMx51NYVxV 5MmlumqpwdNbTyEUvl47bfdrKKr88or4WzWdRsmauGoCLomdX8L6WAplfTkj0TTxKuZqOHGA3Md T0OJkf11GaqVOvz3mPg== X-Authority-Analysis: v=2.4 cv=P8UKQCAu c=1 sm=1 tr=0 ts=6a060de6 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p: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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 clxscore=1015 malwarescore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 | 114 +++++++++++++++++-------------- drivers/vfio/pci/vfio_pci_zdev.c | 18 ++++- 4 files changed, 109 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..ad273decb1c2 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,14 @@ 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); char *status_str =3D "success"; struct pci_driver *driver; + bool mediated_recovery; =20 /* * Ensure that the PCI function is not removed concurrently, no driver @@ -194,13 +208,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 +223,23 @@ static pci_ers_result_t zpci_event_attempt_error_reco= very(struct pci_dev *pdev) goto out_unlock; } =20 + mediated_recovery =3D zpci_store_pci_error(pdev, ccdf) =3D=3D 0 ? true : = false; + 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"; + mutex_unlock(&zdev->pending_errs_lock); + 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 +284,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 +342,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 Fri Jun 12 12:43:37 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 3F2F739934C; Thu, 14 May 2026 18:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781679; cv=none; b=rPd9TYNXi9F9emwe49CUPd+k9jxjxxcP+g9VLRwmv3/zd/Zv5ApALYNTwRiEh8KrLKal9QgwWxW0eTX8xADcHv3OK7vvnV7Zjeb6XjTpko9TsLAdW0Pz/Eii+dYVd5f7Q7Kh5YsvuYvF/zC61HZgrc1OvY9+AF1EnGXXD/V63oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781679; c=relaxed/simple; bh=x5Q77cCRyz7/WtoDOsZ3XDBNysRpLWGmgsNhx46XEeI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y0wuP8QSY2yk8PJvejB9b1pCcj9t3rO8nOKbRwcERCxv/JGU2CkKViUnttrePj4FwnfXS2S7tcSL2woKC4GV0FY2A9IfEqClDuQBzYECvY6h1su++EyMyHmUt0yb7NoH1PW5hjCqPFzaDompuRjHJpIC2vaJYWyoBkoQUrS/cO4= 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=AQKMoq3O; 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="AQKMoq3O" 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 64E8D8ZP3775668; Thu, 14 May 2026 18:01:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=kXpcXE7cBeLctIAKg FJsAKfQYASNox2v+wC8hMNR1lI=; b=AQKMoq3Om6dQTYufpXg5HrKpZW6/TC9D2 yOPDF4ghZ9Wi5AY5lW/EEOAaNJeu9j8plp1FexcQD/R4iew0lyQygreQTIw8Uz5p fXmDVYiewH4HzwFY1FtK8/lCtEnR9P5s7a4Heh+RwYUTaj6h3vE3e7KM9d6rfAiz BO2oHFKQvMvTcHbvro3fSQwYa+9+FUtFJ5/5Edw6RJvSj7XTAHGP4qpNKGLLJYhi iQPBYvcJ59jkw4Eer7+pjtrkg2F1rLYqQi1zOOmfUu71CZTuv/JRslFSUaBiwzbG lTfwudXxRPv+lMsHfwwiwBAunVgTrwUzNuGgJqubiJoa/ORTlAICw== 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 4e3nv6w613-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:11 +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 64EHsZ1T028803; Thu, 14 May 2026 18:01:10 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgwjc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:10 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI19QE15729182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:09 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2211F58062; Thu, 14 May 2026 18:01:09 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 414B758050; Thu, 14 May 2026 18:01:08 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:08 +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 v16 5/7] vfio-pci/zdev: Add a device feature for error information Date: Thu, 14 May 2026 11:00:57 -0700 Message-ID: <20260514180059.1553-6-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=KbvidwYD c=1 sm=1 tr=0 ts=6a060de7 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=sIuuyFDGXZ7lsjPJAw8A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfX729Ctx311AX8 7ovyKuzYIjCXDCLnrDty5avtY+aR2C1zi0t9Qnk1tQ8ffxErS7JIJJULCMDOrujtEtErSJZZW48 caT792hOCUkC59rM3JLdEM5fPGa6hEf3zULon3qSCS6++b7A4PgkNahc59Pkk2dz8C+44ayOU3j d27dQaOaV5IZJ9iLTsovXuby0DTi8kkWpfZbgBF1PKJWgRudjfTtuMTnEJsdL9x2uAVkNbunqzQ 97QKwLyNeUromiWeLrthpkTtwUvToAo+YyuP++BTYjdh5ASXxJVfMTQteG3WT/7IXy5qEeyUqvI urryC42Fe0SmfustqpTQsxihhamm+2KXDbQFeH/N/HSLT54S2PL6winJovUHvurayuySS/Mneya sniU0X4iY5Kkdd11MnHunKs7SYZO0OAP5P0/JOAkM+qMe4tF8yV/fZQYU7DSRIjnx067A4m7cf8 hhh/ax5eynMIxUEFIGw== X-Proofpoint-GUID: UmFq9glEqVSkNqW0unwgrh9t4dc_vYoD X-Proofpoint-ORIG-GUID: UmFq9glEqVSkNqW0unwgrh9t4dc_vYoD 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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 ad273decb1c2..ec42b81eff33 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 3f8d093aacf8..f47a49ca67fa 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 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 Fri Jun 12 12:43:37 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 DED4C396D25; Thu, 14 May 2026 18:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781680; cv=none; b=QjmNX6FUlh4xMdlpjAjTd/Riq54nsizDAV7kAUM8UiML4j2xVzUq0qEUxUueoInqK/qSXI1Ia6N8iNG+YSLoqa5NdhHUvPykoKXte4XWpjRy843dfNgH96zl17wfsfopKHfNO4UUO3tO2xaJ5lVyHOdf20bTimAUs/gBjJiwauI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781680; c=relaxed/simple; bh=P42YvZxGI5G2cnEEMsTCKfL+1dhOLbI9ogZtc8OaZ64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RBU3xVRC1fSDqQEDI/vqFMiYq7bmSJJiltl9Y2eV76uRJWkykvQZlr9qD4RtvcuKaZX7Oa0A+QsLj4xAe5tWViKP0dHXQPe9Yz4/zyiKF7yHqLK89Jdk9qVpi6NjKdedJp0KjjB86U9dD8EameqkO+9dhR8WM2YNHPD7IAolkpo= 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=bnmS5GPp; 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="bnmS5GPp" 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 64E6UItk3773722; Thu, 14 May 2026 18:01:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=HZIwTW1oOFUsiUCSp EO91NJ3o0zlBjIUbldT7Oqbc5g=; b=bnmS5GPpj48gD7qA5LRO5HjxAvfFeWMwC 5L7q36+61w1x03wnFyLNiizmQtNJRN9MJFBFFflY3ZqvPTKzpRX0tgrf+0RZgKY+ V9A8V9HCLktUVyD1fg+jEkpR4RyVQecdAE3/ZUbqHU7FSNfm0kan5Y+if9B3F3cZ zdmnK1bLk6sVCKyuQjCS6/quqRs7mwDQUuGR+Rnxt38cFcABBf+Fu5A6dlf7IMGS D3/fOncBWK00oHXEuwmDHF2JxEfyBkefkXJ/TDbeVggahAyV0kZV1VL1PDw46URH WWmBj8aYE+Wrgux/ITzxrbtvqwca7MKEF2XplU6pi/VNx9iDdjbMw== 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 4e3nv6w618-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:12 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64EHsWLV029409; Thu, 14 May 2026 18:01:11 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfh5kfk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:11 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI1AKg16843386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:10 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FE845805E; Thu, 14 May 2026 18:01:10 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 575E258056; Thu, 14 May 2026 18:01:09 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:09 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Julian Ruess Subject: [PATCH v16 6/7] vfio/pci: Add a reset_done callback for vfio-pci driver Date: Thu, 14 May 2026 11:00:58 -0700 Message-ID: <20260514180059.1553-7-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=KbvidwYD c=1 sm=1 tr=0 ts=6a060de8 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=r1p2_3pzAAAA:8 a=hcTHx3Z5Akp3fEzgVBYA:9 a=r_pkcD-q9-ctt7trBg_g:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfX6ESYWfb7qsx8 fH47Blhj3phIu5hR6HtgxOLUKYbA5nsqELF2J4vb8qLWhJZ3VAmkh9UuMnRUBz3GFU1m37Vx1aD 1/CWI6RYu6cPMnwN93qiVozf9iZaVj1NR62AbbbvjvY4WgiozlmKigik3vA9L4x9s47+oBRXgpR wWP5+VORCyC0q3bTS67tty4zkUqi/ksqr5AuE4Ng7nTUFj/bY0vjyYxWkedAJjI5Wv/v5HaHkrR 9kGqhSUr5sky4H4dY6hLk8ftxVtSvo2eNpmJRJkRN/tSWnvJ9ca7nMUhRvQZVPGXxktreu4dXc3 WgdV9CCOxbYefP6NSDL2PA05oQSbKArbp8HLV5WeOL9f0/IjUZWFVh93xjfGp3aPt/CldUPTjb3 iplOBaZrMXpUc16n03jKlcLOlnaPOsZYY7jh/T14V1Soz6fHqgkzFkIYAuLPf3WYSkdX2mLpQ91 4u5it5Ofe5xNNkUdabw== X-Proofpoint-GUID: 1hdz0MKJ_M7M0ZZyjcGqEQrDpUl6uLFz X-Proofpoint-ORIG-GUID: 1hdz0MKJ_M7M0ZZyjcGqEQrDpUl6uLFz 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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 f47a49ca67fa..6358b59fab2b 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 Fri Jun 12 12:43:37 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 119A03988E4; Thu, 14 May 2026 18:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781688; cv=none; b=oZA8grESz6CpGuR625fAXL7KpWj8VI0dpBB1tBhd1DdCqWMB9MExD712sauuMNKbPT8v4XbTUfvcvd26XqMqatk3CIrGtqi7YEcuw7/Jtvgy9qXi0yGvlxg/GA0jVNs2NRfArgljw6At+TIfoanOr7RjZjuWhGMiSb5G9tDTQxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781688; c=relaxed/simple; bh=3TYFc6itqVc3zvA3ORsy9QJMk5peLve+M+b/RlDFXR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rKYBvxpdy+zNmDxRDQ2uy2XO7HS43kWcDPzALBLto+1UJebMGnfazHcWwmQIXewv8psylOHZ2BVW70l3JbDt+fNB5kWmPKVfbhmsnTYdgzEpx2cciKo2E75K7nf8nchjKQPRm2BaxMYi68zgqEsSJEpiyxGfnWqxlcRwB0oU99A= 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=YS0alzfL; 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="YS0alzfL" 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 64E82KxV3178345; Thu, 14 May 2026 18:01: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=2t4MJ6w9XSNqCnRGI TK3LALBDAsPD/NV/iok/YHO6WA=; b=YS0alzfLFiOoKdbArEWN62QC6Klb/UpVa CysNHtZsTitkZAN2tLwChiUCMfb46vn9pud3RtkCJhmqZGpgO8dmQwfj/t07cipt /XhKqSyxDxmULLC2Yyl9VWFOBvj1E0jZlG+n21wO7tA2MKNV9ySw9k2PNsoylHQq jXdQweVPCbS/GD45YrXbs0SMDclxVBU39rt6Vbo6c62PcxWcaV4Zkkcw/QtGEfm+ Ts6K+PnQ9ZYsUEWjN8ZZwRJODN2nNaXJqrJxiaOPREIDBcN6+lZqoEA3wPf1+okj yH4dk6KdiMaD2sFyOytyuHz65TPg++AmEnZOdn4wtJFwYW+LT7K0w== 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 4e3nv6w60t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:13 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64EHsVAB019461; Thu, 14 May 2026 18:01:13 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgwh1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 18:01:13 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EI1BBP22151912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 18:01:12 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BDDC58054; Thu, 14 May 2026 18:01:11 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DF4758045; Thu, 14 May 2026 18:01:10 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.254.43]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 18:01:10 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Julian Ruess Subject: [PATCH v16 7/7] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Date: Thu, 14 May 2026 11:00:59 -0700 Message-ID: <20260514180059.1553-8-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260514180059.1553-1-alifm@linux.ibm.com> References: <20260514180059.1553-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=Us1T8ewB c=1 sm=1 tr=0 ts=6a060de9 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==: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-GUID: nyEJLopEp_Jwbo1yUwayZDoROe-6xWV3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE3NiBTYWx0ZWRfXzBscWbGvk/zO skXbplEBIZnZRbDrHJryqd/PtIuo/5IiI5PiBffcvE7unSb1+F+TGERLojbLKRyDstPAE9WJ0Us pU4lQtJWPD4rExBPfFIl6Lg4+757+HR8xq76APPIsMHMTDmmuh7UPG2rEq0uoI6HB6dNwrSiIcj W1gNpx8wObNL0SvKJ9Npem41HEBPy9h6NuNvSsaxhXavvovywsRdnZJYb2ffS8FdUQDk6apfXlw 0ZGaaCN0f+49gut5YQITDIdHqgJoVQc12iNW2tw9+xm3eOrK33cdzABfXXfw1liCN35bUAcfOo/ q8hky1+9GYBDBY/37PCRVY6hXyLEYims5qkh1osfeEtiZXoe0eATT7laTlTPai8mQwP2c03mr7Z e34cYUlss9CGi3rtiwABdcdQAXnBMGbS7LYxsusNNG+AJ9nfyKuHqAGxk6gQfnTJofiaNbw6EKt +Rm/3OkCIvEw8tmXaiA== X-Proofpoint-ORIG-GUID: nyEJLopEp_Jwbo1yUwayZDoROe-6xWV3 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-14_04,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140176 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 6358b59fab2b..cd9f31b28160 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