From nobody Sat Jun 13 19:02:05 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 969853D6CB2; Tue, 5 May 2026 20:05:19 +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=1778011521; cv=none; b=mZYEGd58sS8yNrUUVydMic1bIaU0bCb5JZEMHltgkDnZmxSoOwTjRQmXZp606H0a0Ouqf6YgGfaDR+jeXxgBTkYcgT2XNCwa3lmPZ9oSKlPo9yX1GsfKUj0gEWNkV6adGemUHkta3i07WrPyC80X4K4XEe+1wd8SFaWG5Ua5wkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011521; c=relaxed/simple; bh=0O2tkwQnRY2NgTfcng5FhRNS7XbWmh46GDptlDcRPm4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZTFCIg9AumMWnoS2oRB9kx+wP1zrIpw74U7aTAJvUATsWC9S+PYaBP4KySvjJrU1cDlQ5h1k0avNGf9+eNv7vnPDEMwmbZpFxqnTHpIRo2d2k8xUu88zsUCkxn+ou7wYkLPOX+bHyJGH/fqGwxm6dPGWd617GNJJNYZCPgYqR84= 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=bCm5IyuY; 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="bCm5IyuY" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 645IxNTX2692843; Tue, 5 May 2026 20:05: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=2g2+8cwzfC472wSkG K/bPeX8sWH0JpNCZ8A2YKaMGcQ=; b=bCm5IyuYgjZTvFdIMiKcupetvhG9nbQrk kopiLD29ZsIqx3780jvUbQNjRLq62hxL7107xw4SLd2g2LCvs/OAjoQeP6Pj6sLl HKRYZnywH2NCntbzz9JmYd3OwlmTnxOcgl8So1NnBLYkcpLHGgq7oygWrB/mX1xR C/x9GKGjDN00hxz/ITnxqVtT/csID1W08L0NzfVGt9T9oHq5rgKpfYcOXLhMoHz2 RW7tRPmTDjKE+UXYtP18s5L7bSN5W9XmHO6aHiwklMOPXLrc5TLO+wCblOxhVDWe GSANYJ4yux28Q4Ktf0H7hdatwIiW9D56unbKk+2QZsdihVBRmJJNg== 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 4dw9x4ngy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:14 +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 645JsUQc014212; Tue, 5 May 2026 20:05:14 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwwtgb3a5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:14 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5C1P27198046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:12 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2365D58055; Tue, 5 May 2026 20:05:12 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67E6358043; Tue, 5 May 2026 20:05:11 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05: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, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, stable@vger.kernel.org Subject: [PATCH v15 1/7] PCI: Allow per function PCI slots to fix slot reset on s390 Date: Tue, 5 May 2026 13:05:04 -0700 Message-ID: <20260505200510.2954-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-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: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfX9vcBQyBKbgaD 9mJxWkO7AyG8tlp39XHpD+l4oJhXS6n/UaCUO91KK5fOF8vsPjINTqaPy1mcAeSF+moWkfWXZlF 5X4FW3arV80Oo0gMVlXhHvzhJdSJAwtiSm30yitLOFE5P234hvWFZhtrkwCOyjLGla0RDSFHZIt 6ZQdICk3LOh9jPEc8c2vs1SytXdwnIvxlTSnm2dNA8oq02HTTYuRmFj4uCpICT1yJCugImpdFw3 TUtBTUZA41iwFYbZr/qCb3nmapTQq97cSdXRwUV3QzGJkxmTgm3fdjq4UFGHxKlMC7SlX/zvCqt ebHb7gWbeUJoIDLP5mD8cYJdHc2cN1PfvwcUWJaF7agR3VqDI+WiZO43+iEKdwX7FnUg4SGIhkF LEuZayQvvugyZZNn3cgE98S+3zCHra1CT1gHqvd81BXscAyBAjR8N2Tq+WYgJIbS69eY4oQjdB2 ri/kbbgxtFwmyIbV3EQ== X-Proofpoint-ORIG-GUID: WvUca-KbaYvziepamqTsU66LvJ82-Sgb X-Proofpoint-GUID: WvUca-KbaYvziepamqTsU66LvJ82-Sgb X-Authority-Analysis: v=2.4 cv=W7UIkxWk c=1 sm=1 tr=0 ts=69fa4d7a cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY: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-05-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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 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 Sat Jun 13 19:02:05 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 E68373D16E8; Tue, 5 May 2026 20:05:19 +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=1778011521; cv=none; b=bzzPBtwN04PAIiyP5+Ll1gJt+2Jquehh9vxDSx2qvzgKgvPX+ZrCvL1yTLFpTFCnkVAZW2B+vjxcIB1rq8BRCseQUm9ajqcZFP4uBDxtSQoYIpfF5larwGRBTxK2VYVHBCarPWm7r9cX46b8XYyhOTFmni5PBQMQlUpI1qf/ITo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011521; c=relaxed/simple; bh=POORsXRkk4nOKnrZRpviXSsULTny9Rnzj8bxogy/6pk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ohC2ExqeuFpA2X4CmWCQllO5K4PyWIdOatOujHs8M4JcBDA4x2sKq0djr296BxifkkuIdW7rjHWI9+DgrCV/FkOOL+IKkz7UmFTM/e+Kqv3uhFzaA+hdELkVrmOkggrafx8a0XaKkULO5BgJK0h32am2NNN6JvbsZ0NMo+OQqKc= 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=RDRytMSA; 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="RDRytMSA" 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 645JZ2sl2503246; Tue, 5 May 2026 20:05:16 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=RDRytMSADtZzrrCs+czNYBnEwOCh5/izY sK9l21+5xyfambjShaP4sPfmzAhO2tStR9xM30nhu1ZM3RfyugKDukrGZt2X+vuS DGTXmBhtSQKTSICGKLbIoDokdn570AHOu4zcEPVHh2n/VUKbAf/449EIha9j8pS8 +St1FBWYQI48PqjVYcg7vlMhfxSLGU8kZ3PpZEjikA9DaJvj1LpQvRBRZ7z2rA0N 81kqG2w+mW1XM6kHBe+sk+1D7h258TriDPnVxbX9TYl9MzJ06qtjygeKGAUKVq/v 3jalBsj/Rl3B7/OsuSgRnbNQPyiT50oTouTOnBpvzc07tY37lgq9Q== 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 4dw9y1djc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:15 +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 645JsQHC014200; Tue, 5 May 2026 20:05:14 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwwtgb3a7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:14 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5D7Y6095480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:13 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F264D58055; Tue, 5 May 2026 20:05:12 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 412D358043; Tue, 5 May 2026 20:05:12 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05:12 +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 v15 2/7] PCI: Avoid saving config space state if inaccessible Date: Tue, 5 May 2026 13:05:05 -0700 Message-ID: <20260505200510.2954-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-1-alifm@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-ORIG-GUID: OlQFPTi-dFiVRUYeV-TvfQmb6J1Zuig4 X-Proofpoint-GUID: 0xxM-q5CxHDTfDTNwc7tIXdg-KpWYxSO X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfX52DbAk3jKuaB PhpgAZYe2FxCjNkOfOSIygzYP2L4UbgZMLFWGD+NxYKCbzIk3nI7LtPrkBxSGO41VzCIIT42CSO yP2mTMpdpmdbmfa/W3Y5vU2YWkpjT/SEutXlpvuGBK+lYZ5+GGM+gKpOr6zIh2A5Ygm3sLtpYKt QLvS5dV+ofglw0+54Hc47Yyu1qMJ0a6/KYebpiLuZs233KU0JuBoE4D+1KY/fm/Wl9k1cWft0i2 DvEYiV9dBijmM5TQFAidqMAZkDs50Y2xy7vTaTwLSiwsBVzXzVD0FGiK3jp3oxaeEM1vO4qtqVf /Wn5sKtGTWKeHnK1lI/9UMXT2qdUHkQnVXX8lnBGvEzVEtt5mH8il5cjTQCV0dhnJeKs1QliDlG XS/ahPHPi7ijpT3BHPXQcI8fjQdLtWsfr4PVNQ+NaAZXtnZLMucp7yw/69XMxqehXydVK3ycSCz izbmcb0t9JlIdIRZQWg== X-Authority-Analysis: v=2.4 cv=UbFhjqSN c=1 sm=1 tr=0 ts=69fa4d7b cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=1XWaLZrsAAAA:8 a=qS04rNcGil1I7-YeviAA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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 Sat Jun 13 19:02:05 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 841B4191F98; Tue, 5 May 2026 20:05: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=1778011521; cv=none; b=UIaWYIl38HRcu3fRjclr1JYA9274+kHQ0pVhK/kTwcnpEoAfEohEZZR0OyToJQxW8AxSAcz2qM2gTUZyXcLskVdtETH3NptONvi4yCBbeQiVvZ53sN53ZLQY+VzKna1xVynJvnUTDscni65qY44bEvqEwc+Bu/uHGRgzYETn/QA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011521; c=relaxed/simple; bh=/A4i7jVvjy73WaQOU6JOmUh4l/ODHy9wJnwVOUgyG1k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eufX14NvMk8EvTYEjPrXzAU05/a77dMvHeaj3gyySssPqYBgQhPmWXBM2YwMSqJAgdtITCmaoQX1j9tRTuBOkFUIL7ezlA8/RNHBfEZ4KHOiNksWzJo8R5GO6DXcm3v+xmfUQ6So6abfecW5g0vZ+YL0g306mwH20e+EGF5wWdw= 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=BPut1Hq7; 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="BPut1Hq7" 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 645IPlTF3285137; Tue, 5 May 2026 20:05:16 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=BPut1Hq7jZfz2M0jvDpbpZ2AX1mu3CRgO oo/6TgoobGMxCrUpjVWIamDM5PsfkmL6blj/Xh0n9DVdbkJ/ZdkHWuf+XBbnvWUu gJCE/cOe2L8rm+rLupu08hS7dYKfgTD7Pm/0pu5ta10TcocMFiJk0F6s/chtkPEn Ly4Sxf43kOEhHyP7MDiavZcWyPo1dHZoNxU6L1875GpapUICjv+NVqQreZDJJast SkK/oLdUAgUmDsDQKwikutrbxHIvWAiD7efhn6VRRIW8KXyCfRLbVma9JVJq5t9Y 4qE2VWTKObSAY0wu9KULZM2e8HhcHKyY+HvKZC/ssUREdAyXEzodg== 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 4dw9xxn3a5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05: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.7/8.18.1.7) with ESMTP id 645JsVZ6013088; Tue, 5 May 2026 20:05:15 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyw3bmq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5DvL22020742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:14 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D75FA58060; Tue, 5 May 2026 20:05:13 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E8445805E; Tue, 5 May 2026 20:05:13 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05: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, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Benjamin Block Subject: [PATCH v15 3/7] PCI: Fail FLR when config space is inaccessible Date: Tue, 5 May 2026 13:05:06 -0700 Message-ID: <20260505200510.2954-4-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-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: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfX3yzu4eLW6z1b 26U+V5XHOZ79cp6hfGz+j+RhU6BaER9xUo+gevrSGV+B9Bg5uPraSjSfbPtt5G91u7NkYXTlSDm XeHgmY+Aw9sPtjwsKcWXQE60+YGByFOeTfGhehitzIz/3PzVGWLpSuNh/ENdrfXda8tNZQKiHpE 9cb+TlFq/pph0UN9nrAVy82TALhp76coGYsX9I2rPwCWs5dLNsdQGHkRmAgRRRePSJSFdaNGiVG slaIICQE7ERKrk5Piw5nTNQ77nZh1LfVSdb8rwTD9dCENU54SbZuhPkOxzNOS56w9EM4/xaxvD3 +5SkxQgOSoaYLnGt+cNlkEaLY1ftGhEef4WTe5wWxlZGVkUWTWZivsD9xlQs22gRuymDJ2/6EHd o87736BuACVkloo1BBhvXpbnqb62jSNm9iKMRv6yfBXw60IPLq9EYMcqET5ucxWayIZklDLrtL5 7a7T+5f/1/kHfWQGddA== X-Proofpoint-ORIG-GUID: NmbIbEEMgXt0UjmoIoeKxqXhpnQ-IRdz X-Proofpoint-GUID: NmbIbEEMgXt0UjmoIoeKxqXhpnQ-IRdz X-Authority-Analysis: v=2.4 cv=ctWrVV4i c=1 sm=1 tr=0 ts=69fa4d7b 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=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-05-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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 Sat Jun 13 19:02:05 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 060843DC4C0; Tue, 5 May 2026 20:05:21 +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=1778011524; cv=none; b=MZiEsIGwm4FJR9Lu0sxocpfWxhrRXAbD6/PHWNNLG6Mm2NxNlGOih66DmAwYvLz7xIrA19I0V5fwaWgrA3tjiFBONtE5M612PqsjhbRO6IpQ16a6FRvwQvcrCKtdb87sSbGS+18TcGlJOl/ZJEp8u9oLas4Wfk59bUce2TTrUXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011524; c=relaxed/simple; bh=IvQxud+RooMcKnqQtBgOaXEbS2IgbPoA6y5YIyibfJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XDIq3UVeuJzndJUrOReS57zAl7HWprux2YjpZMtQadenZFJoG1D3SZDoz+1iovP/rcK4iijKnQtT/WFJhVU30as6B6mh9px63c+ZyC5GNeDXJXcR4WNwVo/mpntk8isZAp70vHc1d2I2iAZDVV1MZAah7057t70+kePqxYTdTkc= 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=T5jSc55k; 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="T5jSc55k" 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 645CSNSA1362084; Tue, 5 May 2026 20:05: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=IuhPl+zjWAsAyvPUD ZyzHYIWBFnJxKpWyqsj8FrEgyY=; b=T5jSc55kdIaSmfBKqLvwVS7Zau4PSenAd 0R8f9MDNJbF+86vKdUNiMgQLiBMhmyR5QzKPJZF+xcqyZlBNHYf+cYAkk89YQ+6N T2mFh06ur3JB7/EM/X/2rclo34Rqi834Oxj2kr/UYGGJiGKoLhmb+D7XICFnOTOG v8gLmrCEvN2VxZ9Kj7g3Vmcwgtdc7jEuwavEmtg59Y/DJuN/mPLzU4EUFknW5I1+ dXgFzyS37borPM/ikm9kL9yw2KTPGS/hKS4wZ+OFmKm6ii5rokGoE5tYHHEboa2Y T0kEr0gUwDlIOuXEuF6d8xV2qd9+Q9atn34T8T9eSgYNT3gz6zyaQ== 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 4dw9v7dkv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05: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.7/8.18.1.7) with ESMTP id 645JsSJ4019163; Tue, 5 May 2026 20:05:16 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwvkju83t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5EBG20316908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:15 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A76A85805E; Tue, 5 May 2026 20:05:14 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 024FD58059; Tue, 5 May 2026 20:05:14 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05: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, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com Subject: [PATCH v15 4/7] s390/pci: Store PCI error information for passthrough devices Date: Tue, 5 May 2026 13:05:07 -0700 Message-ID: <20260505200510.2954-5-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-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: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfX1082iAw4Ikpv UupuKE+OrTs4wG+YFuqY1357/pdAoNGU/+BTcR3T22pEu906EcoyKUE+jYbX6HWsyVnETHpcGHf +RiFV9WPHpJjGYxNzgvkgUCDl9dGRlET/1w3OwUuwYy1v/VXHEcIsMIChQtfXnd7JC3/78hYu8a Eij9sIf2ZT969r4y8YCKklidbj9yk449CTMKOiWSqTM5IwNQ9zRz+XlsrtslEZgquOFDelvD5g3 EmJGCKEQKlSO/rkLE0C/QQPY7DE60Hz3bW0RgVqjkyQoM6pk6XxxdpD1WHpIaOXkSsd9wUcG/nc yUotpC387KCMl5HacEwDP0jtubNfJ4yA0Dsx7ICc+KB8/vARh+INlOuliv82Ci25fU0p6E5G4de ZrZfTDcvKNlBjq2W9unnSRc0wyUo8U7FNryRrvq5Wv3OKXvXn1UKO+04Z8gwKQWUjyAKu7o4R8M 1/h4P1EJ+WaQigOLpSg== X-Proofpoint-GUID: r-AG62rpBkOdQX_7aKmN_0zbcGJCJP3C X-Proofpoint-ORIG-GUID: r-AG62rpBkOdQX_7aKmN_0zbcGJCJP3C X-Authority-Analysis: v=2.4 cv=eu/vCIpX c=1 sm=1 tr=0 ts=69fa4d7d 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=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-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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..41547c54076f 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,46 @@ 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) +{ + 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", + 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,7 +186,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 +206,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 +221,25 @@ 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 + mutex_lock(&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"; + mutex_unlock(&zdev->pending_errs_lock); + goto out_unlock; + } + mutex_unlock(&zdev->pending_errs_lock); + 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 Sat Jun 13 19:02:05 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 54F6D3E0C75; Tue, 5 May 2026 20:05: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=1778011524; cv=none; b=YHcukLhHPJa0C4nUlKMXvrmnogJAzmvQWBdZQ8DGgRpoYvUlZn6LVCoJAkU0flH/54TGd+rmI0FuQVsZzJOEqt+tOS1OB0gmaXW/88Yo9iqSZ8aF/HKp7MTrrnEgeJiTEb2mKKiyfhwkyZlCtEkMuWTP+N00KV7laKzEr63PC4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011524; c=relaxed/simple; bh=BL9FMxnGl33QuTt5YFYpbnn7Rr2x+kReKrXbRoHkcYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=REtD5ZiVb+wjR2+RNZ42Cld96BOJpe49JSz8v87y39BiTWvmCNEvt9WwdO4WJ5p6olovAdStVdyOUv8iwP7FEoGePhD8iPhTwk7cELpuEqIisAOHhraTwVuN4q+DbCTk7QXNwpETyQ5FnwiEeNtJKUXHB0BFimgQZMg/PspcdeA= 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=DsqoyVxq; 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="DsqoyVxq" 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 645FxsBs2332110; Tue, 5 May 2026 20:05: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=2bqNBrtHblvQvHRvs O2Rf6t0b4r7qIAp8yqsVtIqnmg=; b=DsqoyVxqdidhTCT0eZhGGwb2HPrMmfKg/ kpxo4tCjG9Xv1DJUruc9JtBeHc+18pUhywx8sW/TXZaW5kHtolldFiYNdqFO88IP GOo+xL4RTM6Obm87FBzSkRGjMF2oqtM8GWeNJyJoQgolxXeyS6zex98Md4ZCnLkF kKLH+ZRja0hbwupMf5YFvNXgb0PwdYIrT6c+IXcRQPto6dBWMBCNI6aOmL2ZqTTF Zsap8C9b0qlB5NSM03bVS7Daufi2o0cuuIYg+xrtCP9jpwYNjmwT5qbDblr5wxrm eYd4HyX0NIHlNIbbCrVvQrxbl/uImW6y5JYFPCBmbqJQqqx1v3yLQ== 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 4dw9xxn3a9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:17 +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 645JsYS3014234; Tue, 5 May 2026 20:05:16 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwwtgb3ag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5F6t31916758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:15 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78FBD5805F; Tue, 5 May 2026 20:05:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6DDE58059; Tue, 5 May 2026 20:05:14 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05: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, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com Subject: [PATCH v15 5/7] vfio-pci/zdev: Add a device feature for error information Date: Tue, 5 May 2026 13:05:08 -0700 Message-ID: <20260505200510.2954-6-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-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: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfXy6MGrgL6aVgy elNtHdjdQIOcZ8MAR1yi/xs3kIY79j03y2Vh2xln4qlc/PwubrSuJa4vcu/PW6LoCWi3kYkx6FL kEzTRMPL4/UtT+fAf2BAqRSu/DegPb1Vkavyo+bZYgi9rPQ45GK68Ui6tGoNSoNCOdlaYBxGbZH +r1mD9cNI3ee2I0OQ+d3BNZoZCyIPMRz/iuKtcKYhAVe7fk/L4pBYvgxZWwisuEQjzKkmoJRHND I6wH+GygwrsJ7ahFaLHxohoYFHlJqJpHZ0uC+1nKmCboW/oqL9tLyNzsspSH9ZQat3kAqEwHFc8 H0I0A6srb6D8rHv+UNGCy/LqzA6qHdHcL0HNLeQ8cjtExBd/wUkakVaHNwyWLCQABb8n69l77Cw CUUdbJp5vqREsTqB8kqA48cemL9ORhWWiA9YYDOQFJsjMaJxQEIk4tcK2zjxlowgzM9VergeaME dWv//yu6fclE1zzxEqg== X-Proofpoint-ORIG-GUID: g4KEZw4hdH-DxxojVQJuqRlCjIW6KKgH X-Proofpoint-GUID: g4KEZw4hdH-DxxojVQJuqRlCjIW6KKgH X-Authority-Analysis: v=2.4 cv=ctWrVV4i c=1 sm=1 tr=0 ts=69fa4d7d 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-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-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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 41547c54076f..fc4b51bc4c3c 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 +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 Sat Jun 13 19:02:05 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 72BC23E3C4A; Tue, 5 May 2026 20:05:22 +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=1778011525; cv=none; b=L9V/z1ZPVJebQYbqEZow/5V7XIbCmiYk+MYIkiNNyF/zt/lUMtqksyqnNhodst5ctyeFv283LkGgQtTHeTJBAGiRrvRhKsU6G5ZzBTqgLA75ATWeJrL1q7cTX8KJob97XAhY9wJdbSMi5140IKnK+D/IKAIGLT3nUWzhCVzL2Hk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011525; c=relaxed/simple; bh=P42YvZxGI5G2cnEEMsTCKfL+1dhOLbI9ogZtc8OaZ64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LJXYpdVR7mt49YQ2BcUDEVKVQWNLaHReCOuAhvoKNSW23LhO+utLES3gl+0D8UwzlkmmnETnmxT2m1kY3fMaIjpi+V7BswAgO3mZ/bsssMfweFIDmPkGKb199pRCZYB9v1+aOsbBgezBB7t0mk7jZDxqXKNgkJqXwqFRBqXzPzY= 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=s+K+Mxcc; 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="s+K+Mxcc" 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 645DdqgS2469637; Tue, 5 May 2026 20:05: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=HZIwTW1oOFUsiUCSp EO91NJ3o0zlBjIUbldT7Oqbc5g=; b=s+K+Mxcc3fY4Tvkd0t6IUqTEpR9tfCHbE GsjFOroXF7Q6LtXkfGDt0p+VKExNwlItZ0tnQ6K6e1voeXuKwsbwtmdOWTR5XxSB MXOA3VwLLzWn8gVjChScOOmivCP60ziuYdwa6mZU1uHaYYZ8JeiWbuvOc0toezAT ibBJwAlLU4T2S1SvHd0KZtSAUwoiaGTCq0tlkAqrBhjaJL48nP60q+AUIS0DF2n/ irXEbqunKYzZgDxpf6cIQ16J1rIPa1zTrU4SPq4R3+dr6GZOIylQLP6nh4CzOZvL ZMu6wKuoXfBzwKmTjr3KaRsTvY2f8AddlnpFbs2o1UKLL5pe4W0dA== 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 4dw9xxn3ac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:18 +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 645JsgWv013147; Tue, 5 May 2026 20:05:17 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyw3bmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:17 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5GN13998346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:16 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51C3D5805D; Tue, 5 May 2026 20:05:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9872658060; Tue, 5 May 2026 20:05:15 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05:15 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Julian Ruess Subject: [PATCH v15 6/7] vfio/pci: Add a reset_done callback for vfio-pci driver Date: Tue, 5 May 2026 13:05:09 -0700 Message-ID: <20260505200510.2954-7-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-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: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfX3mX120J6Q3xL Dfi5+s+Jzk12KZNfHRaNu9UO4ybgZDQKtiZSX3ghDeiUOL3a7fneCO8Xy4mTmbQrt5nfydlg9jm LzMwam5y8xwPjEt7OBtxxW254e+y3wxUYusoQSX5C4S7W//RPiDl9wYeCfR0KCTvzbfJHXt3OCF 6YQ3NCYjLDv2GgdhJigET8T0owE5JDZkPYFUoDqX2yA+hvYXK3Nqq6X+HvT/QnSNG85caskQilg GDV4QfemHX+YswlGnPZAcSSegO1ZNq0JPm5Bszdyt33hdGEJ+cDmYpT8jMYTPORqiZmqy95AuMB NoWnbE0WZ8Gmp378kkADu3v39X0eN50wYCogfrmXrp5xUiSiKMqB5i3ar0StfeNdzUVemh7x95L ZvDy0r4VSpZLhoDhBhTqg/AXcJqSCcTWausUrvNHcoP9lnPik7ROSRPq/dCyWMrlwgzshdEmXIP WYHCvABTYtq7loXybMQ== X-Proofpoint-ORIG-GUID: mXvRgWpr4PJ_MctRSkRuhMhCef3wRSFk X-Proofpoint-GUID: mXvRgWpr4PJ_MctRSkRuhMhCef3wRSFk X-Authority-Analysis: v=2.4 cv=ctWrVV4i c=1 sm=1 tr=0 ts=69fa4d7e 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-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-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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 Sat Jun 13 19:02:05 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 F10094968F7; Tue, 5 May 2026 20:05:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011524; cv=none; b=fMFYjNvY8pdfp4SMWI7Otk/8w/lv5Raopp1XdoTapHP77V8BzgnaGECryS5mZOH9qkKzx8MJc0JjzPOPPtH9pvpCrJU4yMh6Zwn3cfbOwy7l02teSEhS0gnh/leN5tE6PWsqnN15DzmWddGQ4guYr8q1aBz5YygZcEkq+r9p3/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011524; c=relaxed/simple; bh=3TYFc6itqVc3zvA3ORsy9QJMk5peLve+M+b/RlDFXR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LixYqwHf5ObtKwnUVATKIf5GvI14RWrzfsYIltNTAeJokw6JU4WnkKlTbLBTSc02h2hiWyx2vF9v+XDJe2c6G4iFzzEv+xyRRW6QZed/jlfqSb94HNAgty10akdyAB8aDy7tLnJe7isDZ/V8XbYBy9djtv6kJqPDKxl0wmL3wh8= 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=YpFLIFHZ; 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="YpFLIFHZ" 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 645Ik4Og3003512; Tue, 5 May 2026 20:05:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=2t4MJ6w9XSNqCnRGI TK3LALBDAsPD/NV/iok/YHO6WA=; b=YpFLIFHZiNsU/NAM4KuGa2tiF2Sl1LV7x goDtHNWUS9QahSwr5wXD1BLLobyw6dNVB5fV6Z3fNNxAxi1YrQcn9Mt99lBMXXAJ kXvjiQW8WyKqeL38mb75IOblXA0kc1wvZ3OTaH5TcvA5D+qu2LXYicriDrsHxZg2 bNRPB2qpYpK5/xwMocwohoXfywk6vllpZ0e0l6OmnybFmk32l0QgwwJsuu/yfIKe E5fbk3lNhnF8OI0GoElV0sV4WsYQS2MyiA2jz9rL9fm9CcWklhSosKJlRC/qylyA 2wL8WmArutenpkLtsnbuFiqKInmzJT+ZeK2LFPykmL54m2kP8lOvA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9v7dkv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:18 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 645JsW1Q031825; Tue, 5 May 2026 20:05:18 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwx9yb0bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2026 20:05:18 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 645K5HBl27788004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2026 20:05:17 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CC5158055; Tue, 5 May 2026 20:05:17 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F30758043; Tue, 5 May 2026 20:05:16 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.242.219]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 May 2026 20:05:16 +0000 (GMT) From: Farhan Ali To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: helgaas@kernel.org, alex@shazbot.org, alifm@linux.ibm.com, schnelle@linux.ibm.com, mjrosato@linux.ibm.com, Julian Ruess Subject: [PATCH v15 7/7] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Date: Tue, 5 May 2026 13:05:10 -0700 Message-ID: <20260505200510.2954-8-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260505200510.2954-1-alifm@linux.ibm.com> References: <20260505200510.2954-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: AW1haW4tMjYwNTA1MDE5MSBTYWx0ZWRfX2XRQLX0TPHU8 mQCFEFqhBgeVqkMGFjMXi+lt3xo9JZ3gjEuhBQyObqH+jQ2R+D7Ta/QVJc54cOY87MdX6aWFqVH jhNrsGmQuGkgpOhQA1OfpekDC0QhnHXRyiRoS755MkpsHjxSsfbrhj07BzFJvKWvZUNhEGOdBG/ 8K/HBcThaReiqinalowRWXSMSKPOwMLZSjKFXwbjclKesupYHwvHHMdNHo+VEts2hGL6lym06lu U9UDDUa2VBeD5q9X6zOGg/LBxdtxO9n0KrURiodsAazNeLGUK0pLbloFy8n4/GIVFNHlEbVf/+i zt+UYD9zXMsBhxr8f3dR65tR7PwFy3ZQoKp7xC/rssewE5gRGZRgZ49UWlt9uL+s3TBttccRxxo 1KPQIPTsQXvkqXxknm2pFGYs5EDn9UsiZdq6r7Guv5nWxt6DNnGFb4BHifcquQw5wFqmaimYWWy 892AKGpEMi/AF0UCr4Q== X-Proofpoint-GUID: MEF0f7QDnVG_OcqCANNG0VD9zgWmsNrW X-Proofpoint-ORIG-GUID: MEF0f7QDnVG_OcqCANNG0VD9zgWmsNrW X-Authority-Analysis: v=2.4 cv=eu/vCIpX c=1 sm=1 tr=0 ts=69fa4d7f cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA: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-05-05_02,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605050191 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