From patchwork Thu Jun 23 21:18:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=eXkFp2d5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=G9/epwDw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTY6D6bPxz9sFk for ; Fri, 24 Jun 2022 07:19:16 +1000 (AEST) Received: from localhost ([::1]:48506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UEM-0005bv-Gl for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:19:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDh-0005ba-1e; Thu, 23 Jun 2022 17:18:33 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:58551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDf-000447-6z; Thu, 23 Jun 2022 17:18:32 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 2FFA03200920; Thu, 23 Jun 2022 17:18:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 23 Jun 2022 17:18:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019107; x= 1656105507; bh=cn4VKbqnAk8XkRrnxeF4mMjoV8m+KL6EIkNrVpCKnOk=; b=e XkFp2d5a0vyNNdyGg7ZY2zbTes+1j7s5xTN7nGFb9ulUNwdwjUfEZpj5uQYghOIq ugVmHuGUEyS0htd8BlO/ZKqYUtqMIUwF2+6/a2ypCaqfTwDwb3U0tgMS4IQLfFvq 26iSvJ0Nk8bGziK1H+pgROvs5WwomzttxCqi701lHK6ZBFyrTCV1BRr3D0kjI2g4 vB2b9E1iSyjJw1sa6wIgoNv5dqS8W9FXqWJFNaValiICzHNUvEpDpYmvSvepsdhu yjHqp9jcP3c4S26qzuIk3qONZdWbv4dqU167/1Ve+P9vwDDgnqNbN7BFGPEych/3 cLg4M7sJm5xVPvkwiuVwQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019107; x=1656105507; bh=cn4VKbqnAk8Xk RrnxeF4mMjoV8m+KL6EIkNrVpCKnOk=; b=G9/epwDwWszGDRPCfzTOY6kssxDN8 PPaGS8jb3XaWvugmUIzqhGm+zKzAnW9ZMSMKPAES88noH/K/MttdKIWFxSolyRMV EB+Q5KGCbr1esm8i9twOR8NegCYFP75zrr0LGqFI15RwLsp3BIg7ow5QxpTxVEbg wHfd301cisTq6esuWHvKUFnpFKEEx+juLcLUEehJFE9eMqrsgE2sMXiSe+oxIRhL 1ejs9fU4p0OcIZ9/3A+SO26mnGVUJY2PnR7BziAhwm9bPJKLjtWZxGzqHS/pIPK2 98yL/rHR1mCpsdhQIBxo8ZJ+8yK/7iNiXTy+/8xuuszcvv+CXau4vG0jw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeegvddtheeukedufedugeeigfdvhfetgfegtddvfeejheevgeeijedvfedt tdelheenucffohhmrghinhepqhguvghvrdhiugenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:26 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 01/12] hw/nvme: fix incorrect use of errp/local_err Date: Thu, 23 Jun 2022 23:18:10 +0200 Message-Id: <20220623211821.50534-2-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Make nvme_check_constraints() return an int and fix incorrect use of errp/local_err. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index d349b3e42620..c8c4a0718fc4 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6808,7 +6808,7 @@ static const MemoryRegionOps nvme_cmb_ops = { }, }; -static void nvme_check_constraints(NvmeCtrl *n, Error **errp) +static int nvme_check_params(NvmeCtrl *n, Error **errp) { NvmeParams *params = &n->params; @@ -6822,38 +6822,38 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp) if (n->namespace.blkconf.blk && n->subsys) { error_setg(errp, "subsystem support is unavailable with legacy " "namespace ('drive' property)"); - return; + return -1; } if (params->max_ioqpairs < 1 || params->max_ioqpairs > NVME_MAX_IOQPAIRS) { error_setg(errp, "max_ioqpairs must be between 1 and %d", NVME_MAX_IOQPAIRS); - return; + return -1; } if (params->msix_qsize < 1 || params->msix_qsize > PCI_MSIX_FLAGS_QSIZE + 1) { error_setg(errp, "msix_qsize must be between 1 and %d", PCI_MSIX_FLAGS_QSIZE + 1); - return; + return -1; } if (!params->serial) { error_setg(errp, "serial property not set"); - return; + return -1; } if (n->pmr.dev) { if (host_memory_backend_is_mapped(n->pmr.dev)) { error_setg(errp, "can't use already busy memdev: %s", object_get_canonical_path_component(OBJECT(n->pmr.dev))); - return; + return -1; } if (!is_power_of_2(n->pmr.dev->size)) { error_setg(errp, "pmr backend size needs to be power of 2 in size"); - return; + return -1; } host_memory_backend_set_mapped(n->pmr.dev, true); @@ -6862,64 +6862,64 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp) if (n->params.zasl > n->params.mdts) { error_setg(errp, "zoned.zasl (Zone Append Size Limit) must be less " "than or equal to mdts (Maximum Data Transfer Size)"); - return; + return -1; } if (!n->params.vsl) { error_setg(errp, "vsl must be non-zero"); - return; + return -1; } if (params->sriov_max_vfs) { if (!n->subsys) { error_setg(errp, "subsystem is required for the use of SR-IOV"); - return; + return -1; } if (params->sriov_max_vfs > NVME_MAX_VFS) { error_setg(errp, "sriov_max_vfs must be between 0 and %d", NVME_MAX_VFS); - return; + return -1; } if (params->cmb_size_mb) { error_setg(errp, "CMB is not supported with SR-IOV"); - return; + return -1; } if (n->pmr.dev) { error_setg(errp, "PMR is not supported with SR-IOV"); - return; + return -1; } if (!params->sriov_vq_flexible || !params->sriov_vi_flexible) { error_setg(errp, "both sriov_vq_flexible and sriov_vi_flexible" " must be set for the use of SR-IOV"); - return; + return -1; } if (params->sriov_vq_flexible < params->sriov_max_vfs * 2) { error_setg(errp, "sriov_vq_flexible must be greater than or equal" " to %d (sriov_max_vfs * 2)", params->sriov_max_vfs * 2); - return; + return -1; } if (params->max_ioqpairs < params->sriov_vq_flexible + 2) { error_setg(errp, "(max_ioqpairs - sriov_vq_flexible) must be" " greater than or equal to 2"); - return; + return -1; } if (params->sriov_vi_flexible < params->sriov_max_vfs) { error_setg(errp, "sriov_vi_flexible must be greater than or equal" " to %d (sriov_max_vfs)", params->sriov_max_vfs); - return; + return -1; } if (params->msix_qsize < params->sriov_vi_flexible + 1) { error_setg(errp, "(msix_qsize - sriov_vi_flexible) must be" " greater than or equal to 1"); - return; + return -1; } if (params->sriov_max_vi_per_vf && @@ -6927,7 +6927,7 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp) error_setg(errp, "sriov_max_vi_per_vf must meet:" " (sriov_max_vi_per_vf - 1) %% %d == 0 and" " sriov_max_vi_per_vf >= 1", NVME_VF_RES_GRANULARITY); - return; + return -1; } if (params->sriov_max_vq_per_vf && @@ -6936,9 +6936,11 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp) error_setg(errp, "sriov_max_vq_per_vf must meet:" " (sriov_max_vq_per_vf - 1) %% %d == 0 and" " sriov_max_vq_per_vf >= 2", NVME_VF_RES_GRANULARITY); - return; + return -1; } } + + return 0; } static void nvme_init_state(NvmeCtrl *n) @@ -7336,7 +7338,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) { NvmeCtrl *n = NVME(pci_dev); NvmeNamespace *ns; - Error *local_err = NULL; NvmeCtrl *pn = NVME(pcie_sriov_get_pf(pci_dev)); if (pci_is_vf(pci_dev)) { @@ -7348,9 +7349,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) n->subsys = pn->subsys; } - nvme_check_constraints(n, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (nvme_check_params(n, errp)) { return; } @@ -7358,7 +7357,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) &pci_dev->qdev, n->parent_obj.qdev.id); if (nvme_init_subsys(n, errp)) { - error_propagate(errp, local_err); return; } nvme_init_state(n); From patchwork Thu Jun 23 21:18:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=IT730y55; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=Q0JCVFcb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTY9Q2jJdz9sFk for ; Fri, 24 Jun 2022 07:22:02 +1000 (AEST) Received: from localhost ([::1]:56200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UH1-0002T1-TT for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:21:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDi-0005bx-Eu; Thu, 23 Jun 2022 17:18:34 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:60823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDg-00044G-RE; Thu, 23 Jun 2022 17:18:34 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id DF0BF3200957; Thu, 23 Jun 2022 17:18:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 23 Jun 2022 17:18:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019110; x= 1656105510; bh=haKouNLSIfcSpTUsKMFT6Uc7HnGv5ffpazcJpUu6o3E=; b=I T730y557sgHX8IciVGC9itGQm/A1M5OCNlP3FrI8/HqrKnO/UXDpmIc3bd+Mk05J 6tL+7UWv4WLX2l8GOL1/Ok1MTUPXUch2WR/1kEEpCfZ6eYbpKqhtjBAqKTejEUtq ZOs2RyhSy0BvUno0AGI3MphfLiFzHMXniGhWYAapZg/3taqnzjDQyRPL1QSic3zB h6h7Z/J0mnfavPDsEQdTKmVwi4nY4LsBSJoXSFACuyLjBYymrkCwqt91VcFiKjTG bQj3jDvFzQOn3yn4g7uoKFWAHXWJSFy+whGyufklvLKV6gbU5YdXnAqY2N0gGnUH mieIrlMwri6I1ZziX/4aA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019110; x=1656105510; bh=haKouNLSIfcSp TUsKMFT6Uc7HnGv5ffpazcJpUu6o3E=; b=Q0JCVFcbd/QnJkx8NFkCituxrrLbr RgC6uB4P5bIyyb47soRfq5wwov1IRsl8c2nycbylzmf4WLcyoLzXnk/U41Skymfe UEkVd8MTSBGdH8SJ0eDO23M+i/wYX5filWMNqmX6DZAYX7iV9ybBO6Sf/fnSbwBf iDojIk7RNKf4gWbBh/f/8LhEVf7Z67H1DkKqFAY8TagpkmqKPw5u8hA3HOh1+oCt xTE4UkDet9Lf4pokHw3fZlWTtjLRqgdmNDTwEuuzrWDdWYyZr1WgmIYSFKkbQC1/ eYoTIVR1DZZ3iiCx6uvqYkpA+OuW70i2U7i39Jkmr5N2KteAt0JYQs2zg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:28 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 02/12] hw/nvme: remove redundant passing of PCIDevice Date: Thu, 23 Jun 2022 23:18:11 +0200 Message-Id: <20220623211821.50534-3-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen The NvmeCtrl is a PCIDevice, so remove the redundant passing of the PCIDevice parameter. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c8c4a0718fc4..b688afccbe5a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7007,8 +7007,9 @@ static void nvme_init_state(NvmeCtrl *n) } } -static void nvme_init_cmb(NvmeCtrl *n, PCIDevice *pci_dev) +static void nvme_init_cmb(NvmeCtrl *n) { + PCIDevice *pci_dev = PCI_DEVICE(n); uint64_t cmb_size = n->params.cmb_size_mb * MiB; uint64_t cap = ldq_le_p(&n->bar.cap); @@ -7029,8 +7030,9 @@ static void nvme_init_cmb(NvmeCtrl *n, PCIDevice *pci_dev) } } -static void nvme_init_pmr(NvmeCtrl *n, PCIDevice *pci_dev) +static void nvme_init_pmr(NvmeCtrl *n) { + PCIDevice *pci_dev = PCI_DEVICE(n); uint32_t pmrcap = ldl_le_p(&n->bar.pmrcap); NVME_PMRCAP_SET_RDS(pmrcap, 1); @@ -7116,8 +7118,9 @@ static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) return 0; } -static int nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) +static int nvme_init_pci(NvmeCtrl *n, Error **errp) { + PCIDevice *pci_dev = PCI_DEVICE(n); uint8_t *pci_conf = pci_dev->config; uint64_t bar_size; unsigned msix_table_offset, msix_pba_offset; @@ -7174,11 +7177,11 @@ static int nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); if (n->params.cmb_size_mb) { - nvme_init_cmb(n, pci_dev); + nvme_init_cmb(n); } if (n->pmr.dev) { - nvme_init_pmr(n, pci_dev); + nvme_init_pmr(n); } if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs) { @@ -7201,8 +7204,9 @@ static void nvme_init_subnqn(NvmeCtrl *n) } } -static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) +static void nvme_init_ctrl(NvmeCtrl *n) { + PCIDevice *pci_dev = PCI_DEVICE(n); NvmeIdCtrl *id = &n->id_ctrl; uint8_t *pci_conf = pci_dev->config; uint64_t cap = ldq_le_p(&n->bar.cap); @@ -7360,10 +7364,11 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) return; } nvme_init_state(n); - if (nvme_init_pci(n, pci_dev, errp)) { + if (nvme_init_pci(n, errp)) { return; } - nvme_init_ctrl(n, pci_dev); + + nvme_init_ctrl(n); /* setup a namespace if the controller drive property was given */ if (n->namespace.blkconf.blk) { From patchwork Thu Jun 23 21:18:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=DY7OPYRm; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=ZK+E696C; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYD46dRmz9s07 for ; Fri, 24 Jun 2022 07:24:20 +1000 (AEST) Received: from localhost ([::1]:33912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UJE-0006VU-1k for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:24:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDk-0005ix-Ly; Thu, 23 Jun 2022 17:18:36 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:43763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDj-00044d-48; Thu, 23 Jun 2022 17:18:36 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 38A3C320025E; Thu, 23 Jun 2022 17:18:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 23 Jun 2022 17:18:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019112; x= 1656105512; bh=lmRxgq4fNcetwf7/k+ccoS3T0J+r+c9ZMkTA0GefQO4=; b=D Y7OPYRm1cXopoIVlPR0waRGDrBOzF6wxh6J9FWub7L/QWaZkuOAhJiAO8zt6chHD iUNv5iJ9MSMnz0np72WgbryaxEKgGTkB2h+ohYLSTFO4p8z5DUjyvhBqF0Zy4N5T tEeDiuaEg6SIkyAor/ejydP1IYlG9VSUDwjwFj3OQbwYYZkppJP7kcQzRPIEYzuJ BLEYjafk8IRCXGqwyNQrvB4thw8S1nDE7q7XLIOWizvQ4AVx3RqwpxBPY8mkH5ek Tr381tuHg98/HV+TpFY3n6yu/j/iff/U5guCwsfGldwDJ0dqAjar+NddEN1RfJa9 h5XdtAusCbYXX7HkBsU5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019112; x=1656105512; bh=lmRxgq4fNcetw f7/k+ccoS3T0J+r+c9ZMkTA0GefQO4=; b=ZK+E696Cagri4Czao1423gXs1Rn23 evnkVW33W8VrBMrpprHibWWk+9x7bL9Cq/83WVOm0UFxybMdPtVzH5h02a7UNLVU MzxArKkAHLYCbL0XVIBilji4+g1WwcQS07cPGKwVyKw/5E8Zjv8+Os/uDDK/zV9v RtkxoDM0qnWxsxEqmHlYWNr7ApCBn8Ry/3L25M9RAPFQg8vHWpJrkAMmI59G4t6M lqRCVwkdCvcsE6Mel0gPy1EyLJ6OVIN9x/LijQ5T1pdOiZ6QQXvG8DRHqDccBAwU mKh/dYI4IHAjQTXlbF/4cxAXoI6bSIod4Fw6zNUZo9GLzbtEcoZi33Kcw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:31 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 03/12] hw/nvme: cleanup error reporting in nvme_init_pci() Date: Thu, 23 Jun 2022 23:18:12 +0200 Message-Id: <20220623211821.50534-4-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Replace the local Error variable with errp and ERRP_GUARD(). Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index b688afccbe5a..af82daa304bf 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7120,14 +7120,14 @@ static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) static int nvme_init_pci(NvmeCtrl *n, Error **errp) { + ERRP_GUARD(); + PCIDevice *pci_dev = PCI_DEVICE(n); uint8_t *pci_conf = pci_dev->config; uint64_t bar_size; unsigned msix_table_offset, msix_pba_offset; int ret; - Error *err = NULL; - pci_conf[PCI_INTERRUPT_PIN] = 1; pci_config_set_prog_interface(pci_conf, 0x2); @@ -7164,13 +7164,13 @@ static int nvme_init_pci(NvmeCtrl *n, Error **errp) } ret = msix_init(pci_dev, n->params.msix_qsize, &n->bar0, 0, msix_table_offset, - &n->bar0, 0, msix_pba_offset, 0, &err); + &n->bar0, 0, msix_pba_offset, 0, errp); if (ret < 0) { if (ret == -ENOTSUP) { - warn_report_err(err); + warn_report_err(*errp); + *errp = NULL; } else { - error_propagate(errp, err); - return ret; + return -1; } } From patchwork Thu Jun 23 21:18:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=Yiu6n7lw; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=TeIqED5P; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYG74n6Rz9s07 for ; Fri, 24 Jun 2022 07:26:07 +1000 (AEST) Received: from localhost ([::1]:38236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UKz-00014g-9z for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:26:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDn-0005rr-7k; Thu, 23 Jun 2022 17:18:40 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:39333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDl-00044y-IE; Thu, 23 Jun 2022 17:18:38 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id A69833200957; Thu, 23 Jun 2022 17:18:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 23 Jun 2022 17:18:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019115; x= 1656105515; bh=Gu/2ZQo53SQ5H+1IizNlQZ3toC12z2U/p2E4Ue6509c=; b=Y iu6n7lwBCOMnl1vOMaBjY+37vrAAk9pxrXzpxm2+lR70Fm9yQw5Z0gJho2cGH+uf kCQKN0vs+bitY7XbbpW79t+WuXz7sDwWu+XDnsUa40HaOyU/cs3ZUNrcUzkI9xGx /sPjWCFgHtwCQ8oHwgEltM+2Yv0pGz5/Ah8kAJrmc9Eq0aAyAnb+Fj4zGkZJQIAD i8wyeGtyBg+eHwYyFD1UhekO4gkd905XtbId1k/eml6UX5rXSkcQxch5pR1G2Ly6 2JE9kHbSOQHOlFZhxs3Bwv/ezcxec3boi0ECG4sm8xPTXv8/4a4t5/+wnWOrWw+l JjbQ1JMT6uR71YguikxUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019115; x=1656105515; bh=Gu/2ZQo53SQ5H +1IizNlQZ3toC12z2U/p2E4Ue6509c=; b=TeIqED5PGxwrg/PAAgV7PwEam3ucL itnQX4OFMGV/0v4odpMSgpjYM4FtZoGtf+m63fud14wrl9uF4InTZECdAQo4Tq8i fHbT5ayXqdF1nnpvzdRwfZdGeNTtIilbZMsORqnVF1fr+o7FJ4NV7RK8UBf/qN9X ZNqiKBosgoLRsMjVaiymnJr6lQ3U48rJYfpbvbZJA4VsEtkVGgNUtjtb8nC2EIDK NvCHz8/dSqgzZyYTCeywMImZisJlD6DCgKLPcvpBKjmq0+Y98RXPWVBEVNLnhc2/ 2HrIg5LIVNBWXtcdRu5GusYwBE1kkib2MbmZSDbjW2KSD5ukCDsU3NtDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:34 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 04/12] hw/nvme: fix numzrwa handling Date: Thu, 23 Jun 2022 23:18:13 +0200 Message-Id: <20220623211821.50534-5-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Number of ZRWA Resources should be initialized to Max Active Resources, and not the total number of zones. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 8 ++------ hw/nvme/ns.c | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index af82daa304bf..a09700455c02 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1765,9 +1765,7 @@ static uint16_t nvme_zrm_finish(NvmeNamespace *ns, NvmeZone *zone) if (zone->d.za & NVME_ZA_ZRWA_VALID) { zone->d.za &= ~NVME_ZA_ZRWA_VALID; - if (ns->params.numzrwa) { - ns->zns.numzrwa++; - } + ns->zns.numzrwa++; } /* fallthrough */ @@ -1807,9 +1805,7 @@ static uint16_t nvme_zrm_reset(NvmeNamespace *ns, NvmeZone *zone) nvme_aor_dec_active(ns); if (zone->d.za & NVME_ZA_ZRWA_VALID) { - if (ns->params.numzrwa) { - ns->zns.numzrwa++; - } + ns->zns.numzrwa++; } /* fallthrough */ diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 870c3ca1a2f0..b9b35b3c3bc9 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -286,7 +286,7 @@ static void nvme_ns_init_zoned(NvmeNamespace *ns) if (ns->params.zrwas) { ns->zns.numzrwa = ns->params.numzrwa ? - ns->params.numzrwa : ns->num_zones; + ns->params.numzrwa : ns->params.max_active_zones; ns->zns.zrwas = ns->params.zrwas >> ns->lbaf.ds; ns->zns.zrwafg = ns->params.zrwafg >> ns->lbaf.ds; @@ -294,7 +294,7 @@ static void nvme_ns_init_zoned(NvmeNamespace *ns) id_ns_z->ozcs |= NVME_ID_NS_ZONED_OZCS_ZRWASUP; id_ns_z->zrwacap = NVME_ID_NS_ZONED_ZRWACAP_EXPFLUSHSUP; - id_ns_z->numzrwa = cpu_to_le32(ns->params.numzrwa); + id_ns_z->numzrwa = cpu_to_le32(ns->zns.numzrwa - 1); id_ns_z->zrwas = cpu_to_le16(ns->zns.zrwas); id_ns_z->zrwafg = cpu_to_le16(ns->zns.zrwafg); } From patchwork Thu Jun 23 21:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=Dj5M/Qm/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=bF0QKeky; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTY9S0dzxz9sFk for ; Fri, 24 Jun 2022 07:22:03 +1000 (AEST) Received: from localhost ([::1]:56342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UH3-0002ZG-Le for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:22:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDq-00060M-I9; Thu, 23 Jun 2022 17:18:42 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:41257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDp-00045O-2O; Thu, 23 Jun 2022 17:18:42 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 2329B320091E; Thu, 23 Jun 2022 17:18:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 23 Jun 2022 17:18:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019117; x= 1656105517; bh=OwfQlYYQ1qwecaHdTXnsn9x20hUfPTiXgdnaRcXv18w=; b=D j5M/Qm/TgctsHjNKyYMJL7yia7VGIo0ZQ0/QM+WcZIKnAMaIN4p95X9jUyO6NzjP SmSKPSunm6Jcz05wRfmtf0raoOXPLt1iEScju06cZze5t9PddQPzrm96dF5IRK3h qqpvQH5Huyo7XeDTkGVFYORxK0985qoWMIopuB2A7RJAv1wL0JF5BnPozK++86LI yN/vbpg8G1md18bUAHZw53FoDOXsSMp7b1NuNYp64hxSdgzxyZTf+scew0EWag2j JhQCPmNa0ujomylwMdK7vCcpAedp7oIjR/+gUI768AhI3m7iCMBX/cZE431rJ2ku C7ip5xJgQKvmC+HYXOGfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019117; x=1656105517; bh=OwfQlYYQ1qwec aHdTXnsn9x20hUfPTiXgdnaRcXv18w=; b=bF0QKekyQUyjy0J+OXqZJOHQaw8UN 89vPrPCnnoB0rdP96LXWtop3hLeRtgoc61QnDFNGHs8apeUvliI0CEUStRWxccjh KgZx1M2rUveKArN6gcr139um1jM2koW060YG9ONvU9fRURTOte+KWY9uIzYPduKn Ff7k3yMD6KrT62rFvr6JBY6Rhu959QgEv9w7vjiC0druMOAT/aYezyNIjwEpkijy RynThdO9Z4jXQjHd7jLJg/IHZVcZpvKKfx75OnTifPXqaUB5Gc26QJYOwquyEogx JViEdWABEfznBqFx1Rel+tnHJEJoOwqlD1bHlaw4uN/yq+spsSjBUNHTw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:36 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 05/12] hw/nvme: fix accidental reintroduction of redundant code Date: Thu, 23 Jun 2022 23:18:14 +0200 Message-Id: <20220623211821.50534-6-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Commit 44219b6029fc ("hw/nvme: 64-bit pi support") accidentially reintroduced code that was removed in commit a6de6ed5092c ("hw/nvme: move format parameter parsing"). It is beneign, but get rid of it anyway. Fixes: 44219b6029fc ("hw/nvme: 64-bit pi support") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index a09700455c02..f10334fc1d3f 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5725,9 +5725,6 @@ static void nvme_format_bh(void *opaque) NvmeFormatAIOCB *iocb = opaque; NvmeRequest *req = iocb->req; NvmeCtrl *n = nvme_ctrl(req); - uint32_t dw10 = le32_to_cpu(req->cmd.cdw10); - uint8_t lbaf = dw10 & 0xf; - uint8_t pi = (dw10 >> 5) & 0x7; uint16_t status; int i; @@ -5749,7 +5746,7 @@ static void nvme_format_bh(void *opaque) goto done; } - status = nvme_format_check(iocb->ns, lbaf, pi); + status = nvme_format_check(iocb->ns, iocb->lbaf, iocb->pi); if (status) { req->status = status; goto done; From patchwork Thu Jun 23 21:18:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=kDyfzyZb; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=ih4v7Uhy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYKG4mrqz9s07 for ; Fri, 24 Jun 2022 07:28:50 +1000 (AEST) Received: from localhost ([::1]:43882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UNc-0004ru-54 for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDt-00067O-2Z; Thu, 23 Jun 2022 17:18:45 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:36895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDr-00045h-GR; Thu, 23 Jun 2022 17:18:44 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 91DB73200901; Thu, 23 Jun 2022 17:18:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 23 Jun 2022 17:18:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019120; x= 1656105520; bh=rtJSyEain9X10ZJ9y4MMHJr4bL5seuQJHeojW/t6nqc=; b=k DyfzyZbQDjf7MByM+vzw9avgWKLdMDei0CQkYgrYRwxwZrbDSWtXQGMNucQ0Jm6J PZTadDI8UsfesjLYeV40lOz9NZ8cF7GHZB7yrnGGfxYrBPbC/OLVKITDzgnbrJnX oXUdW+uExeH8Oi0bVtNm4Nc+Kbuj4GBGle3WVusghBSUrbMxgW8ztezBHvqoInhY 4Iw7ZUNdakM967UtCdPO29CkNLssvZac8lwvbVZ1FV68vr6gw8TG45GYJMDdRPK+ k7C8u1/aBCdEd+B5EnYkTAMKXJd2vcxuveMi9bOh4w/XLRA7zj7M7QVOuYgepRa3 0ldFxiPPQrETpbSaWNYOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019120; x=1656105520; bh=rtJSyEain9X10 ZJ9y4MMHJr4bL5seuQJHeojW/t6nqc=; b=ih4v7UhyNpPUiu4B+8joiRaIA6pIZ OqC1/QGrb1s/IwmcfkTlSbfnIzVDQG2nmNg0oYuv8euyjq0KlvVDLdSgvZcHoo21 L/gFB7o0kBe8296Zkg5ph2KbGTedgF7t23oyoExUe1EA+ZtRzG86OL7aEoxUMJNY YGHeUpBfDYWBMK81sY9J2Q13d57At0tHdMaNMZZsEq13sS8Yt1c4QmpGsBq3Wk5j B8CDsYtYGjpqsQ6QxLCnqSZUeN/GMkoh5tSvMV/OSRPszYUMMmXeC4C+aNN0raLf nEK8D7DGiSC5QoYqtqb0ad/m6NU5JAqUQvALysbxNRHrjc8lfOg0K6kVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:38 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 06/12] hw/nvme: fix cancellation of format operations Date: Thu, 23 Jun 2022 23:18:15 +0200 Message-Id: <20220623211821.50534-7-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Cancelling a format operation neglects to set iocb->ret as well as clearing the iocb->aiocb after cancelling the underlying aiocb. Fix this. Fixes: 3bcf26d3d619 ("hw/nvme: reimplement format nvm to allow cancellation") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f10334fc1d3f..a85eabfa8bfd 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5640,8 +5640,11 @@ static void nvme_format_cancel(BlockAIOCB *aiocb) { NvmeFormatAIOCB *iocb = container_of(aiocb, NvmeFormatAIOCB, common); + iocb->ret = -ECANCELED; + if (iocb->aiocb) { blk_aio_cancel_async(iocb->aiocb); + iocb->aiocb = NULL; } } From patchwork Thu Jun 23 21:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647372 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=Ke291IdI; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=cpV5dFLB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYMt4hs8z9s09 for ; Fri, 24 Jun 2022 07:31:05 +1000 (AEST) Received: from localhost ([::1]:48122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UPm-0007hW-Po for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:31:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDv-0006CN-B9; Thu, 23 Jun 2022 17:18:47 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:50003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDt-00045y-GB; Thu, 23 Jun 2022 17:18:47 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0E26D320025E; Thu, 23 Jun 2022 17:18:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 23 Jun 2022 17:18:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019122; x= 1656105522; bh=BwX9+a3mmIjl5tKgXuuhWLJER3Iee/pH50sfjWa/OWg=; b=K e291IdIhgcSnfYlkwYR8HgWPzCQhzbhe6FPRd3C8CUGl3w7zlS9t9Hs9XZBXNqWO U8ty4UI4vadD5FINxs/GvyVKNw0/0/8TOhJ2bCyyr7ySPSHMLX9LX4LukZAi+vN2 AA70Fqp8pdOrMKO456Oo9pLldZH+sbuuzCKStubo3/pTFNcdCWQUG27Xx7uK5kMa gXPTyeEzBXBKt+3D41paIZSx8UTKzj+4dbPAgx2cRkmERlHlSRdPrbDKmm9zYM5i +R+X/qukzDrXaAE2Uitprn9LokMNZv9WtlVkFyX9x39ikVWyFW3AmvYkNd+0TFXc hCpgubekArUXkcsVka6Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019122; x=1656105522; bh=BwX9+a3mmIjl5 tKgXuuhWLJER3Iee/pH50sfjWa/OWg=; b=cpV5dFLBYDyJyJg7ul5P4xfA/UkcL TfQChWF62nYsU6oisqbHjs4F1UZPUXJivtNR8VXGbNdrp1sEjli44czi/kOVDUDz dJ0ZXISoUevGmwiLZcXVMldnwmXVyTerWoZWB36m1hPfD0Cv9y1Qyudex9ir9jgG e/KroqYEyxjzlgTAg9UEUqPngAywuL74K0V69T2H431ddmYVghXrZoA8FcL5akWe F6L9WOXE2FhmUPBE9wrmpupB1WDhmsoHO8nq0rW4smCnLbw8gPyRFP0Rgk49p6s9 n2U7gu3MICoHi25s8DKCi3m+Stc2tHmsg7gy7bPbxP8n3kWPuR9IyiF3A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:41 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 07/12] hw/nvme: fix flush cancel Date: Thu, 23 Jun 2022 23:18:16 +0200 Message-Id: <20220623211821.50534-8-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Make sure that iocb->aiocb is NULL'ed when cancelling. Fixes: 38f4ac65ac88 ("hw/nvme: reimplement flush to allow cancellation") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index a85eabfa8bfd..cea90cf65ce8 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -3158,6 +3158,7 @@ static void nvme_flush_cancel(BlockAIOCB *acb) if (iocb->aiocb) { blk_aio_cancel_async(iocb->aiocb); + iocb->aiocb = NULL; } } From patchwork Thu Jun 23 21:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=PPV5nQys; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=qKb1pqSP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYQx1xxWz9s09 for ; Fri, 24 Jun 2022 07:33:44 +1000 (AEST) Received: from localhost ([::1]:52352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4USM-0002JZ-2Q for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:33:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDx-0006Gr-4A; Thu, 23 Jun 2022 17:18:49 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:48911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDv-00046I-Fq; Thu, 23 Jun 2022 17:18:48 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7E697320091E; Thu, 23 Jun 2022 17:18:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 23 Jun 2022 17:18:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019125; x= 1656105525; bh=urkDKj28QOaJNNz3LSM48EgyVlP0l7gXJ1kwu/bRW4s=; b=P PV5nQysTSSh9AEW7bw0BGLMuknaO4mhjJRW4aH+D6DZ+uydLBBLOKzQTqOC6K95U Zkzqpj3hUQEpzFGGGYSLigOP0HvRSB8RYPFqNF23/wSsnS6zijxw2+x4fWIWTirI 2p9od6jY8RGkYA+5Yai5ORFfqUJrwPD15XEIc320ZUb5xWEwUxlgnwFhqVeGpsBm tDRhu5toYO7uKxoaA7G2EUNQ6DoPXwVd1BAkoAkaa3GoP9VdmvNrerZ2Ir/PQfRm KM1fSQq5RvB+ffugxBptyIP6Gv3ipp9A4vYDcXye26GCF2SEt5O3RUHaKJuMV/rC gkgIIwxvuTtir7577eT1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019125; x=1656105525; bh=urkDKj28QOaJN Nz3LSM48EgyVlP0l7gXJ1kwu/bRW4s=; b=qKb1pqSPOMsD4GopT1rZBgAe71cDW CXr/xf6wLgk2z3RwVMw3+alccLCjUG5kkCwDNB6bw1eNYDChYV0eKS80aEMf+Ru9 WjSEe9Fn6Zu3TCnwFvRBcdVCMwNUu+28y910qFfLqByGXTlHZ/0chV01HBm+Teh1 NvvN79paScPfDbWwE2SbiRw7Z8GQvPm/XulzC9e5+LGOBG7vACSnD/7D1adYG90o Gp7JZAN1+fEKZB9l0hSYD1kQDUBnBwzNeFT2OeBDWq1TJYWsUurQHL4+Lg456sv8 Hgy1p/hiph599xguPd0+UsmrZ5mfvX6RRMXCsSYVkuPazFO82EEPhguFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:43 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 08/12] hw/nvme: rework flush bh scheduling Date: Thu, 23 Jun 2022 23:18:17 +0200 Message-Id: <20220623211821.50534-9-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Remove an initial bh scheduling and move the completion invocation into a separate bh. Also, make sure that iocb->aiocb is NULL'ed when cancelling. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index cea90cf65ce8..1acf88d9e8c7 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -3168,6 +3168,19 @@ static const AIOCBInfo nvme_flush_aiocb_info = { .get_aio_context = nvme_get_aio_context, }; +static void nvme_flush_bh(void *opaque) +{ + NvmeFlushAIOCB *iocb = opaque; + + iocb->common.cb(iocb->common.opaque, iocb->ret); + + qemu_bh_delete(iocb->bh); + iocb->bh = NULL; + qemu_aio_unref(iocb); +} + +static void nvme_do_flush(NvmeFlushAIOCB *iocb); + static void nvme_flush_ns_cb(void *opaque, int ret) { NvmeFlushAIOCB *iocb = opaque; @@ -3189,13 +3202,11 @@ static void nvme_flush_ns_cb(void *opaque, int ret) } out: - iocb->aiocb = NULL; - qemu_bh_schedule(iocb->bh); + nvme_do_flush(iocb); } -static void nvme_flush_bh(void *opaque) +static void nvme_do_flush(NvmeFlushAIOCB *iocb) { - NvmeFlushAIOCB *iocb = opaque; NvmeRequest *req = iocb->req; NvmeCtrl *n = nvme_ctrl(req); int i; @@ -3222,14 +3233,9 @@ static void nvme_flush_bh(void *opaque) return; done: - qemu_bh_delete(iocb->bh); - iocb->bh = NULL; - - iocb->common.cb(iocb->common.opaque, iocb->ret); - - qemu_aio_unref(iocb); - - return; + if (iocb->bh) { + qemu_bh_schedule(iocb->bh); + } } static uint16_t nvme_flush(NvmeCtrl *n, NvmeRequest *req) @@ -3263,7 +3269,7 @@ static uint16_t nvme_flush(NvmeCtrl *n, NvmeRequest *req) } req->aiocb = &iocb->common; - qemu_bh_schedule(iocb->bh); + nvme_do_flush(iocb); return NVME_NO_COMPLETE; From patchwork Thu Jun 23 21:18:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647358 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=AEhB+xWd; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=aBTMM6Yv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTY710y9Nz9s07 for ; Fri, 24 Jun 2022 07:19:57 +1000 (AEST) Received: from localhost ([::1]:51846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UF0-0007s1-KG for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:19:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDz-0006Nq-GU; Thu, 23 Jun 2022 17:18:51 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:34495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDx-00046X-SY; Thu, 23 Jun 2022 17:18:51 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id F3D3E3200957; Thu, 23 Jun 2022 17:18:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 23 Jun 2022 17:18:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019127; x= 1656105527; bh=5AJzH0OZXxYlk0dkZeJQPFlyIp8WXctBx49EIQxU/Zw=; b=A EhB+xWdvJeZxLgoz6ZTyYE/IZ8aXOozpMRY+MNZH+JMWh4IquWkHP9z6jnTS1snL sD+o2uh3UMTpycZ5CkpowXZmT4V+1kY/fBDPdGa1OtciiT3qqbrnefQ1X4YXuLOI rZWTUt0XRwZB6hrB6ErM66CB3nXnWjgZiygQvkTppQCxaEOAhS0WR/X8bJ1zACzo iazF+qb8RCe+8+TSuwgQLfSgYFMffeRMxrxR8clXFMt0WVJmlsn5aU4qX91AvZWF XtRFq4+QkRpJkyjDU8XlgheEgOKca1p133Xbom7bU7CXiJJxUxRjV7gxWvAr/EuL hbtNBzlPT2KXKdAKsC+3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019127; x=1656105527; bh=5AJzH0OZXxYlk 0dkZeJQPFlyIp8WXctBx49EIQxU/Zw=; b=aBTMM6YviYLy5qptugnRkhRdkBeGU 9MfdXyKH0Owvc0lWVivTb1lvfQTfTGfO4Ewf0PLVTMK9d36giyLY08Sr/Sh2iQi8 DFN/VW6krLoblLaEM4Gd26ip7YKhPzK+mGp8hsaZvXZG8OYhNvdmSvxkZNBawGOc N1/NwRu3twX5+yXfz/z55FMt2gqhe5MVNDgAW3yQmLswgVuwuo3NKoj4gQ2AOo/x jh+HH/0SSFw+utoklrOZaetopw90+VDXIkwmtn8gurCluzMZOugH8ckR4YgFD67p zhpkW/QmaWdTgiZMqpvmPjRaSRhEeL9TyMvY7kfsK/TWJePe0g8u5z4rw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:46 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 09/12] hw/nvme: improve cancellation handling in zone reset Date: Thu, 23 Jun 2022 23:18:18 +0200 Message-Id: <20220623211821.50534-10-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen If the zone reset operation is cancelled but the block unmap operation completes normally, the callback will continue resetting the next zone since it neglects to check iocb->ret which will have been set to -ECANCELED. Make sure that this is checked and bail out if an error is present. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 1acf88d9e8c7..9add74753fd8 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -3760,14 +3760,8 @@ static void nvme_zone_reset_epilogue_cb(void *opaque, int ret) int64_t moff; int count; - if (ret < 0) { - nvme_zone_reset_cb(iocb, ret); - return; - } - - if (!ns->lbaf.ms) { - nvme_zone_reset_cb(iocb, 0); - return; + if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) { + goto out; } moff = nvme_moff(ns, iocb->zone->d.zslba); @@ -3777,6 +3771,9 @@ static void nvme_zone_reset_epilogue_cb(void *opaque, int ret) BDRV_REQ_MAY_UNMAP, nvme_zone_reset_cb, iocb); return; + +out: + nvme_zone_reset_cb(iocb, ret); } static void nvme_zone_reset_cb(void *opaque, int ret) @@ -3788,6 +3785,8 @@ static void nvme_zone_reset_cb(void *opaque, int ret) if (ret < 0) { iocb->ret = ret; goto done; + } else if (iocb->ret < 0) { + goto done; } if (iocb->zone) { From patchwork Thu Jun 23 21:18:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=gA2jnaZi; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=hV6ljQLv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYD91wzDz9s07 for ; Fri, 24 Jun 2022 07:24:25 +1000 (AEST) Received: from localhost ([::1]:34286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UJL-0006kJ-3M for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:24:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UE1-0006Wo-TH; Thu, 23 Jun 2022 17:18:53 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:46257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UE0-00046o-7l; Thu, 23 Jun 2022 17:18:53 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 4F6FA320091E; Thu, 23 Jun 2022 17:18:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 23 Jun 2022 17:18:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019129; x= 1656105529; bh=Uw4Beh3GJ2Y977GWAS5ev7RKpWmRWIWeTXSBJIX0XOg=; b=g A2jnaZi0+0z3wJKL8FDdNV3OAqG8hY5iItXfj1a+b0iWiKX+zWqvyAUw2neEFttW nXhlJg7LGDF5hEwgfDtCpw1Y5KhtVOrUZ9E707U7k8qU4dlMxuFFpXxUY4Oil6Et 0Yx+11BvStoywfxlqHT3P8Jcfgb6IiHv5t9PlJ3jkB9jmixw2dszgy0BLpblQCub 9KbxE2Sf3gJj9SEy5Wnm03uHfVsFwbB44YdpQLNXpIIDWbrsLNeyv45R3/rM1Bra zXj1KUFWQw4uLUIBpYkOg1slKE/8+mrWKH43OMz613Wn7mXvkBXwSc/pPytGsmrV XpzW+WmuZbYxcjJHxtO3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019129; x=1656105529; bh=Uw4Beh3GJ2Y97 7GWAS5ev7RKpWmRWIWeTXSBJIX0XOg=; b=hV6ljQLvdKgB5+YcQXO9se7X2un6m NMhiLje3dqYChdR/u0c1j9fkM1CaNnUvTZEBADvYTUXyd6kM19J5HE8JGGSxXsWi ikPAQIUlF26Ps5XdkAOL5WL4KdgEfHciTgFW77gXaF1Ze3wMtbZoOfPQrOEgSDUr nW43T5+PQSe+MmLzdHBgYh9sVX5dX7IHSCUnYt4SSk3sF8RSAtU4oi2cDGdNa0f2 meRiYEZwjQKjPRQzRVEFWu4LP7G6SwMLIGfFbepv/FvDS1toCTXZ85kHu3aqfNA7 xF/0TmWaeSiDUY380utC6GfcszQ6cloueVSxOKQxe9hiEXLALeG9MtXVw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:48 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 10/12] hw/nvme: improve cancellation handling in dsm Date: Thu, 23 Jun 2022 23:18:19 +0200 Message-Id: <20220623211821.50534-11-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen When the DSM operation is cancelled asynchronously, we set iocb->ret to -ECANCELED. However, the callback function only checks the return value of the completed aio, which may have completed succesfully prior to the cancellation and thus the callback ends up continuing the dsm operation instead of bailing out. Fix this. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 9add74753fd8..5eee730ed0cf 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2367,16 +2367,10 @@ static void nvme_dsm_md_cb(void *opaque, int ret) uint64_t slba; uint32_t nlb; - if (ret < 0) { - iocb->ret = ret; + if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) { goto done; } - if (!ns->lbaf.ms) { - nvme_dsm_cb(iocb, 0); - return; - } - range = &iocb->range[iocb->idx - 1]; slba = le64_to_cpu(range->slba); nlb = le32_to_cpu(range->nlb); @@ -2389,7 +2383,6 @@ static void nvme_dsm_md_cb(void *opaque, int ret) ret = nvme_block_status_all(ns, slba, nlb, BDRV_BLOCK_ZERO); if (ret) { if (ret < 0) { - iocb->ret = ret; goto done; } @@ -2403,8 +2396,7 @@ static void nvme_dsm_md_cb(void *opaque, int ret) return; done: - iocb->aiocb = NULL; - qemu_bh_schedule(iocb->bh); + nvme_dsm_cb(iocb, ret); } static void nvme_dsm_cb(void *opaque, int ret) @@ -2420,6 +2412,8 @@ static void nvme_dsm_cb(void *opaque, int ret) if (ret < 0) { iocb->ret = ret; goto done; + } else if (iocb->ret < 0) { + goto done; } next: From patchwork Thu Jun 23 21:18:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=bFQXeFiu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=FEUcdBWN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYGF5MWdz9s07 for ; Fri, 24 Jun 2022 07:26:13 +1000 (AEST) Received: from localhost ([::1]:38520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UL5-0001Fl-K6 for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UE4-0006f2-D7; Thu, 23 Jun 2022 17:18:56 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:38647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UE2-00047E-JY; Thu, 23 Jun 2022 17:18:56 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id BA92E3200953; Thu, 23 Jun 2022 17:18:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 23 Jun 2022 17:18:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019132; x= 1656105532; bh=URNdkGQ8Jhh3C9CNzgiSYcZOTDyRV0EKShg68E0eQCw=; b=b FQXeFiuTZbLjgvDR7+pxwBpg2apm4giODTBakR19fBZzH/8ADSAt7/0mYpm19y0T DeGmJtwmIuAeaQyE/0hAvXM/Sz3jf/GqSSsNVQufRP/zhEjlDyBaOMsGA0nVHrGT 9zf5ub8d628pXbE0Zmww8tdYA8Oxn9byvn/BBoplFcHdX83BduLpZctwJMVEkyUc UHcSGPys4WlVCbzUhmJuXiEX7l/CYDsb8FctWIcGQY6bfscmieEbL3xnfY22N7J3 PwlgVGzhlsUlS/NERdb0waz0mx5BpB9cWpGxKfNjYuQLt+RkqNMoXrBEDYwyTOJ1 H8gFC5bCHWRHZ5bmWXcjg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019132; x=1656105532; bh=URNdkGQ8Jhh3C 9CNzgiSYcZOTDyRV0EKShg68E0eQCw=; b=FEUcdBWNcKNEFcn7kxPt8Xgcgg8u9 b9j/vy7IXC+Wyo5ebySG2nwcDlPpmsJV1eHo8ucdmhHrcblx2sNBKXPRTbRU0/mK VEx7HiUAJTYjLE8yQ0fXVmPbLCnTT9zYL1JQt907rHm4KKE/N0Gw5OB4AzrTRFXE UtsqiMWFs2EcEnACLjvGGGX94Ui6q0AVLuNv2fgNBmX0+BtfmYtI3bLmCYdyAkAG EuBQvlWm6wUNvBkcuvhlWKPPi5iG1p9WtGX1Xk9yJBHXw4vIrenxWREW3mVybaMh hgmsILeLlNttlODm32Aj4TrvDkNC1NOr85eTaPgoXmA+IMpJnFkaG+5Kw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:51 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 11/12] hw/nvme: simplify copy command error handling Date: Thu, 23 Jun 2022 23:18:20 +0200 Message-Id: <20220623211821.50534-12-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Move error handling down in the call stack to simplify the control flow. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 50 ++++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 5eee730ed0cf..4d6b4c9f00ba 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2614,7 +2614,7 @@ static void nvme_copy_bh(void *opaque) qemu_aio_unref(iocb); } -static void nvme_copy_cb(void *opaque, int ret); +static void nvme_do_copy(NvmeCopyAIOCB *iocb); static void nvme_copy_source_range_parse_format0(void *ranges, int idx, uint64_t *slba, uint32_t *nlb, @@ -2726,7 +2726,7 @@ static void nvme_copy_out_completed_cb(void *opaque, int ret) iocb->idx++; iocb->slba += nlb; out: - nvme_copy_cb(iocb, iocb->ret); + nvme_do_copy(iocb); } static void nvme_copy_out_cb(void *opaque, int ret) @@ -2738,16 +2738,8 @@ static void nvme_copy_out_cb(void *opaque, int ret) size_t mlen; uint8_t *mbounce; - if (ret < 0) { - iocb->ret = ret; + if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) { goto out; - } else if (iocb->ret < 0) { - goto out; - } - - if (!ns->lbaf.ms) { - nvme_copy_out_completed_cb(iocb, 0); - return; } nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, NULL, @@ -2766,7 +2758,7 @@ static void nvme_copy_out_cb(void *opaque, int ret) return; out: - nvme_copy_cb(iocb, ret); + nvme_copy_out_completed_cb(iocb, ret); } static void nvme_copy_in_completed_cb(void *opaque, int ret) @@ -2860,15 +2852,9 @@ static void nvme_copy_in_completed_cb(void *opaque, int ret) invalid: req->status = status; - iocb->aiocb = NULL; - if (iocb->bh) { - qemu_bh_schedule(iocb->bh); - } - - return; - + iocb->ret = -1; out: - nvme_copy_cb(iocb, ret); + nvme_do_copy(iocb); } static void nvme_copy_in_cb(void *opaque, int ret) @@ -2879,16 +2865,8 @@ static void nvme_copy_in_cb(void *opaque, int ret) uint64_t slba; uint32_t nlb; - if (ret < 0) { - iocb->ret = ret; + if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) { goto out; - } else if (iocb->ret < 0) { - goto out; - } - - if (!ns->lbaf.ms) { - nvme_copy_in_completed_cb(iocb, 0); - return; } nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, &slba, @@ -2904,12 +2882,11 @@ static void nvme_copy_in_cb(void *opaque, int ret) return; out: - nvme_copy_cb(iocb, iocb->ret); + nvme_copy_in_completed_cb(iocb, ret); } -static void nvme_copy_cb(void *opaque, int ret) +static void nvme_do_copy(NvmeCopyAIOCB *iocb) { - NvmeCopyAIOCB *iocb = opaque; NvmeRequest *req = iocb->req; NvmeNamespace *ns = req->ns; uint64_t slba; @@ -2917,10 +2894,7 @@ static void nvme_copy_cb(void *opaque, int ret) size_t len; uint16_t status; - if (ret < 0) { - iocb->ret = ret; - goto done; - } else if (iocb->ret < 0) { + if (iocb->ret < 0) { goto done; } @@ -2967,6 +2941,7 @@ static void nvme_copy_cb(void *opaque, int ret) invalid: req->status = status; + iocb->ret = -1; done: iocb->aiocb = NULL; if (iocb->bh) { @@ -2974,7 +2949,6 @@ done: } } - static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req) { NvmeNamespace *ns = req->ns; @@ -3060,7 +3034,7 @@ static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req) BLOCK_ACCT_WRITE); req->aiocb = &iocb->common; - nvme_copy_cb(iocb, 0); + nvme_do_copy(iocb); return NVME_NO_COMPLETE; From patchwork Thu Jun 23 21:18:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=NaAUeoQP; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=CLnCGbEt; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTYVT5BKsz9s09 for ; Fri, 24 Jun 2022 07:36:49 +1000 (AEST) Received: from localhost ([::1]:55956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UVL-0004si-HP for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:36:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UEQ-0007Qi-OD; Thu, 23 Jun 2022 17:19:18 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:46583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UEP-00047a-0o; Thu, 23 Jun 2022 17:19:18 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 2819D320025E; Thu, 23 Jun 2022 17:18:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 23 Jun 2022 17:18:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019134; x= 1656105534; bh=RdetYxis/WUrSIhNp79V8/GQNGJ3LxpRdXFX7z5KRpE=; b=N aAUeoQPAEFv1pOtCfvWDtkvwoUNeuUzdhmSQmcgYn2JChNCKwVKUJmRmgoj6Hq1R P7sIqNscQhDc0YD45uy5JfYbHIk9yntycMS45tL5g9Yrf0ZYtAoxdVSedkqAn4MX V0TTtdJ6VlpqLi6HLtwQh++4sopuec/vD7DnT4z8c4pZlorJuc8pkvUrJpz5vs0e AwrkdVJKVZWkcwFE3Z0wpX43Dll34+4bhiylahiCuk6icQ2+PdJhzWjcFZ1PYvpd 8hf41EXRdvSIjDRav1au6Xv5XBFbwXM+nvvRJF3+p2pw6O3jYN9boLgwzM1QnJiO Yd4ApOs2+j6fSmg+k7+YQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019134; x=1656105534; bh=RdetYxis/WUrS IhNp79V8/GQNGJ3LxpRdXFX7z5KRpE=; b=CLnCGbEtC/SkR9qM6JkZ39EqqaKuT w6/ML/hUOCvcNISjGtnpRnD/4vmNohHzCeY/6HARsp55v6eLBtftJmxFTatZrv3I xETpjuc4V2WvM8VlQLpxLh/roUvolcChrSYqpcWiLuK+hMLFEdjgn4Ulqyh1R3pj b7aqtJ3VXE8KBxMrDEoHPLOuFRJGFv5lg8SaZ6tMEAIRQKHg13CSNratBiy9Mgqp d8Btij1ktOqiVIJQCXtd4iHlKI1/pYlwdLxnpwtHxeWmHZ1Lhr59mSIJ2vfcIijR d6G/xLxwhvUEAxF5OLc3vu1wWoOAxATjlyN5k+AZWc6DPLc5+kLBLajGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:53 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 12/12] hw/nvme: align logic of format with flush Date: Thu, 23 Jun 2022 23:18:21 +0200 Message-Id: <20220623211821.50534-13-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Use the same logic in format as in flush, saving a bh scheduling at the start of the operation and moving completion handling to a separately invoked bottom halve. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 4d6b4c9f00ba..0e6f4d71134b 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5608,8 +5608,6 @@ typedef struct NvmeFormatAIOCB { uint8_t pil; } NvmeFormatAIOCB; -static void nvme_format_bh(void *opaque); - static void nvme_format_cancel(BlockAIOCB *aiocb) { NvmeFormatAIOCB *iocb = container_of(aiocb, NvmeFormatAIOCB, common); @@ -5628,6 +5626,17 @@ static const AIOCBInfo nvme_format_aiocb_info = { .get_aio_context = nvme_get_aio_context, }; +static void nvme_format_bh(void *opaque) +{ + NvmeFormatAIOCB *iocb = opaque; + + iocb->common.cb(iocb->common.opaque, iocb->ret); + + qemu_bh_delete(iocb->bh); + iocb->bh = NULL; + qemu_aio_unref(iocb); +} + static void nvme_format_set(NvmeNamespace *ns, uint8_t lbaf, uint8_t mset, uint8_t pi, uint8_t pil) { @@ -5642,6 +5651,8 @@ static void nvme_format_set(NvmeNamespace *ns, uint8_t lbaf, uint8_t mset, nvme_ns_init_format(ns); } +static void nvme_do_format(NvmeFormatAIOCB *iocb); + static void nvme_format_ns_cb(void *opaque, int ret) { NvmeFormatAIOCB *iocb = opaque; @@ -5651,6 +5662,8 @@ static void nvme_format_ns_cb(void *opaque, int ret) if (ret < 0) { iocb->ret = ret; goto done; + } else if (iocb->ret < 0) { + goto done; } assert(ns); @@ -5672,8 +5685,7 @@ static void nvme_format_ns_cb(void *opaque, int ret) iocb->offset = 0; done: - iocb->aiocb = NULL; - qemu_bh_schedule(iocb->bh); + nvme_do_format(iocb); } static uint16_t nvme_format_check(NvmeNamespace *ns, uint8_t lbaf, uint8_t pi) @@ -5697,16 +5709,15 @@ static uint16_t nvme_format_check(NvmeNamespace *ns, uint8_t lbaf, uint8_t pi) return NVME_SUCCESS; } -static void nvme_format_bh(void *opaque) +static void nvme_do_format(NvmeFormatAIOCB *iocb) { - NvmeFormatAIOCB *iocb = opaque; NvmeRequest *req = iocb->req; NvmeCtrl *n = nvme_ctrl(req); uint16_t status; int i; if (iocb->ret < 0) { - goto done; + goto out; } if (iocb->broadcast) { @@ -5720,26 +5731,23 @@ static void nvme_format_bh(void *opaque) } if (!iocb->ns) { - goto done; + goto out; } status = nvme_format_check(iocb->ns, iocb->lbaf, iocb->pi); if (status) { req->status = status; - goto done; + goto out; } iocb->ns->status = NVME_FORMAT_IN_PROGRESS; nvme_format_ns_cb(iocb, 0); return; -done: - qemu_bh_delete(iocb->bh); - iocb->bh = NULL; - - iocb->common.cb(iocb->common.opaque, iocb->ret); - - qemu_aio_unref(iocb); +out: + if (iocb->bh) { + qemu_bh_schedule(iocb->bh); + } } static uint16_t nvme_format(NvmeCtrl *n, NvmeRequest *req) @@ -5786,7 +5794,7 @@ static uint16_t nvme_format(NvmeCtrl *n, NvmeRequest *req) } req->aiocb = &iocb->common; - qemu_bh_schedule(iocb->bh); + nvme_do_format(iocb); return NVME_NO_COMPLETE; @@ -5794,6 +5802,7 @@ out: qemu_bh_delete(iocb->bh); iocb->bh = NULL; qemu_aio_unref(iocb); + return status; }