[{"id":3686759,"web_url":"http://patchwork.ozlabs.org/comment/3686759/","msgid":"<20260505225625.ADC00C2BCB9@smtp.kernel.org>","list_archive_url":null,"date":"2026-05-05T22:56:25","subject":"Re: [PATCH v15 4/7] s390/pci: Store PCI error information for\n passthrough devices","submitter":{"id":93311,"url":"http://patchwork.ozlabs.org/api/people/93311/","name":null,"email":"sashiko-bot@kernel.org"},"content":"Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:\n- [High] The mediated recovery feature for non-KVM passthrough devices is gated by a KVM-dependent Kconfig option, causing it to be compiled out and fail when KVM is disabled.\n- [High] A time-of-check to time-of-use (TOCTOU) race condition exists in `zpci_event_attempt_error_recovery` regarding the `mediated_recovery` state, leading to permanently broken passthrough devices.\n- [Low] Missing trailing newline (`\\n`) characters in `pr_err()` and `pr_info()` format strings.\n--\n\ncommit b20dbe013c9c596d29efb7c91a62d8992eaf33b9\nAuthor: Farhan Ali <alifm@linux.ibm.com>\n\ns390/pci: Store PCI error information for passthrough devices\n\nThis commit modifies s390 PCI error handling to store error information for\npassthrough devices. This allows userspace drivers like vfio-pci to manage\ndevice recovery directly, removing the dependency on a KVM file descriptor.\n\n> diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c\n> --- a/arch/s390/pci/pci_event.c\n> +++ b/arch/s390/pci/pci_event.c\n> @@ -81,6 +52,46 @@ static bool is_driver_supported(struct pci_driver *driver)\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.mediated_recovery)\n> +\t\treturn;\n> +\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\nIs this missing a trailing newline (\\n) in the format string?\n\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_stop_mediated_recovery(struct zpci_dev *zdev)\n> +{\n> +\tguard(mutex)(&zdev->pending_errs_lock);\n> +\tzdev->pending_errs.mediated_recovery = false;\n> +\tif (zdev->pending_errs.count)\n> +\t\tpr_info(\"Unhandled PCI error events count=%d for PCI function 0x%x\",\n> +\t\t\tzdev->pending_errs.count, zdev->fid);\n\nDoes this pr_info() also need a trailing newline (\\n)?\n\n> +\tmemset(&zdev->pending_errs, 0, sizeof(struct zpci_ccdf_pending));\n> +}\n> +EXPORT_SYMBOL_GPL(zpci_stop_mediated_recovery);\n[ ... ]\n> @@ -216,12 +221,25 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)\n>  \t\tgoto out_unlock;\n>  \t}\n>  \n> +\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> +\tmutex_lock(&zdev->pending_errs_lock);\n> +\tif (zdev->pending_errs.mediated_recovery) {\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\tmutex_unlock(&zdev->pending_errs_lock);\n> +\t\tgoto out_unlock;\n> +\t}\n> +\tmutex_unlock(&zdev->pending_errs_lock);\n\nIs there a time-of-check to time-of-use race condition here?\n\nzpci_store_pci_error() checks zdev->pending_errs.mediated_recovery and\nreturns without storing the error if it is false. Later in this function,\nwe acquire pending_errs_lock again and re-evaluate mediated_recovery to\ndecide whether to skip host-level recovery.\n\nIf a concurrent userspace open of the VFIO device sets mediated_recovery to\ntrue between these two checks, the error is discarded but the host recovery\nis still skipped. Could this state be cached once under a single critical\nsection?\n\n> diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c\n> --- a/drivers/vfio/pci/vfio_pci_zdev.c\n> +++ b/drivers/vfio/pci/vfio_pci_zdev.c\n> @@ -144,24 +144,36 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,\n>  int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)\n>  {\n>  \tstruct zpci_dev *zdev = to_zpci(vdev->pdev);\n> +\tint ret;\n>  \n>  \tif (!zdev)\n>  \t\treturn -ENODEV;\n>  \n> +\tzpci_start_mediated_recovery(zdev);\n\nThe commit message states the goal is to support userspace drivers without\nany KVM fd. However, does placing this logic in vfio_pci_zdev.c inadvertently\ntie the mediated recovery feature to KVM?\n\nSince vfio_pci_zdev.c is only built if CONFIG_VFIO_PCI_ZDEV_KVM is enabled,\nif a kernel is configured without KVM, vfio_pci_zdev_open_device() resolves\nto an empty inline stub. This means mediated_recovery would never be set to\ntrue, and the host kernel would still attempt recovery on the passthrough\ndevice.","headers":{"Return-Path":"\n <linux-pci+bounces-53809-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=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=kp0XEbbF;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-53809-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"kp0XEbbF\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\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 4g9DQm14JQz1yJx\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 08:56:32 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 7E52B3022047\n\tfor <incoming@patchwork.ozlabs.org>; Tue,  5 May 2026 22:56:28 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 56B0432E6B8;\n\tTue,  5 May 2026 22:56:26 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\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 34AA132C937\n\tfor <linux-pci@vger.kernel.org>; Tue,  5 May 2026 22:56:25 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id ADC00C2BCB9;\n\tTue,  5 May 2026 22:56:25 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778021786; cv=none;\n b=TLAbA6qR/WXUhOggCP0FZ6iTbD95MgElGgeSdcYgZff/1gsTQfxt5TLFnPVWiW4RMlCAVDZ+mBEFkhN28z2eXOaIeFPb9f8kgv3Nm+o8fGMBJYxDqLJCM7B9IiYjeV0iO2hhSw5ejHn/499GtsizajurW25AS/AlBbAkw/EWStU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778021786; c=relaxed/simple;\n\tbh=s78riUYH4omGMoo57Ve3BIq7OJE5YbXIBLS7N7pyIpA=;\n\th=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date:\n\t Message-Id;\n b=eOBaFgrj52smKX0OsMHNFP11rFzzt6GY5ZCLXz3IkmdkSOvtCbvxV0sx+42JWX43pIlJ4zQZQduu+QCZVLpeSbWim4uR6zvrD9eLvIy3BC9aZ4rjpDzlWdXeyz1NSnlPcVRT7YU8X6zDiXQihMUtNrWwN9lOFJj7uNx5vxD/mOw=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=kp0XEbbF; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778021785;\n\tbh=s78riUYH4omGMoo57Ve3BIq7OJE5YbXIBLS7N7pyIpA=;\n\th=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date:From;\n\tb=kp0XEbbFhF/BAWJ1gLZm+mq0TRgfqKgqqu+oU/nCpD4/0G+tgbMqZVtpvZbCA/G/l\n\t lJHGO2FH/XqujgCX5xe/RjR4TrwEKZlcE+XlGKnMx3pM4bGCL2e2o133rQJQfKp86g\n\t tca8JX0Azw+d1IArr+80/oeQIFfFVMNFqIussTMulpGeHSwxAJh7VVzw/uzlBp6oaH\n\t bK163+Sg5J7dVNbXhK6U79Ip2+YCuH+O2I0CVp4QzXYFJmK3IsrzPRINJucKfRMYuC\n\t 0bYTSSxqx94rJWgPIBURhJraUgVU7qcHPdZOLtHmybHZY784uHfu0kNQnaWu5PVkAH\n\t AmXIKXvsRWovg==","From":"sashiko-bot@kernel.org","Subject":"Re: [PATCH v15 4/7] s390/pci: Store PCI error information for\n passthrough devices","Reply-To":"sashiko@lists.linux.dev","To":"\"Farhan Ali\" <alifm@linux.ibm.com>","Cc":"linux-pci@vger.kernel.org","In-Reply-To":"<20260505200510.2954-5-alifm@linux.ibm.com>","References":"<20260505200510.2954-5-alifm@linux.ibm.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Date":"Tue, 05 May 2026 22:56:25 +0000","Message-Id":"<20260505225625.ADC00C2BCB9@smtp.kernel.org>","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>"}},{"id":3686920,"web_url":"http://patchwork.ozlabs.org/comment/3686920/","msgid":"<24bd0f694b2bddf07450e09fcea0488ee42ccdf7.camel@linux.ibm.com>","list_archive_url":null,"date":"2026-05-06T09:38:34","subject":"Re: [PATCH v15 4/7] s390/pci: Store PCI error information for\n passthrough devices","submitter":{"id":78856,"url":"http://patchwork.ozlabs.org/api/people/78856/","name":"Niklas Schnelle","email":"schnelle@linux.ibm.com"},"content":"On Tue, 2026-05-05 at 13:05 -0700, Farhan Ali wrote:\n> For a passthrough device we need co-operation from user space to recover\n> the device. This would require to bubble up any error information to user\n> space.  Let's store this error information for passthrough devices, so it\n> can be retrieved later.\n> \n> We can now have userspace drivers (vfio-pci based) on s390x. The userspace\n> drivers will not have any KVM fd and so no kzdev associated with them. So\n> we need to update the logic for detecting passthrough devices to not depend\n> on struct kvm_zdev.\n> \n> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>\n> Signed-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        | 114 +++++++++++++++++--------------\n>  drivers/vfio/pci/vfio_pci_zdev.c |  18 ++++-\n>  4 files changed, 109 insertions(+), 54 deletions(-)\n> \n> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h\n> index 5dcf35f0f325..016386f7ef4a 100644\n> --- a/arch/s390/include/asm/pci.h\n> +++ b/arch/s390/include/asm/pci.h\n> @@ -118,6 +118,32 @@ 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> +\tbool mediated_recovery;\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> @@ -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> @@ -334,6 +362,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>  \n> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c\n> index 39bd2adfc240..2d377c2e194d 100644\n> --- a/arch/s390/pci/pci.c\n> +++ b/arch/s390/pci/pci.c\n> @@ -842,6 +842,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>  \n> diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c\n> index 839bd91c056e..41547c54076f 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,18 +43,6 @@ 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> -{\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> -}\n> -\n>  static bool is_driver_supported(struct pci_driver *driver)\n>  {\n>  \tif (!driver || !driver->err_handler)\n> @@ -81,6 +52,46 @@ 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.mediated_recovery)\n> +\t\treturn;\n> +\n> +\tif (zdev->pending_errs.count >= ZPCI_ERR_PENDING_MAX) {\n> +\t\tpr_err(\"%s: Maximum number (%d) of pending error events queued\",\n\nMissing \"\\n\"\n\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->pending_errs.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> +\tguard(mutex)(&zdev->pending_errs_lock);\n> +\tzdev->pending_errs.mediated_recovery = false;\n> +\tif (zdev->pending_errs.count)\n> +\t\tpr_info(\"Unhandled PCI error events count=%d for PCI function 0x%x\",\n\nAlso missing \"\\n\"\n\n> +\t\t\tzdev->pending_errs.count, zdev->fid);\n> +\tmemset(&zdev->pending_errs, 0, sizeof(struct zpci_ccdf_pending));\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 +186,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 +206,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 +221,25 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)\n>  \t\tgoto out_unlock;\n>  \t}\n>  \n> +\tzpci_store_pci_error(pdev, ccdf);\n\nSashiko notes that zdev->pendings_errs.mediated_recovery could become\ntrue between the above zpci_store_pci_error() and the below check for\nleaving recovery to user-space. I think we could make a general\nimprovement that also tackles this concern. The ideas is that we could\nhave zpci_store_pci_error() return true if it did store the error and\nwe are in mediated recovery mode. Then we use that as the signal to\nskip host recovery below. That way we also don't need to retake the\npending_errs_lock which makes the below much simpler and it would be a\nwin independent of the race. As for the race this would make sure that\nwe either do the host recovery or store the error and let user-space\nrecover.\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> +\tmutex_lock(&zdev->pending_errs_lock);\n> +\tif (zdev->pending_errs.mediated_recovery) {\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\tmutex_unlock(&zdev->pending_errs_lock);\n> +\t\tgoto out_unlock;\n> +\t}\n> +\tmutex_unlock(&zdev->pending_errs_lock);\n\nOther than the missing \"\\n\" and suggestion above this looks good to me.\nSo I'd hope to R-b the next version.\n\nThanks,\nNiklas","headers":{"Return-Path":"\n <linux-pci+bounces-53839-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=HHhW2Lu0;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-53839-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=\"HHhW2Lu0\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=148.163.158.5","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 sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g9VpY3q21z1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 19:44:37 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 82AFE3014BC1\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  6 May 2026 09:39:49 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id E70E13EAC90;\n\tWed,  6 May 2026 09:39:47 +0000 (UTC)","from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n [148.163.158.5])\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 554073E9F9A;\n\tWed,  6 May 2026 09:39:44 +0000 (UTC)","from pps.filterd (m0356516.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 645HRnPw2769341;\n\tWed, 6 May 2026 09:39:39 GMT","from ppma11.dal12v.mail.ibm.com\n (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9w6fav8-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tWed, 06 May 2026 09:39:39 +0000 (GMT)","from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1])\n\tby ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 6469dOki031844;\n\tWed, 6 May 2026 09:39:38 GMT","from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74])\n\tby ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwx9ydbg7-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tWed, 06 May 2026 09:39:38 +0000 (GMT)","from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com\n [10.39.53.228])\n\tby smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 6469daFQ32637624\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tWed, 6 May 2026 09:39:37 GMT","from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id D830758055;\n\tWed,  6 May 2026 09:39:36 +0000 (GMT)","from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 3082358059;\n\tWed,  6 May 2026 09:39:35 +0000 (GMT)","from [9.52.215.169] (unknown [9.52.215.169])\n\tby smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP;\n\tWed,  6 May 2026 09:39:35 +0000 (GMT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778060387; cv=none;\n b=nYXbed56NYXyuh6T2G71CAhG29MHJycKh7baNv11uuBOP8cIfXFgBEwS7eUlK8qXQSOth2VOWRwqItkDkbC3aCZB4dEDXdcnbP0U4mBTfkbqqe6UgwqNCpOYkMq2eErVlsWMTPVgg2YFivGV2ztQQxbygOuE4+BTuoFntDY0gIw=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778060387; c=relaxed/simple;\n\tbh=4Gv4eM8gD0segQ3Z+gCobKn/W1vPAzKXWT9G8vuJ9q0=;\n\th=Message-ID:Subject:From:To:Cc:In-Reply-To:References:Content-Type:\n\t Date:MIME-Version;\n b=fpwhH7sMIMNcaE0Nqvt1P7n5ETP07fU0Y6FA9GuYPyJMPhjQ/wGAhbROcOGC3OLHJdXwlN4am8iMsCHTwTxNCwUMAlHcl27JKK/HiRnwlipfzaUV/I2EwQsG29Wjp6uMcc9eXmEbELRKUsWReV9zJcpGAgjm8SwaVGSbmOuJCRY=","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=HHhW2Lu0; arc=none smtp.client-ip=148.163.158.5","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n\t:content-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to; s=pp1; bh=WEAmT+\n\tbr5ESyBMdhBXa0IcMUMJYiUaug0gPuYdmYpvQ=; b=HHhW2Lu0PG+Kk5ZeLeOrsW\n\tcktOWqBJJ/9KB6YyXhvfsmj+OzMdOvUL55cfiRSQAZ97mO3cfiY7qCrxLwYtyiJD\n\t+LLoweUYcO06uQkmNorT+OE8RX3pNY4MphgIylYySEZCSAbh5qgQavZUJUhNFvX4\n\t390c8kRA0IgJQg5heLoUdaGpKbKxZ7nmRKk/BUGsg6P8lxDGkulkKX+iwd2QwB1n\n\tKl10uaFex4okwRJpPCJnEvFWYM6AgMBXqb+tEWvqONTy+fW0h6l/qHW2uc88DHfe\n\tHSHmrMOvJ2mzSqTauU9lvGTE0QjucaYjl0SMccaE7yFXa1VQ2DYNB5aIJKzohFSw\n\t==","Message-ID":"<24bd0f694b2bddf07450e09fcea0488ee42ccdf7.camel@linux.ibm.com>","Subject":"Re: [PATCH v15 4/7] s390/pci: Store PCI error information for\n passthrough devices","From":"Niklas Schnelle <schnelle@linux.ibm.com>","To":"Farhan Ali <alifm@linux.ibm.com>, linux-s390@vger.kernel.org,\n        linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org","Cc":"helgaas@kernel.org, alex@shazbot.org, mjrosato@linux.ibm.com","In-Reply-To":"<20260505200510.2954-5-alifm@linux.ibm.com>","References":"<20260505200510.2954-1-alifm@linux.ibm.com>\n\t <20260505200510.2954-5-alifm@linux.ibm.com>","Autocrypt":"addr=schnelle@linux.ibm.com; prefer-encrypt=mutual;\n keydata=mQINBGHm3M8BEAC+MIQkfoPIAKdjjk84OSQ8erd2OICj98+GdhMQpIjHXn/RJdCZLa58k\n /ay5x0xIHkWzx1JJOm4Lki7WEzRbYDexQEJP0xUia0U+4Yg7PJL4Dg/W4Ho28dRBROoJjgJSLSHwc\n 3/1pjpNlSaX/qg3ZM8+/EiSGc7uEPklLYu3gRGxcWV/944HdUyLcnjrZwCn2+gg9ncVJjsimS0ro/\n 2wU2RPE4ju6NMBn5Go26sAj1owdYQQv9t0d71CmZS9Bh+2+cLjC7HvyTHKFxVGOznUL+j1a45VrVS\n XQ+nhTVjvgvXR84z10bOvLiwxJZ/00pwNi7uCdSYnZFLQ4S/JGMs4lhOiCGJhJ/9FR7JVw/1t1G9a\n UlqVp23AXwzbcoV2fxyE/CsVpHcyOWGDahGLcH7QeitN6cjltf9ymw2spBzpRnfFn80nVxgSYVG1d\n w75ksBAuQ/3e+oTQk4GAa2ShoNVsvR9GYn7rnsDN5pVILDhdPO3J2PGIXa5ipQnvwb3EHvPXyzakY\n tK50fBUPKk3XnkRwRYEbbPEB7YT+ccF/HioCryqDPWUivXF8qf6Jw5T1mhwukUV1i+QyJzJxGPh19\n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3nULFeeCt7T/edk2FC6KVh4sL1jw1kyceX4DjiMffqYBPrhK5gz5\n cDIixLBF9C6Wt1ObvuDBrIQf1/3q6EZrUrUuf6qtaXDMuC6cSlShm47qaPEvVYh67O9JZQ7vzvaea\n UI74DJUb8Pjnz7mTOmMOzsS1gUhCue4n2YSSM6ythioCGb/3bgMGTpuer3JhvZG5s5uKD9yyj8s8x\n 35qJkCFfjmjVx9s3vSUS48X+cUpYcMispErKzFu7C0YgKoxvJ4XTfXlDBiMFMPYcN67hsb2jeYHVJ\n wzE+fIZiDx9JLh1oQW2krwjweisE+3glOaKXZKi0fBtkxyH41iemLtLNYZRJopv6ykdl3hiI+Nh+a\n 3FZJPTo/OpqchMm8XIeDxC4NFFiPMpyLeYzIxO7eZpiGrAjVTE=","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Date":"Wed, 06 May 2026 11:38:34 +0200","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","User-Agent":"Evolution 3.58.3 (3.58.3-1.fc43) ","X-TM-AS-GCONF":"00","X-Authority-Analysis":"v=2.4 cv=XPQAjwhE c=1 sm=1 tr=0 ts=69fb0c5b cx=c_pps\n a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17\n a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8\n a=pafV649OIR0JyFPQdDAA:9 a=QEXdDO2ut3YA:10","X-Proofpoint-ORIG-GUID":"5qRXA7xaIYJfoXEGmPKiuhWCZbnT_lZm","X-Proofpoint-GUID":"5qRXA7xaIYJfoXEGmPKiuhWCZbnT_lZm","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNTA2MDA5NCBTYWx0ZWRfX2JXiHplIN3vV\n 5GUa26LbfQI//NfpXUSVhmKL2nqR386dCxkVg/AQzwQnBJDv2dBtKlc74+VbpktdUCs7vka6p9U\n QbHCdTdl1XL2fShUY3Z5CFc6lgSRKi5e6VcoQB7JlTauIlhQv4iuWIs/rAKplDTCV1F0H4nU/Sz\n 93JQdc9G4hZqWK4F1p+VW4Bhngld3K53tzqwPcnYP3fUJJGoaUAPWPL9rIdQqXTW0nEHSOxPhR9\n NT1tt21XfIrJ9+zo1By09swKx7iU1Cj1ynhf1YvKyBpZNsrgSI9JXFEyiE5Eux1DDq7gigjbR0B\n oemotJbJh6g0qyabE2TLd0wzALQbvTVGUDOgDSNRVgjRtLjFugQOLEO7yNk2GBIFaAhp6f+F0an\n D84EiH7CUvn/3uDfQzexSi3dll096xaar6MaldQi2ETUE+dKtlvP2Jn23+j0h9ZT1GvKt6g48zd\n bGpMgDA+uLobRF/VWmQ==","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-05-05_03,2026-04-30_02,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0\n priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605060094"}}]