get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2217833/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2217833,
    "url": "http://patchwork.ozlabs.org/api/patches/2217833/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260330174011.1161-5-alifm@linux.ibm.com/",
    "project": {
        "id": 28,
        "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api",
        "name": "Linux PCI development",
        "link_name": "linux-pci",
        "list_id": "linux-pci.vger.kernel.org",
        "list_email": "linux-pci@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260330174011.1161-5-alifm@linux.ibm.com>",
    "list_archive_url": null,
    "date": "2026-03-30T17:40:08",
    "name": "[v12,4/7] s390/pci: Store PCI error information for passthrough devices",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "99ac8f6809bedd4bdbec11a4cbe0228e933116c3",
    "submitter": {
        "id": 73785,
        "url": "http://patchwork.ozlabs.org/api/people/73785/?format=api",
        "name": "Farhan Ali",
        "email": "alifm@linux.ibm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260330174011.1161-5-alifm@linux.ibm.com/mbox/",
    "series": [
        {
            "id": 498071,
            "url": "http://patchwork.ozlabs.org/api/series/498071/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=498071",
            "date": "2026-03-30T17:40:08",
            "name": "Error recovery for vfio-pci devices on s390x",
            "version": 12,
            "mbox": "http://patchwork.ozlabs.org/series/498071/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2217833/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2217833/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linux-pci+bounces-51484-incoming=patchwork.ozlabs.org@vger.kernel.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linux-pci@vger.kernel.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=MFErmZVt;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org;\n envelope-from=linux-pci+bounces-51484-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)",
            "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com\n header.b=\"MFErmZVt\"",
            "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=148.163.156.1",
            "smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com",
            "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.ibm.com"
        ],
        "Received": [
            "from sin.lore.kernel.org (sin.lore.kernel.org\n [IPv6:2600:3c15:e001:75::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fkz7J26kkz1xrn\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 04:41:00 +1100 (AEDT)",
            "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id 2CB243013186\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 17:40:33 +0000 (UTC)",
            "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id CA82E3DE456;\n\tMon, 30 Mar 2026 17:40:28 +0000 (UTC)",
            "from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E1853DE425;\n\tMon, 30 Mar 2026 17:40:26 +0000 (UTC)",
            "from pps.filterd (m0360083.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 62U98rdD3071713;\n\tMon, 30 Mar 2026 17:40:21 GMT",
            "from ppma23.wdc07v.mail.ibm.com\n (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d66g1r13y-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 30 Mar 2026 17:40:20 +0000 (GMT)",
            "from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1])\n\tby ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 62UF9qj5013936;\n\tMon, 30 Mar 2026 17:40:19 GMT",
            "from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74])\n\tby ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d6ttkdsfu-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tMon, 30 Mar 2026 17:40:19 +0000",
            "from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com\n [10.241.53.103])\n\tby smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 62UHeHmW63046110\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tMon, 30 Mar 2026 17:40:18 GMT",
            "from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id D475658056;\n\tMon, 30 Mar 2026 17:40:17 +0000 (GMT)",
            "from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 127D25805E;\n\tMon, 30 Mar 2026 17:40:17 +0000 (GMT)",
            "from IBM-D32RQW3.ibm.com (unknown [9.61.243.214])\n\tby smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP;\n\tMon, 30 Mar 2026 17:40:16 +0000 (GMT)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774892428; cv=none;\n b=i377d8JTI47LBPmOy/3/9RI32mEMDQeGM39Hn0RO+ohXyyPI6M9mQmfZQJuU/1nb8hTqXocYp2Sw0mSpuoC8MCBmwj9EXBqxlXHoIICOoxUJ3kB9BuyRJ0DZsEUyMC85/FTOhOMS/Lc0qhIfpBq6ylc5R8lUimnAsuFeyU7qMxQ=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774892428; c=relaxed/simple;\n\tbh=fxezx+Q8UlfpH5zb6/5aKiN8qKEgXKAyAoZ0eU2j1eI=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=rOETxF9YhEgQfgurJt/YZEv/2TV4T/uOPtLEWFHvpAbr3iDWQOcOmkd7OfcLQBLujR9i/B0/DnX1tfl1AzqeNoKQqe3Mo32dvbW3nhsWqW2L8fhD7hvayRtsleD8jtsZqp15PxDT1zGBYgWfmulABWxdXMfH9eAb/TDoc2ohtt0=",
        "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com;\n spf=pass smtp.mailfrom=linux.ibm.com;\n dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com\n header.b=MFErmZVt; arc=none smtp.client-ip=148.163.156.1",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n\t:content-transfer-encoding:date:from:in-reply-to:message-id\n\t:mime-version:references:subject:to; s=pp1; bh=hdmmIZzD/+bP+bkAk\n\tTn1ju+gTqU60oqK6Vw7xeNzU3s=; b=MFErmZVt4SxOlLg+Lj4sNvmpA/n8Fyet0\n\tmd4npPfyR5abEO47c4mzHmhf4FIq1z60mOV6vtnAD/hGmhv1FdBESyaxXY6oAnYt\n\ty8hjkUCUppEuUzwCXI+ih42GnXkZwPYVvc85EN3ke/dhNv9Rr0S7B4LI0ycq+hfp\n\tDMkZimXS3hOjztn/MJJQhOK7ke3EntfIcnz7qER6se/KuTofVnpgWZHXwLI+uXtl\n\t9tzDjDqp6O78B8TnPZBJZBYdEGTv8syxhG9LXGWsCXhynAzU6vKckM+vSMza1YcX\n\tQlF69yy0v4Nf3osy++QBawqkAZGh0t7LLvLOfwuozbStrzZrtUz8Q==",
        "From": "Farhan Ali <alifm@linux.ibm.com>",
        "To": "linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,\n        linux-pci@vger.kernel.org",
        "Cc": "helgaas@kernel.org, lukas@wunner.de, alex@shazbot.org, clg@redhat.com,\n        kbusch@kernel.org, alifm@linux.ibm.com, schnelle@linux.ibm.com,\n        mjrosato@linux.ibm.com",
        "Subject": "[PATCH v12 4/7] s390/pci: Store PCI error information for passthrough\n devices",
        "Date": "Mon, 30 Mar 2026 10:40:08 -0700",
        "Message-ID": "<20260330174011.1161-5-alifm@linux.ibm.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20260330174011.1161-1-alifm@linux.ibm.com>",
        "References": "<20260330174011.1161-1-alifm@linux.ibm.com>",
        "Precedence": "bulk",
        "X-Mailing-List": "linux-pci@vger.kernel.org",
        "List-Id": "<linux-pci.vger.kernel.org>",
        "List-Subscribe": "<mailto:linux-pci+subscribe@vger.kernel.org>",
        "List-Unsubscribe": "<mailto:linux-pci+unsubscribe@vger.kernel.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-TM-AS-GCONF": "00",
        "X-Authority-Analysis": "v=2.4 cv=Fdo6BZ+6 c=1 sm=1 tr=0 ts=69cab584 cx=c_pps\n a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17\n a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=nHH4Lq_S5grMkevcTHMA:9",
        "X-Proofpoint-ORIG-GUID": "F5brkuQ8MXJkG5GDf-oHVehYZofyzChT",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMzMwMDE0MSBTYWx0ZWRfX9PUxz+sHUiHW\n TRkng9g6OOtTLtDy1W+qmR444ThmVtHyf9X0vgddFNFOvEC9QFT6+JO6Il+Qg4XsXgmmMEavkp8\n KN3bBxpo6/QERB/dJzqLjSjeWavUn5uzdfT5IUTRnEhcVaNrJQ9BhUsm4l1wrcCMnu6n1LJixW1\n g5aB4SGxhPq+a0t90sdEKnSJHeNcccAI/evhmhyx8AN/Ml5q/t7Yjg6MphTwR8bMRgmpX/jL+P4\n Dicntu/BTdZP62xJ0hiYYgMqZ2hB4xBf1Dn0hcI0cCZyk+kseDHJiWL5lUILB4mxY/8HQmfimRU\n V1CkUPIS4IQj1qwSeC22x4T/0AQFk38QpbPnIbLICi+w2+brU5iKSb33Dy5xStzSRwFV/UWtYXj\n NLlwKP7BvN+yw9lohRyhvNCGGOvyFUcAMfORF+Kj/SPdnoyOARVfskr3L1Y+oR1t7fDWNyll5/p\n +YLdkhDMBFHEIarJrOg==",
        "X-Proofpoint-GUID": "F5brkuQ8MXJkG5GDf-oHVehYZofyzChT",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-03-29_05,2026-03-28_01,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n impostorscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501\n adultscore=0 malwarescore=0 phishscore=0 spamscore=0 lowpriorityscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603300141"
    },
    "content": "For a passthrough device we need co-operation from user space to recover\nthe device. This would require to bubble up any error information to user\nspace.  Let's store this error information for passthrough devices, so it\ncan be retrieved later.\n\nWe can now have userspace drivers (vfio-pci based) on s390x. The userspace\ndrivers will not have any KVM fd and so no kzdev associated with them. So\nwe need to update the logic for detecting passthrough devices to not depend\non struct kvm_zdev.\n\nSigned-off-by: Farhan Ali <alifm@linux.ibm.com>\n---\n arch/s390/include/asm/pci.h      |  30 ++++++++\n arch/s390/pci/pci.c              |   1 +\n arch/s390/pci/pci_event.c        | 113 ++++++++++++++++++-------------\n drivers/vfio/pci/vfio_pci_zdev.c |   9 ++-\n 4 files changed, 105 insertions(+), 48 deletions(-)",
    "diff": "diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h\nindex c0ff19dab580..7fb9a80b0175 100644\n--- a/arch/s390/include/asm/pci.h\n+++ b/arch/s390/include/asm/pci.h\n@@ -118,6 +118,31 @@ struct zpci_bus {\n \tenum pci_bus_speed\tmax_bus_speed;\n };\n \n+/* Content Code Description for PCI Function Error */\n+struct zpci_ccdf_err {\n+\tu32 reserved1;\n+\tu32 fh;                         /* function handle */\n+\tu32 fid;                        /* function id */\n+\tu32 ett         :  4;           /* expected table type */\n+\tu32 mvn         : 12;           /* MSI vector number */\n+\tu32 dmaas       :  8;           /* DMA address space */\n+\tu32 reserved2   :  6;\n+\tu32 q           :  1;           /* event qualifier */\n+\tu32 rw          :  1;           /* read/write */\n+\tu64 faddr;                      /* failing address */\n+\tu32 reserved3;\n+\tu16 reserved4;\n+\tu16 pec;                        /* PCI event code */\n+} __packed;\n+\n+#define ZPCI_ERR_PENDING_MAX 4\n+struct zpci_ccdf_pending {\n+\tu8 count;\n+\tu8 head;\n+\tu8 tail;\n+\tstruct zpci_ccdf_err err[ZPCI_ERR_PENDING_MAX];\n+};\n+\n /* Private data per function */\n struct zpci_dev {\n \tstruct zpci_bus *zbus;\n@@ -171,6 +196,7 @@ struct zpci_dev {\n \n \tchar res_name[16];\n \tbool mio_capable;\n+\tbool mediated_recovery;\n \tstruct zpci_bar_struct bars[PCI_STD_NUM_BARS];\n \n \tu64\t\tstart_dma;\t/* Start of available DMA addresses */\n@@ -192,6 +218,8 @@ struct zpci_dev {\n \tstruct iommu_domain *s390_domain; /* attached IOMMU domain */\n \tstruct kvm_zdev *kzdev;\n \tstruct mutex kzdev_lock;\n+\tstruct zpci_ccdf_pending pending_errs;\n+\tstruct mutex pending_errs_lock;\n \tspinlock_t dom_lock;\t\t/* protect s390_domain change */\n };\n \n@@ -330,6 +358,8 @@ void zpci_debug_exit_device(struct zpci_dev *);\n int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *);\n int zpci_clear_error_state(struct zpci_dev *zdev);\n int zpci_reset_load_store_blocked(struct zpci_dev *zdev);\n+void zpci_start_mediated_recovery(struct zpci_dev *zdev);\n+void zpci_stop_mediated_recovery(struct zpci_dev *zdev);\n \n #ifdef CONFIG_NUMA\n \ndiff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c\nindex 2a430722cbe4..d64d370d86cf 100644\n--- a/arch/s390/pci/pci.c\n+++ b/arch/s390/pci/pci.c\n@@ -841,6 +841,7 @@ struct zpci_dev *zpci_create_device(u32 fid, u32 fh, enum zpci_state state)\n \tmutex_init(&zdev->state_lock);\n \tmutex_init(&zdev->fmb_lock);\n \tmutex_init(&zdev->kzdev_lock);\n+\tmutex_init(&zdev->pending_errs_lock);\n \n \treturn zdev;\n \ndiff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c\nindex 839bd91c056e..9cda09da8b43 100644\n--- a/arch/s390/pci/pci_event.c\n+++ b/arch/s390/pci/pci_event.c\n@@ -17,23 +17,6 @@\n #include \"pci_bus.h\"\n #include \"pci_report.h\"\n \n-/* Content Code Description for PCI Function Error */\n-struct zpci_ccdf_err {\n-\tu32 reserved1;\n-\tu32 fh;\t\t\t\t/* function handle */\n-\tu32 fid;\t\t\t/* function id */\n-\tu32 ett\t\t:  4;\t\t/* expected table type */\n-\tu32 mvn\t\t: 12;\t\t/* MSI vector number */\n-\tu32 dmaas\t:  8;\t\t/* DMA address space */\n-\tu32\t\t:  6;\n-\tu32 q\t\t:  1;\t\t/* event qualifier */\n-\tu32 rw\t\t:  1;\t\t/* read/write */\n-\tu64 faddr;\t\t\t/* failing address */\n-\tu32 reserved3;\n-\tu16 reserved4;\n-\tu16 pec;\t\t\t/* PCI event code */\n-} __packed;\n-\n /* Content Code Description for PCI Function Availability */\n struct zpci_ccdf_avail {\n \tu32 reserved1;\n@@ -60,16 +43,11 @@ static inline bool ers_result_indicates_abort(pci_ers_result_t ers_res)\n \t}\n }\n \n-static bool is_passed_through(struct pci_dev *pdev)\n+static bool needs_mediated_recovery(struct pci_dev *pdev)\n {\n \tstruct zpci_dev *zdev = to_zpci(pdev);\n-\tbool ret;\n-\n-\tmutex_lock(&zdev->kzdev_lock);\n-\tret = !!zdev->kzdev;\n-\tmutex_unlock(&zdev->kzdev_lock);\n-\n-\treturn ret;\n+\tguard(mutex)(&zdev->pending_errs_lock);\n+\treturn zdev->mediated_recovery;\n }\n \n static bool is_driver_supported(struct pci_driver *driver)\n@@ -81,6 +59,47 @@ static bool is_driver_supported(struct pci_driver *driver)\n \treturn true;\n }\n \n+static void zpci_store_pci_error(struct pci_dev *pdev,\n+\t\t\t\t struct zpci_ccdf_err *ccdf)\n+{\n+\tstruct zpci_dev *zdev = to_zpci(pdev);\n+\tint i;\n+\n+\tguard(mutex)(&zdev->pending_errs_lock);\n+\tif (zdev->pending_errs.count >= ZPCI_ERR_PENDING_MAX) {\n+\t\tpr_err(\"%s: Maximum number (%d) of pending error events queued\",\n+\t\t       pci_name(pdev), ZPCI_ERR_PENDING_MAX);\n+\t\treturn;\n+\t}\n+\n+\ti = zdev->pending_errs.tail % ZPCI_ERR_PENDING_MAX;\n+\tmemcpy(&zdev->pending_errs.err[i], ccdf, sizeof(struct zpci_ccdf_err));\n+\tzdev->pending_errs.tail++;\n+\tzdev->pending_errs.count++;\n+}\n+\n+void zpci_start_mediated_recovery(struct zpci_dev *zdev)\n+{\n+\tguard(mutex)(&zdev->pending_errs_lock);\n+\tzdev->mediated_recovery = true;\n+}\n+EXPORT_SYMBOL_GPL(zpci_start_mediated_recovery);\n+\n+void zpci_stop_mediated_recovery(struct zpci_dev *zdev)\n+{\n+\tstruct pci_dev *pdev = NULL;\n+\n+\tguard(mutex)(&zdev->pending_errs_lock);\n+\tzdev->mediated_recovery = false;\n+\tpdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);\n+\tif (zdev->pending_errs.count)\n+\t\tpr_info(\"%s: Unhandled PCI error events count=%d\",\n+\t\t\tpci_name(pdev), zdev->pending_errs.count);\n+\tmemset(&zdev->pending_errs, 0, sizeof(struct zpci_ccdf_pending));\n+\tpci_dev_put(pdev);\n+}\n+EXPORT_SYMBOL_GPL(zpci_stop_mediated_recovery);\n+\n static pci_ers_result_t zpci_event_notify_error_detected(struct pci_dev *pdev,\n \t\t\t\t\t\t\t struct pci_driver *driver)\n {\n@@ -175,7 +194,8 @@ static pci_ers_result_t zpci_event_do_reset(struct pci_dev *pdev,\n  * and the platform determines which functions are affected for\n  * multi-function devices.\n  */\n-static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)\n+static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev,\n+\t\t\t\t\t\t\t  struct zpci_ccdf_err *ccdf)\n {\n \tpci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;\n \tstruct zpci_dev *zdev = to_zpci(pdev);\n@@ -194,13 +214,6 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)\n \t}\n \tpdev->error_state = pci_channel_io_frozen;\n \n-\tif (is_passed_through(pdev)) {\n-\t\tpr_info(\"%s: Cannot be recovered in the host because it is a pass-through device\\n\",\n-\t\t\tpci_name(pdev));\n-\t\tstatus_str = \"failed (pass-through)\";\n-\t\tgoto out_unlock;\n-\t}\n-\n \tdriver = to_pci_driver(pdev->dev.driver);\n \tif (!is_driver_supported(driver)) {\n \t\tif (!driver) {\n@@ -216,12 +229,23 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)\n \t\tgoto out_unlock;\n \t}\n \n+\tif (needs_mediated_recovery(pdev))\n+\t\tzpci_store_pci_error(pdev, ccdf);\n+\n \ters_res = zpci_event_notify_error_detected(pdev, driver);\n \tif (ers_result_indicates_abort(ers_res)) {\n \t\tstatus_str = \"failed (abort on detection)\";\n \t\tgoto out_unlock;\n \t}\n \n+\tif (needs_mediated_recovery(pdev)) {\n+\t\tpr_info(\"%s: Leaving recovery of pass-through device to user-space\\n\",\n+\t\t\tpci_name(pdev));\n+\t\ters_res = PCI_ERS_RESULT_RECOVERED;\n+\t\tstatus_str = \"in progress\";\n+\t\tgoto out_unlock;\n+\t}\n+\n \tif (ers_res != PCI_ERS_RESULT_NEED_RESET) {\n \t\ters_res = zpci_event_do_error_state_clear(pdev, driver);\n \t\tif (ers_result_indicates_abort(ers_res)) {\n@@ -266,25 +290,20 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)\n  * @pdev: PCI function for which to report\n  * @es: PCI channel failure state to report\n  */\n-static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_t es)\n+static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_t es,\n+\t\t\t\t  struct zpci_ccdf_err *ccdf)\n {\n \tstruct pci_driver *driver;\n \n \tpci_dev_lock(pdev);\n \tpdev->error_state = es;\n-\t/**\n-\t * While vfio-pci's error_detected callback notifies user-space QEMU\n-\t * reacts to this by freezing the guest. In an s390 environment PCI\n-\t * errors are rarely fatal so this is overkill. Instead in the future\n-\t * we will inject the error event and let the guest recover the device\n-\t * itself.\n-\t */\n-\tif (is_passed_through(pdev))\n-\t\tgoto out;\n+\n+\tif (needs_mediated_recovery(pdev))\n+\t\tzpci_store_pci_error(pdev, ccdf);\n \tdriver = to_pci_driver(pdev->dev.driver);\n \tif (driver && driver->err_handler && driver->err_handler->error_detected)\n \t\tdriver->err_handler->error_detected(pdev, pdev->error_state);\n-out:\n+\n \tpci_dev_unlock(pdev);\n }\n \n@@ -330,12 +349,12 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf)\n \t\tbreak;\n \tcase 0x0040: /* Service Action or Error Recovery Failed */\n \tcase 0x003b:\n-\t\tzpci_event_io_failure(pdev, pci_channel_io_perm_failure);\n+\t\tzpci_event_io_failure(pdev, pci_channel_io_perm_failure, ccdf);\n \t\tbreak;\n \tdefault: /* PCI function left in the error state attempt to recover */\n-\t\ters_res = zpci_event_attempt_error_recovery(pdev);\n+\t\ters_res = zpci_event_attempt_error_recovery(pdev, ccdf);\n \t\tif (ers_res != PCI_ERS_RESULT_RECOVERED)\n-\t\t\tzpci_event_io_failure(pdev, pci_channel_io_perm_failure);\n+\t\t\tzpci_event_io_failure(pdev, pci_channel_io_perm_failure, ccdf);\n \t\tbreak;\n \t}\n \tpci_dev_put(pdev);\ndiff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c\nindex 0990fdb146b7..0658095ac5b1 100644\n--- a/drivers/vfio/pci/vfio_pci_zdev.c\n+++ b/drivers/vfio/pci/vfio_pci_zdev.c\n@@ -148,6 +148,8 @@ int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)\n \tif (!zdev)\n \t\treturn -ENODEV;\n \n+\tzpci_start_mediated_recovery(zdev);\n+\n \tif (!vdev->vdev.kvm)\n \t\treturn 0;\n \n@@ -161,7 +163,12 @@ void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)\n {\n \tstruct zpci_dev *zdev = to_zpci(vdev->pdev);\n \n-\tif (!zdev || !vdev->vdev.kvm)\n+\tif (!zdev)\n+\t\treturn;\n+\n+\tzpci_stop_mediated_recovery(zdev);\n+\n+\tif (!vdev->vdev.kvm)\n \t\treturn;\n \n \tif (zpci_kvm_hook.kvm_unregister)\n",
    "prefixes": [
        "v12",
        "4/7"
    ]
}