From nobody Fri Apr 4 05:05:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1740648756; cv=none; d=zohomail.com; s=zohoarc; b=XIIzseBgSD2VeuM8bDRBDv0AVAGZE7sSu+jnJ02TQvVdQsagokD+clYproEdNArwztQLwlTbySejK4J6ves7HrKN5ja1ZAIie+r1FEgdLejOOfNvfaBdI1FVssZ4WkwOYer/8xEK2pLIc13pgIrG8qpeTbB0um5mRWHFO2zVzSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740648756; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dZuF08uJ1a3asratCM7/aWSmjseMjsdnXiaM51iax7c=; b=dX40peXR9YU/ZW1fNZ8DKSgp3TKViLYwxJayvIsCCtzFH6S5G3wj9SL46cmoxYqfEAm/fqgVAFv6EKgU6ACRaWHqNBsDpCXufMtqn8ssBtCJy+686NwsjgrDoGID9Ufjxp8HiGjtheH5P3jR/nbjFb72C6cXFScbJTdaRpVButk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1740648756421530.4356676105737; Thu, 27 Feb 2025 01:32:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnaEN-0008KQ-7o; Thu, 27 Feb 2025 04:31:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnaEA-000836-AK; Thu, 27 Feb 2025 04:30:48 -0500 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnaE2-0008IR-FY; Thu, 27 Feb 2025 04:30:40 -0500 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 7F17D1140BC5; Thu, 27 Feb 2025 04:30:37 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Thu, 27 Feb 2025 04:30:37 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Feb 2025 04:30:35 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1740648637; x= 1740735037; bh=dZuF08uJ1a3asratCM7/aWSmjseMjsdnXiaM51iax7c=; b=a +setTad8dwBoTL3q7bqaxDl4T9l+wkl/JiqX3XLNKAn2FAGc1Rxqf972e0e/RKNB aSQnrId4Q5Ao6hlgoGUD0fBBKnUWfKiC+PP1gn1UF8ScPA1Mp1IkmD2PnHXJIT2N lZTp2LK402icLqGkTPerIPQX9fqKiDJk4dgcHFjy8y6XUOPhVxMRLmgPE1jnADoc OSRVTxirM+iEnMIDl005kghQxppe4xbmZTb5EL+q5Hm+JdKnWvQlKDHG2qbgxsjl 2QnT/OJyDAlGOCAbSsxYKATYRAAPxZoEBxPb19IbgSYR83I5Wi9ngYVXDtIQ89f4 +LU/NP0KqV0MzQiPNIBwg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1740648637; x=1740735037; bh=d ZuF08uJ1a3asratCM7/aWSmjseMjsdnXiaM51iax7c=; b=1HWJQODbtZpGuCLGJ /ihDO+wJ7ZzkY8/bIy3EHTkpmU/4Vkc4R6uVSreq6F841BKkgSirL5G5qyMvO6vl b+Wl9pw2Ia8jOw8+tcaiCPxEoekTcfBo0GC+enbolyXM5zew3Pmlxv5URhFhmtm5 2hFOVzbLfH8GWV0ID65ikcWXd5AYSTSv1dWIhRD4fMa8HSBNfPNa7fkzWOyXOfuM oMyR2df3Yb5bGw2/+exd6oPUHq2g1kcjxgi7DBKDjmYH3k7uTaeoJNgRk2MxlQVz OmWioyZYie5AoO8h1jx9YZy1i2+LR2pAKj3ynZ3aOhB3uhwdmquk1Gxmzkq7wF5f f6QVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekjeduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpefmlhgruhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnth drughkqeenucggtffrrghtthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefg heefgfejjeehffefgedujedugeenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmh epmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughkpdhnsggprhgtphht thhopeduvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepqhgvmhhuqdguvghvvg hlsehnohhnghhnuhdrohhrghdprhgtphhtthhopehpvghtvghrrdhmrgihuggvlhhlsehl ihhnrghrohdrohhrghdprhgtphhtthhopehkrdhjvghnshgvnhesshgrmhhsuhhnghdrtg homhdprhgtphhtthhopehfohhsshesuggvfhhmrggtrhhordhithdprhgtphhtthhopehk sghushgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepihhtshesihhrrhgvlhgvvh grnhhtrdgukhdprhgtphhtthhopehsthgvfhgrnhhhrgesrhgvughhrghtrdgtohhmpdhr tghpthhtohepfhgrmhesvghuphhhohhnrdhnvghtpdhrtghpthhtohepphhhihhlmhguse hlihhnrghrohdrohhrgh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: qemu-devel@nongnu.org Cc: Peter Maydell , Klaus Jensen , Jesper Wendel Devantier , Keith Busch , Klaus Jensen , Stefan Hajnoczi , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 06/10] hw/nvme: be compliant wrt. dsm processing limits Date: Thu, 27 Feb 2025 10:30:13 +0100 Message-ID: <20250227093018.11262-7-its@irrelevant.dk> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250227093018.11262-1-its@irrelevant.dk> References: <20250227093018.11262-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=103.168.172.152; envelope-from=its@irrelevant.dk; helo=fhigh-a1-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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1740648758647019100 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen The specification states that, > The controller shall set all three processing limit fields (i.e., the > DMRL, DMRSL and DMSL fields) to non-zero values or shall clear all > three processing limit fields to 0h. So, set the DMRL and DMSL fields in addition to DMRSL. Reviewed-by: Jesper Wendel Devantier Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 24 +++++++++++++++--------- include/block/nvme.h | 2 ++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 2b73f601608f..86e1c48fab82 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5639,7 +5639,9 @@ static uint16_t nvme_identify_ctrl_csi(NvmeCtrl *n, N= vmeRequest *req) switch (c->csi) { case NVME_CSI_NVM: id_nvm->vsl =3D n->params.vsl; + id_nvm->dmrl =3D NVME_ID_CTRL_NVM_DMRL_MAX; id_nvm->dmrsl =3D cpu_to_le32(n->dmrsl); + id_nvm->dmsl =3D NVME_ID_CTRL_NVM_DMRL_MAX * n->dmrsl; break; =20 case NVME_CSI_ZONED: @@ -6696,18 +6698,23 @@ static uint16_t nvme_aer(NvmeCtrl *n, NvmeRequest *= req) return NVME_NO_COMPLETE; } =20 -static void nvme_update_dmrsl(NvmeCtrl *n) +static void nvme_update_dsm_limits(NvmeCtrl *n, NvmeNamespace *ns) { - int nsid; + if (ns) { + n->dmrsl =3D + MIN_NON_ZERO(n->dmrsl, BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1= )); =20 - for (nsid =3D 1; nsid <=3D NVME_MAX_NAMESPACES; nsid++) { - NvmeNamespace *ns =3D nvme_ns(n, nsid); + return; + } + + for (uint32_t nsid =3D 1; nsid <=3D NVME_MAX_NAMESPACES; nsid++) { + ns =3D nvme_ns(n, nsid); if (!ns) { continue; } =20 - n->dmrsl =3D MIN_NON_ZERO(n->dmrsl, - BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1)); + n->dmrsl =3D + MIN_NON_ZERO(n->dmrsl, BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1= )); } } =20 @@ -6795,7 +6802,7 @@ static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeR= equest *req) ctrl->namespaces[nsid] =3D NULL; ns->attached--; =20 - nvme_update_dmrsl(ctrl); + nvme_update_dsm_limits(ctrl, NULL); =20 break; =20 @@ -8902,8 +8909,7 @@ void nvme_attach_ns(NvmeCtrl *n, NvmeNamespace *ns) n->namespaces[nsid] =3D ns; ns->attached++; =20 - n->dmrsl =3D MIN_NON_ZERO(n->dmrsl, - BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1)); + nvme_update_dsm_limits(n, ns); } =20 static void nvme_realize(PCIDevice *pci_dev, Error **errp) diff --git a/include/block/nvme.h b/include/block/nvme.h index aecfc9ce66b4..763b2b2f0ec7 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1207,6 +1207,8 @@ typedef struct NvmeIdCtrlZoned { uint8_t rsvd1[4095]; } NvmeIdCtrlZoned; =20 +#define NVME_ID_CTRL_NVM_DMRL_MAX 255 + typedef struct NvmeIdCtrlNvm { uint8_t vsl; uint8_t wzsl; --=20 2.47.2