From nobody Mon Feb 9 12:09:26 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1615371464; cv=none; d=zohomail.com; s=zohoarc; b=kv5ttonTX552AV0dE0eZpk7zhboJq57wczaqsQ/BAjfYPo+enWeoFkY7hXVK6mNFFSy2wjCKu+sJuV+Gvig6xTiLcDiqDwxtsQLU20+mMetnUuYQnWmkwhkL9XzLINqfI0fV4fxVWDJYt6MaA6t3rHntWGKvfmvH/A4/QydDMNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615371464; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i40kluUep3MRgyO0mjv2mKZ0t1c6G7kMDepxeE8+Bu4=; b=imtfBCwgs3I1eo/efDcjDwrcxvcNKbQ5N3CsUncKl+9aadpAjtFsmAkhGDnxoDQrHEXbWw7WcuQuQcJIr2uUqal9jEeXqrYNjTUTUjJH8hEpP0bvYNMQRKALP5jnwN/oVllJXB0nq74XFIc3jPh0Jc4hj1nIfzk8nIPKOj3tp/s= ARC-Authentication-Results: i=1; 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 1615371464659746.9592100222894; Wed, 10 Mar 2021 02:17:44 -0800 (PST) Received: from localhost ([::1]:53958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJvuR-0003zZ-Gy for importer@patchew.org; Wed, 10 Mar 2021 05:17:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvXZ-0007av-5G; Wed, 10 Mar 2021 04:54:05 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:42233) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvXW-00059Z-4L; Wed, 10 Mar 2021 04:54:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5039B5C0143; Wed, 10 Mar 2021 04:54:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 10 Mar 2021 04:54:01 -0500 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id E662724005E; Wed, 10 Mar 2021 04:53:59 -0500 (EST) 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=fm2; bh=i40kluUep3MRg yO0mjv2mKZ0t1c6G7kMDepxeE8+Bu4=; b=pVlH9Jcc1oL0X+kOWGwPCHzlpPlCK Rmt/qgk7de5Hr/NHyyIgVrj2nUjF3Mexi11wtBygNbHyPHFtfktTD9BhpZB0lCkC MEWSGZfO1raesAVvSCs5WcnuDlxmHA2PWQt6f0co6TPx3bK8p91WM4PiYed9Nt5Y ml99rp6FsSSHLp9aCsZtR1aR2HoutIF0FdIF6plO84kFelW7NtqsKx0EwDTnD6Dm Eo2uz+fX8MenoCL0ikCUDavGXByqnivpSDLuRgfyu74zrFHOr2mQAx4+iavi06q1 TAPTfZDonMIbbgwg79wsFWKxYvtD3YfEgmNbgDzHKTCdrOsZZnDEmcDDg== 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= fm2; bh=i40kluUep3MRgyO0mjv2mKZ0t1c6G7kMDepxeE8+Bu4=; b=cEenBf7j Qkot8pV6ysFcjtplLLEwkWZ857+/sX1I6p8ILl++OhhmXXVePBwPMs8ZxlZCgJPL AkJq5DjGnt73SBcDvIwn0Z7ZKN+ZxPTFBEU2dHcImLSPGADqb0w24bYN0ursv+n1 4fb2Xtlu1rInmCvZ1/h8WakL+7Q9bMKI47Q6ifot0QbVRHV8odQT1ihaR1oauond kvknFLUD/rD8VOnG2Nin4nSBSa3fSpakO8KlhOpMwle87MqWQroWaIHQDwNE1JZX RIVBwEqGrPAy8whv0ZLTOaGa+IeiP8zRk3Mp30+fiR2OoQcgv2hbqXlb73w0eZnd SWKcmfjbaIEdwg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpeegne curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH v5 07/13] hw/block/nvme: prefer runtime helpers instead of device parameters Date: Wed, 10 Mar 2021 10:53:41 +0100 Message-Id: <20210310095347.682395-8-its@irrelevant.dk> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310095347.682395-1-its@irrelevant.dk> References: <20210310095347.682395-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=66.111.4.29; envelope-from=its@irrelevant.dk; helo=out5-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_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Gollu Appalanaidu , Max Reitz , Keith Busch , Stefan Hajnoczi , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen In preparation for Format NVM support, use runtime helpers instead of the constant device parameters when getting lba size information etc. Signed-off-by: Klaus Jensen Reviewed-by: Minwoo Im --- hw/block/nvme-ns.h | 2 +- hw/block/nvme-ns.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h index e2f53d999699..07e16880801d 100644 --- a/hw/block/nvme-ns.h +++ b/hw/block/nvme-ns.h @@ -138,7 +138,7 @@ static inline bool nvme_ns_ext(NvmeNamespace *ns) /* calculate the number of LBAs that the namespace can accomodate */ static inline uint64_t nvme_ns_nlbas(NvmeNamespace *ns) { - if (ns->params.ms) { + if (nvme_msize(ns)) { return ns->size / (nvme_lsize(ns) + nvme_msize(ns)); } return ns->size >> nvme_ns_lbads(ns); diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index 00e8f6af2162..7e3cba55e4db 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -110,11 +110,11 @@ lbaf_found: /* support DULBE and I/O optimization fields */ id_ns->nsfeat |=3D (0x4 | 0x10); =20 - npdg =3D ns->blkconf.discard_granularity / ns->blkconf.logical_block_s= ize; + npdg =3D ns->blkconf.discard_granularity / nvme_lsize(ns); =20 if (bdrv_get_info(blk_bs(ns->blkconf.blk), &bdi) >=3D 0 && bdi.cluster_size > ns->blkconf.discard_granularity) { - npdg =3D bdi.cluster_size / ns->blkconf.logical_block_size; + npdg =3D bdi.cluster_size / nvme_lsize(ns); } =20 id_ns->npda =3D id_ns->npdg =3D npdg - 1; @@ -161,7 +161,7 @@ static int nvme_ns_init_blk(NvmeNamespace *ns, Error **= errp) static int nvme_ns_zoned_check_calc_geometry(NvmeNamespace *ns, Error **er= rp) { uint64_t zone_size, zone_cap; - uint32_t lbasz =3D ns->blkconf.logical_block_size; + uint32_t lbasz =3D nvme_lsize(ns); =20 /* Make sure that the values of ZNS properties are sane */ if (ns->params.zone_size_bs) { --=20 2.30.1