From nobody Sun May 19 03:12:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626035645380199.017176759451; Sun, 11 Jul 2021 13:34:05 -0700 (PDT) Received: from localhost ([::1]:38286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2g9L-0002Kc-NW for importer@patchew.org; Sun, 11 Jul 2021 16:34:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3J-0003rx-MQ; Sun, 11 Jul 2021 16:27:49 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:55651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3H-0002se-MU; Sun, 11 Jul 2021 16:27:49 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id D6D033200034; Sun, 11 Jul 2021 16:27:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 11 Jul 2021 16:27:46 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jul 2021 16:27:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=xzP35CbRRWuuo R3gzE4VsQTCJWGZJMrnrDE5SrPKt2c=; b=fsT44sRagz6IJe6yuT2O957nS/kBD L0X2UgviCbAz1vdkctdnTYBPxHkvNj4VI4863ALjSxjZfkzqNJ7SVKwPWabyJN+V KE6uk7EFCayfuzjZD4DtZGSreWEcujXUxx6xExbJeNdNWdR0zHE3p3s9ApO+ez7m nRAflslZ9kpPfH0MBGnQ4/6E4TjPhthEoTmPjl1mCdfALxM5j+T02ALIX6bDjzJI CCv5/ylG/ku5lzcUyMPeH7jjIKfRIRF2J5MTtg//E7oezqfntlmvYB/0bsQNngI+ Oo75MXfS44r/V5EIlloGHC9x6InhSw3J1MThdVI7Ce1pytuUonVclnqcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=xzP35CbRRWuuoR3gzE4VsQTCJWGZJMrnrDE5SrPKt2c=; b=Dya1vZ7o Iv+bkmVmNAVhku2Y37cyhs6yinIedK+w/7yZglOllRxN/aW8Rzc9rh9QuJ6kymnV q+6SNUCp7o0BA3kOjNmN65nTep1orVX9DBWRgTpnMi/uIX2WPKxTtadh+5brDWTd ZtxgYXGtj8aK729avlKlwS0S9psWqnMI3ZM+9RWTSw/bePNEx/3Ko0lab5h4Vn5Y MEc3xnrhRSVxLi9D2qhSBeUu848a2D3fvlI6tGy5PUU27Rk3JiOxjstOZkpYrQQk ul+yKGOzVEzEdnzVeN/3D204Zj6M+xauC96A8B38zFkkLbF5cqO8zaJZ/GWR470t KtocURH4mJWfhw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtgddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 1/6] hw/nvme: remove NvmeCtrl parameter from ns setup/check functions Date: Sun, 11 Jul 2021 22:27:31 +0200 Message-Id: <20210711202736.591334-2-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210711202736.591334-1-its@irrelevant.dk> References: <20210711202736.591334-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Jensen , Keith Busch , Hannes Reinecke , qemu-block@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626035646225100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen The nvme_ns_setup and nvme_ns_check_constraints should not depend on the controller state. Refactor and remove it. Reviewed-by: Hannes Reinecke Signed-off-by: Klaus Jensen --- hw/nvme/nvme.h | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvme/ns.c | 37 ++++++++++++++++++------------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 56f8eceed2ad..0868359a1e86 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -246,7 +246,7 @@ static inline void nvme_aor_dec_active(NvmeNamespace *n= s) } =20 void nvme_ns_init_format(NvmeNamespace *ns); -int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp); +int nvme_ns_setup(NvmeNamespace *ns, Error **errp); void nvme_ns_drain(NvmeNamespace *ns); void nvme_ns_shutdown(NvmeNamespace *ns); void nvme_ns_cleanup(NvmeNamespace *ns); diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 629b0d38c2a2..dd1801510032 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6498,7 +6498,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **= errp) ns =3D &n->namespace; ns->params.nsid =3D 1; =20 - if (nvme_ns_setup(n, ns, errp)) { + if (nvme_ns_setup(ns, errp)) { return; } =20 diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 4275c3db6301..3c4f5b8c714a 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -346,8 +346,7 @@ static void nvme_zoned_ns_shutdown(NvmeNamespace *ns) assert(ns->nr_open_zones =3D=3D 0); } =20 -static int nvme_ns_check_constraints(NvmeCtrl *n, NvmeNamespace *ns, - Error **errp) +static int nvme_ns_check_constraints(NvmeNamespace *ns, Error **errp) { if (!ns->blkconf.blk) { error_setg(errp, "block backend not configured"); @@ -366,20 +365,6 @@ static int nvme_ns_check_constraints(NvmeCtrl *n, Nvme= Namespace *ns, return -1; } =20 - if (!n->subsys) { - if (ns->params.detached) { - error_setg(errp, "detached requires that the nvme device is " - "linked to an nvme-subsys device"); - return -1; - } - - if (ns->params.shared) { - error_setg(errp, "shared requires that the nvme device is " - "linked to an nvme-subsys device"); - return -1; - } - } - if (ns->params.zoned) { if (ns->params.max_active_zones) { if (ns->params.max_open_zones > ns->params.max_active_zones) { @@ -411,9 +396,9 @@ static int nvme_ns_check_constraints(NvmeCtrl *n, NvmeN= amespace *ns, return 0; } =20 -int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) +int nvme_ns_setup(NvmeNamespace *ns, Error **errp) { - if (nvme_ns_check_constraints(n, ns, errp)) { + if (nvme_ns_check_constraints(ns, errp)) { return -1; } =20 @@ -465,7 +450,21 @@ static void nvme_ns_realize(DeviceState *dev, Error **= errp) uint32_t nsid =3D ns->params.nsid; int i; =20 - if (nvme_ns_setup(n, ns, errp)) { + if (!n->subsys) { + if (ns->params.detached) { + error_setg(errp, "detached requires that the nvme device is " + "linked to an nvme-subsys device"); + return; + } + + if (ns->params.shared) { + error_setg(errp, "shared requires that the nvme device is " + "linked to an nvme-subsys device"); + return; + } + } + + if (nvme_ns_setup(ns, errp)) { return; } =20 --=20 2.32.0 From nobody Sun May 19 03:12:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626035600297283.92255148032996; Sun, 11 Jul 2021 13:33:20 -0700 (PDT) Received: from localhost ([::1]:36956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2g8c-0001Nn-EU for importer@patchew.org; Sun, 11 Jul 2021 16:33:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3L-0003xc-RF; Sun, 11 Jul 2021 16:27:51 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:56553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3K-0002ua-Bz; Sun, 11 Jul 2021 16:27:51 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 968C03200201; Sun, 11 Jul 2021 16:27:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 11 Jul 2021 16:27:49 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jul 2021 16:27:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=h8t2938WpU3UU zpsqciYJT+0fzYoMfhS77cmgL5tVOs=; b=YSeY9IF6EyhZH00IRO9anm/7qTcoq 51Qw/Cl12xmH8RtRkQSuxvp38SIQ/CAkHVUfUFIqcD1Q2bcpIAuzlZ2N3DhMr/dR zmZWs98nEHUWpZ3h1QbCprK1A8MSTBR3IAgNw56rl90rNYi9GOxcV78sNkCeaiuI Cj6w9i3pcLLRlBVRPHMAf7ZmAWhESfwI5vJya1hd180cPrdrXmAk93ZFhxRH+xQH nsSGcIJbnhr9zqC9GTZEijD23m2s9cPwPvfictm6/sUMgX6Y6+1cfa5MwbI4vOY8 KnW2/HvONmAz0bje9ze+1pgoZNKaIbnSGlcAO/5qiFtiVxYcCLFwrvz5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=h8t2938WpU3UUzpsqciYJT+0fzYoMfhS77cmgL5tVOs=; b=ARx/OKsq NOwZJ9ZsXS2JbWDzjtTumD8g4t8goIWTKY0ieuix/5AkpoFVMUFUJ3q1ZDYshntj 4ILg6Z73K55Hw6QYDjm4GXOmh6NRwst29hkYXnoE5u0+/83cndKwc10lOQ3DqY51 kI5QwN6HMZdjg+CT+/qpPUQC8iGQ4WmqSXAARCBBuqzPYxXXB9ZWWH01hVoSSang 2vdiv5G4e9Ma03EQlbdM43VmDaLgUCKaoWxp+PGw//sNqLOGetvzJsqjTz4aX62n V583bF8S/T1XJ11GtdXbd65anpWZfvrlZ9YNDdc5w072Su0PKyWyQR2g3n3YQH/V cVemGbaVBzwHTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtgddugeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 2/6] hw/nvme: mark nvme-subsys non-hotpluggable Date: Sun, 11 Jul 2021 22:27:32 +0200 Message-Id: <20210711202736.591334-3-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210711202736.591334-1-its@irrelevant.dk> References: <20210711202736.591334-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Jensen , Keith Busch , Hannes Reinecke , qemu-block@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626035600930100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen We currently lack the infrastructure to handle subsystem hotplugging, so disable it. Reviewed-by: Hannes Reinecke Signed-off-by: Klaus Jensen --- hw/nvme/subsys.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 192223d17ca1..dc7a96862f37 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -61,6 +61,7 @@ static void nvme_subsys_class_init(ObjectClass *oc, void = *data) =20 dc->realize =3D nvme_subsys_realize; dc->desc =3D "Virtual NVMe subsystem"; + dc->hotpluggable =3D false; =20 device_class_set_props(dc, nvme_subsystem_props); } --=20 2.32.0 From nobody Sun May 19 03:12:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626036069474184.22295719116448; Sun, 11 Jul 2021 13:41:09 -0700 (PDT) Received: from localhost ([::1]:45604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gGC-0007KR-6i for importer@patchew.org; Sun, 11 Jul 2021 16:41:08 -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 1m2g3P-000459-4K; Sun, 11 Jul 2021 16:27:55 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:55129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3N-0002wi-LS; Sun, 11 Jul 2021 16:27:54 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id DCFB33200201; Sun, 11 Jul 2021 16:27:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 11 Jul 2021 16:27:52 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jul 2021 16:27:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=wG7Zr+dwuhEwF WP/4Iw9tSJ54oGJFx3b2RiKRyjEeY4=; b=lUgJKWzdc96HJfauWtje5NcXH3q1N xN+yuJNMz5zB8W1UFWgoPD6RKGAAL/fK5psOqADsUC2ZbQ2lp29ITty7yhclBezs dLXQ/aDigZ0hHTZMrpr297kdjqMy3M+bn5r0LP/OdfhIVwU0tGikWLh/kAfPeHpj 9UyLTl4pzWFo6wdozhrJU+ZkLQbnFHHXJMgtT5R2zBmREhiYq8Zi/FeGBaP7DNTv M/Q6/GOoWFKJJjQPR88Ja5W/ey1qbAimqfme3yqoV9JNkXqKVsg4zeYmhBzAMHlX El1CBew+g15nN1OZmPohqKOrXvCajR2pP3xXEZsDv7DRGcopobyIZb1Fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=wG7Zr+dwuhEwFWP/4Iw9tSJ54oGJFx3b2RiKRyjEeY4=; b=AJ6WVAi4 49qmCi/6rMQgOEQygeQ0aJMpIjz68PE9KLgTV6xiezyoKT2Ecwfmb8GrhYMBlzKF UHYASo251dHj7byUC4AnGWcVh4X8Zy8WGRh4mfX6O4KED5xZGdlO3IN0/qW79HA6 znYh+lIfRz6kxpptv+5MYgmbqlMBkW8A4aPkoyuKZXXrKJAl6RuwfrnscrAGt+wq 1eqb3lrd/HVIZoBpI+wdC3Jq5T1M5ubu6MPtqP2hfTj6LRUPUPXygYLcWv2OrEUT nV1LNVUr0TSbNzhu9+LCpPidxrrHO0mJ26LdAnWN5EijG8MpcNnNF+9G2/UVhnFm nI8GKIXmOejzzA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtgddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 3/6] hw/nvme: unregister controller with subsystem at exit Date: Sun, 11 Jul 2021 22:27:33 +0200 Message-Id: <20210711202736.591334-4-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210711202736.591334-1-its@irrelevant.dk> References: <20210711202736.591334-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Jensen , Keith Busch , Hannes Reinecke , qemu-block@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626036070521100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Make sure the controller is unregistered from the subsystem when device is removed. Reviewed-by: Hannes Reinecke Signed-off-by: Klaus Jensen --- hw/nvme/nvme.h | 1 + hw/nvme/ctrl.c | 4 ++++ hw/nvme/subsys.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 0868359a1e86..c4065467d877 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -50,6 +50,7 @@ typedef struct NvmeSubsystem { } NvmeSubsystem; =20 int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); +void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n); =20 static inline NvmeCtrl *nvme_subsys_ctrl(NvmeSubsystem *subsys, uint32_t cntlid) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index dd1801510032..90e3ee2b70ee 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6523,6 +6523,10 @@ static void nvme_exit(PCIDevice *pci_dev) nvme_ns_cleanup(ns); } =20 + if (n->subsys) { + nvme_subsys_unregister_ctrl(n->subsys, n); + } + g_free(n->cq); g_free(n->sq); g_free(n->aer_reqs); diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index dc7a96862f37..92caa604a280 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -32,6 +32,11 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) return cntlid; } =20 +void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n) +{ + subsys->ctrls[n->cntlid] =3D NULL; +} + static void nvme_subsys_setup(NvmeSubsystem *subsys) { const char *nqn =3D subsys->params.nqn ? --=20 2.32.0 From nobody Sun May 19 03:12:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16260359719531002.7304176575545; Sun, 11 Jul 2021 13:39:31 -0700 (PDT) Received: from localhost ([::1]:44190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gEb-0006Oe-Qv for importer@patchew.org; Sun, 11 Jul 2021 16:39:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3S-0004DS-Oy; Sun, 11 Jul 2021 16:27:58 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:58899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3R-0002zB-94; Sun, 11 Jul 2021 16:27:58 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 260B83200909; Sun, 11 Jul 2021 16:27:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 11 Jul 2021 16:27:55 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jul 2021 16:27:52 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=kUje2Vxop9TRc 4Lak53EzA8xgsjr/JN1irVkKwHRT88=; b=VwmfjXm95R7sV8HRJ29obqPEg0jB4 /B+sYkVxm6egh38uqEnCsTpt2H9NaldTQ7qrjRBj8fBeT+iQdEeKxrr/KUnaMIr8 3lvY4WBUMcs/XC1F66jCXPWxwoHLbEM03K1o64CdhzHOtxjOWt3il7eSQO+Aom+6 Gjsx06PqdD6T4Wjl38hM18bvVkX9wWtkPOERW/25SahDcWROVxdjQ6BauxKdTAcd pwBt2ECkRLeVxCAzSeZFcIdVVLiKoTMAb9rwpMCa9EfMngsosKEVdqjtCDTBv78C OAUa2fY6tq7qi4ow2klT6315FPKjWkpDrE5g8M5M/nVfMAf/tbRkMJycQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=kUje2Vxop9TRc4Lak53EzA8xgsjr/JN1irVkKwHRT88=; b=bGKgcavb em/OhUoRAdmaa2Dzt1x4nui90UmQsUmbLinpeG84tuSDPtE9r2BNxZenLZvj7jVu rJqU2Y+9tPL7Pe4/OifbkXWmHFYN56ILJcQfvqNDS4TcY48LH/Iv7V5tx0UX5D92 oCEBrhxIEwdCl+XGAOQcFu0aJyR5uDnPhUOsCzdTosF0M/qkbYs5F1ZY/6nF1VYK klGoUU5ZIIPd8x1ld2OtFx7sNW2EW4lTocm1/PzX4OR4aMsUzK9n2DnQqvvUfY9e FbbLUXziGL4N554N26KzGyVP2CrS57yNq8v2HWkIEkIgMFngvqDEYqLgu0sV21PK wfdPGGVYVk6xvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtgddugeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 4/6] hw/nvme: error handling for too many mappings Date: Sun, 11 Jul 2021 22:27:34 +0200 Message-Id: <20210711202736.591334-5-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210711202736.591334-1-its@irrelevant.dk> References: <20210711202736.591334-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Jensen , Keith Busch , Padmakar Kalghatgi , qemu-block@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626035974072100001 Content-Type: text/plain; charset="utf-8" From: Padmakar Kalghatgi If the number of PRP/SGL mappings exceed 1024, reads and writes will fail because of an internal QEMU limitation of max 1024 vectors. Signed-off-by: Padmakar Kalghatgi Reviewed-by: Klaus Jensen [k.jensen: changed the error message to be more generic] Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 13 +++++++++++++ hw/nvme/trace-events | 1 + 2 files changed, 14 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 90e3ee2b70ee..ead7531bde5e 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -623,6 +623,10 @@ static uint16_t nvme_map_addr(NvmeCtrl *n, NvmeSg *sg,= hwaddr addr, size_t len) return NVME_INVALID_USE_OF_CMB | NVME_DNR; } =20 + if (sg->iov.niov + 1 > IOV_MAX) { + goto max_mappings_exceeded; + } + if (cmb) { return nvme_map_addr_cmb(n, &sg->iov, addr, len); } else { @@ -634,9 +638,18 @@ static uint16_t nvme_map_addr(NvmeCtrl *n, NvmeSg *sg,= hwaddr addr, size_t len) return NVME_INVALID_USE_OF_CMB | NVME_DNR; } =20 + if (sg->qsg.nsg + 1 > IOV_MAX) { + goto max_mappings_exceeded; + } + qemu_sglist_add(&sg->qsg, addr, len); =20 return NVME_SUCCESS; + +max_mappings_exceeded: + NVME_GUEST_ERR(pci_nvme_ub_too_many_mappings, + "number of mappings exceed 1024"); + return NVME_INTERNAL_DEV_ERROR | NVME_DNR; } =20 static inline bool nvme_addr_is_dma(NvmeCtrl *n, hwaddr addr) diff --git a/hw/nvme/trace-events b/hw/nvme/trace-events index f9a1f14e2638..430eeb395b24 100644 --- a/hw/nvme/trace-events +++ b/hw/nvme/trace-events @@ -199,3 +199,4 @@ pci_nvme_ub_db_wr_invalid_cqhead(uint32_t qid, uint16_t= new_head) "completion qu pci_nvme_ub_db_wr_invalid_sq(uint32_t qid) "submission queue doorbell writ= e for nonexistent queue, sqid=3D%"PRIu32", ignoring" pci_nvme_ub_db_wr_invalid_sqtail(uint32_t qid, uint16_t new_tail) "submiss= ion queue doorbell write value beyond queue size, sqid=3D%"PRIu32", new_hea= d=3D%"PRIu16", ignoring" pci_nvme_ub_unknown_css_value(void) "unknown value in cc.css field" +pci_nvme_ub_too_many_mappings(void) "too many prp/sgl mappings" --=20 2.32.0 From nobody Sun May 19 03:12:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626036440102674.9838652725508; Sun, 11 Jul 2021 13:47:20 -0700 (PDT) Received: from localhost ([::1]:51888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gM9-0003uT-SV for importer@patchew.org; Sun, 11 Jul 2021 16:47:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3W-0004Nb-M1; Sun, 11 Jul 2021 16:28:02 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:58475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3U-00031B-Sp; Sun, 11 Jul 2021 16:28:02 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 09D5132008FA; Sun, 11 Jul 2021 16:27:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 11 Jul 2021 16:27:59 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jul 2021 16:27:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=Zu/rZACoGrJMQ vsq5CXXPNYtt/8U/uQ6Gucb6dmydZA=; b=DlW34C9OfDZZbxurt2Q4QQOwhjNcq 3pLF3xbRwb0OhBA0nNG+6GqtArDXOfdzt2H0G08H4le7CVAu/5XJPfEYIz2ohxB2 BVF0sSCk29JYS2EYP7EKzIpj80WZKAUat9PVi6AfU7q0lfaKH7PV/l0JZAYvlhW+ FvvUsz2+emJHLL27rPEed0hSnCCjIhUMdBlP4lgegzQRaCXmm0hak2A1rD4h+3JE j2cpCG1YBvvhyacDLq36apsT0JzB2y2ECKaBqtBcD4AmQ53edNFf7KsRL/ns7v0e BvVXJvgqY2tnrrGR7SwGbXuzyLpV26c4xfdQLRvxf6qHcHONFOV0+9QTA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Zu/rZACoGrJMQvsq5CXXPNYtt/8U/uQ6Gucb6dmydZA=; b=NKHGC0G+ fO3bFx/bzIngPmf7pT1x1T9+jjJ73D4d1U0KTOiLZd4kX2YMOa9tFGs3E1WItKFm Jb+s+1aff3K6oJIZqDfrdmZV0uzM9PocSqPioPi/uW+3ggv9OJ06LRjLuMoymA41 xrj+/uO0dNps1YTYA10B/9kZEXVrpwAZoSNm4ugwmG/l6oQyeSnKn58jg3GDptsu 8DEJbKcw6nNqUA6jg2q1a9Lx3WO/qh+t/sQOe0aOIla82wGQszbh33hl8wNVKEYf 2kJ4qQRx+xNT2anKVWNtZ+H7WQa8zN/hKGPuo3Dz50wn7ACj0O15sztaJxWTtLZx NRrDudNuRpik4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtgddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 5/6] tests/qtest/nvme-test: add persistent memory region test Date: Sun, 11 Jul 2021 22:27:35 +0200 Message-Id: <20210711202736.591334-6-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210711202736.591334-1-its@irrelevant.dk> References: <20210711202736.591334-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Jensen , Keith Busch , Gollu Appalanaidu , qemu-block@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626036442402100001 Content-Type: text/plain; charset="utf-8" From: Gollu Appalanaidu This will test the PMR functionality. Signed-off-by: Gollu Appalanaidu Reviewed-by: Klaus Jensen [k.jensen: replaced memory-backend-file with memory-backend-ram] Signed-off-by: Klaus Jensen --- tests/qtest/nvme-test.c | 61 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/qtest/nvme-test.c b/tests/qtest/nvme-test.c index d32c953a3824..47e757d7e2af 100644 --- a/tests/qtest/nvme-test.c +++ b/tests/qtest/nvme-test.c @@ -13,6 +13,7 @@ #include "libqos/libqtest.h" #include "libqos/qgraph.h" #include "libqos/pci.h" +#include "include/block/nvme.h" =20 typedef struct QNvme QNvme; =20 @@ -66,12 +67,65 @@ static void nvmetest_oob_cmb_test(void *obj, void *data= , QGuestAllocator *alloc) g_assert_cmpint(qpci_io_readl(pdev, bar, cmb_bar_size - 1), !=3D, 0x44= 332211); } =20 +static void nvmetest_pmr_reg_test(void *obj, void *data, QGuestAllocator *= alloc) +{ + QNvme *nvme =3D obj; + QPCIDevice *pdev =3D &nvme->dev; + QPCIBar pmr_bar, nvme_bar; + uint32_t pmrcap, pmrsts; + + qpci_device_enable(pdev); + pmr_bar =3D qpci_iomap(pdev, 4, NULL); + + /* Without Enabling PMRCTL check bar enablemet */ + qpci_io_writel(pdev, pmr_bar, 0, 0xccbbaa99); + g_assert_cmpint(qpci_io_readb(pdev, pmr_bar, 0), !=3D, 0x99); + g_assert_cmpint(qpci_io_readw(pdev, pmr_bar, 0), !=3D, 0xaa99); + + /* Map NVMe Bar Register to Enable the Mem Region */ + nvme_bar =3D qpci_iomap(pdev, 0, NULL); + + pmrcap =3D qpci_io_readl(pdev, nvme_bar, 0xe00); + g_assert_cmpint(NVME_PMRCAP_RDS(pmrcap), =3D=3D, 0x1); + g_assert_cmpint(NVME_PMRCAP_WDS(pmrcap), =3D=3D, 0x1); + g_assert_cmpint(NVME_PMRCAP_BIR(pmrcap), =3D=3D, 0x4); + g_assert_cmpint(NVME_PMRCAP_PMRWBM(pmrcap), =3D=3D, 0x2); + g_assert_cmpint(NVME_PMRCAP_CMSS(pmrcap), =3D=3D, 0x1); + + /* Enable PMRCTRL */ + qpci_io_writel(pdev, nvme_bar, 0xe04, 0x1); + + qpci_io_writel(pdev, pmr_bar, 0, 0x44332211); + g_assert_cmpint(qpci_io_readb(pdev, pmr_bar, 0), =3D=3D, 0x11); + g_assert_cmpint(qpci_io_readw(pdev, pmr_bar, 0), =3D=3D, 0x2211); + g_assert_cmpint(qpci_io_readl(pdev, pmr_bar, 0), =3D=3D, 0x44332211); + + pmrsts =3D qpci_io_readl(pdev, nvme_bar, 0xe08); + g_assert_cmpint(NVME_PMRSTS_NRDY(pmrsts), =3D=3D, 0x0); + + /* Disable PMRCTRL */ + qpci_io_writel(pdev, nvme_bar, 0xe04, 0x0); + + qpci_io_writel(pdev, pmr_bar, 0, 0x88776655); + g_assert_cmpint(qpci_io_readb(pdev, pmr_bar, 0), !=3D, 0x55); + g_assert_cmpint(qpci_io_readw(pdev, pmr_bar, 0), !=3D, 0x6655); + g_assert_cmpint(qpci_io_readl(pdev, pmr_bar, 0), !=3D, 0x88776655); + + pmrsts =3D qpci_io_readl(pdev, nvme_bar, 0xe08); + g_assert_cmpint(NVME_PMRSTS_NRDY(pmrsts), =3D=3D, 0x1); + + qpci_iounmap(pdev, nvme_bar); + qpci_iounmap(pdev, pmr_bar); +} + static void nvme_register_nodes(void) { QOSGraphEdgeOptions opts =3D { .extra_device_opts =3D "addr=3D04.0,drive=3Ddrv0,serial=3Dfoo", .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," - "file.read-zeroes=3Don,format=3Draw", + "file.read-zeroes=3Don,format=3Draw " + "-object memory-backend-ram,id=3Dpmr0," + "share=3Don,size=3D8", }; =20 add_qpci_address(&opts, &(QPCIAddress) { .devfn =3D QPCI_DEVFN(4, 0) }= ); @@ -83,6 +137,11 @@ static void nvme_register_nodes(void) qos_add_test("oob-cmb-access", "nvme", nvmetest_oob_cmb_test, &(QOSGra= phTestOptions) { .edge.extra_device_opts =3D "cmb_size_mb=3D2" }); + + qos_add_test("pmr-test-access", "nvme", nvmetest_pmr_reg_test, + &(QOSGraphTestOptions) { + .edge.extra_device_opts =3D "pmrdev=3Dpmr0" + }); } =20 libqos_init(nvme_register_nodes); --=20 2.32.0 From nobody Sun May 19 03:12:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626035972643552.629988996995; Sun, 11 Jul 2021 13:39:32 -0700 (PDT) Received: from localhost ([::1]:44256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gEd-0006R9-B6 for importer@patchew.org; Sun, 11 Jul 2021 16:39:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3a-0004YC-Tn; Sun, 11 Jul 2021 16:28:07 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:47831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2g3X-00033E-Vf; Sun, 11 Jul 2021 16:28:06 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 3B2723200201; Sun, 11 Jul 2021 16:28:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 11 Jul 2021 16:28:02 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jul 2021 16:27:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=p628K/cVIOKqD l9bgic2q9Dr8HRS2yD8wYlwNPoN++A=; b=QFlLDumfqJ0B66mSv1/nR9ptVA0X5 5fcHWRQ8o+os5KozZ92pquomuzBA/jpVPGG6fBj6b06hg0i8vEgkVybG2h55u/NR 3C2T9qDHTnewA52XJudGC3xuPOfD2VPy5GIOk27PPikvfCgianKGCiwyTyBom/Iz zZA252JZn1qpnAIfKH+h8L6srib4NQD8VNXy7zl8Rfe3pdQuV7Hsfc160aaJVYm3 u9oXF2753GCV8khfVcvdQ4f5KyHKEMImiM+/2SGCjV5xMFs5e3QSRS8DNpPzj/I4 8Io1kjTHx2j+unSY9f1LjkTQnCahjFkmSdCkkW0ftEa3jnQ7YdDPw1cew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=p628K/cVIOKqDl9bgic2q9Dr8HRS2yD8wYlwNPoN++A=; b=al9NYAp1 SRnCewv3d5J5OOtjKgWn5nqowcfYyUDJt+XzSb1A7sRpQwq96cUjkY4g4hZBvNrs Tsmqd6CyQEj9+hWXjmqQFTmtp2+UFRMZYZYmWFXJvZMa0rzTc/B3dpRh+m1V2nr2 c/CTor2Fu8f6vxf6ivhMLGKB/lYVw5R2gENbrU1gr41ohlRjjE+O2lWO8NCSBMFK bNBkwZoMeib46xc+/iaS4GtpzNY4Ee43tpPrfGCSF8xjptlaGRqVUoMgr7UkjCm7 /etPWuV7uHruwipsY4mS7ugkKa+7qlUtHS3azOLHjuAQZAU1MXNlNABB4r0BKdlH ezRrxa8TnHT82A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtgddugeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 6/6] hw/nvme: fix controller hot unplugging Date: Sun, 11 Jul 2021 22:27:36 +0200 Message-Id: <20210711202736.591334-7-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210711202736.591334-1-its@irrelevant.dk> References: <20210711202736.591334-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Jensen , Keith Busch , Hannes Reinecke , qemu-block@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626035974904100003 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Prior to this patch the nvme-ns devices are always children of the NvmeBus owned by the NvmeCtrl. This causes the namespaces to be unrealized when the parent device is removed. However, when subsystems are involved, this is not what we want since the namespaces may be attached to other controllers as well. This patch adds an additional NvmeBus on the subsystem device. When nvme-ns devices are realized, if the parent controller device is linked to a subsystem, the parent bus is set to the subsystem one instead. This makes sure that namespaces are kept alive and not unrealized. Reviewed-by: Hannes Reinecke Signed-off-by: Klaus Jensen --- hw/nvme/nvme.h | 15 ++++++++------- hw/nvme/ctrl.c | 14 ++++++-------- hw/nvme/ns.c | 18 ++++++++++++++++++ hw/nvme/subsys.c | 3 +++ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index c4065467d877..83ffabade4cf 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -33,12 +33,20 @@ QEMU_BUILD_BUG_ON(NVME_MAX_NAMESPACES > NVME_NSID_BROAD= CAST - 1); typedef struct NvmeCtrl NvmeCtrl; typedef struct NvmeNamespace NvmeNamespace; =20 +#define TYPE_NVME_BUS "nvme-bus" +OBJECT_DECLARE_SIMPLE_TYPE(NvmeBus, NVME_BUS) + +typedef struct NvmeBus { + BusState parent_bus; +} NvmeBus; + #define TYPE_NVME_SUBSYS "nvme-subsys" #define NVME_SUBSYS(obj) \ OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS) =20 typedef struct NvmeSubsystem { DeviceState parent_obj; + NvmeBus bus; uint8_t subnqn[256]; =20 NvmeCtrl *ctrls[NVME_MAX_CONTROLLERS]; @@ -365,13 +373,6 @@ typedef struct NvmeCQueue { QTAILQ_HEAD(, NvmeRequest) req_list; } NvmeCQueue; =20 -#define TYPE_NVME_BUS "nvme-bus" -#define NVME_BUS(obj) OBJECT_CHECK(NvmeBus, (obj), TYPE_NVME_BUS) - -typedef struct NvmeBus { - BusState parent_bus; -} NvmeBus; - #define TYPE_NVME "nvme" #define NVME(obj) \ OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index ead7531bde5e..2f0524e12a36 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6527,16 +6527,14 @@ static void nvme_exit(PCIDevice *pci_dev) =20 nvme_ctrl_reset(n); =20 - for (i =3D 1; i <=3D NVME_MAX_NAMESPACES; i++) { - ns =3D nvme_ns(n, i); - if (!ns) { - continue; + if (n->subsys) { + for (i =3D 1; i <=3D NVME_MAX_NAMESPACES; i++) { + ns =3D nvme_ns(n, i); + if (ns) { + ns->attached--; + } } =20 - nvme_ns_cleanup(ns); - } - - if (n->subsys) { nvme_subsys_unregister_ctrl(n->subsys, n); } =20 diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 3c4f5b8c714a..b7cf1494e75b 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -441,6 +441,15 @@ void nvme_ns_cleanup(NvmeNamespace *ns) } } =20 +static void nvme_ns_unrealize(DeviceState *dev) +{ + NvmeNamespace *ns =3D NVME_NS(dev); + + nvme_ns_drain(ns); + nvme_ns_shutdown(ns); + nvme_ns_cleanup(ns); +} + static void nvme_ns_realize(DeviceState *dev, Error **errp) { NvmeNamespace *ns =3D NVME_NS(dev); @@ -462,6 +471,14 @@ static void nvme_ns_realize(DeviceState *dev, Error **= errp) "linked to an nvme-subsys device"); return; } + } else { + /* + * If this namespace belongs to a subsystem (through a link on the + * controller device), reparent the device. + */ + if (!qdev_set_parent_bus(dev, &subsys->bus.parent_bus, errp)) { + return; + } } =20 if (nvme_ns_setup(ns, errp)) { @@ -552,6 +569,7 @@ static void nvme_ns_class_init(ObjectClass *oc, void *d= ata) =20 dc->bus_type =3D TYPE_NVME_BUS; dc->realize =3D nvme_ns_realize; + dc->unrealize =3D nvme_ns_unrealize; device_class_set_props(dc, nvme_ns_props); dc->desc =3D "Virtual NVMe namespace"; } diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 92caa604a280..93c35950d69d 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -50,6 +50,9 @@ static void nvme_subsys_realize(DeviceState *dev, Error *= *errp) { NvmeSubsystem *subsys =3D NVME_SUBSYS(dev); =20 + qbus_create_inplace(&subsys->bus, sizeof(NvmeBus), TYPE_NVME_BUS, dev, + dev->id); + nvme_subsys_setup(subsys); } =20 --=20 2.32.0