From nobody Tue Feb 10 06:26:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.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; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1600885713; cv=none; d=zohomail.com; s=zohoarc; b=TweXbd15mItXfWrfgaAsjye9+mQJgX52vfGcCYj0F2sBl0jtjxMJ4uveX/Wvc/zoPV0kC0k0hOCrRVRw8qD5UhupyCdBY7x/qqMKA/pL0vW9r29a9aC9E0N54sfnTkTKOSYONvSkUBiMallyUc3JzUoCOQGol4EziQfjS+fJThU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600885713; 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=UKFjCmB1+RKLT3BiI4n0OhHIhB+1xXyaWbJ52LWZt5E=; b=f2lxfOMeYfIREzZOuDSJu26rNHAWQifxKhxKWnPV/QF3O2VeuwD44AidFaYWdJGlczhSV8/U2w5RZQI+1r8aYHIFbnhXR6On3eIG2hZkFgISk7qMcMt4HDAMEsXPIV6RoaXzJN5u7vNphlsAmBxOEMGYvZT1hAIVeInm1NTxmVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600885713720785.8386983074739; Wed, 23 Sep 2020 11:28:33 -0700 (PDT) Received: from localhost ([::1]:45280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kL9VI-00032i-Ae for importer@patchew.org; Wed, 23 Sep 2020 14:28:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kL9Nx-0004w8-7i; Wed, 23 Sep 2020 14:20:58 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:35018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kL9Nt-00087W-LT; Wed, 23 Sep 2020 14:20:56 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Sep 2020 02:36:11 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2020 11:06:56 -0700 Received: from unknown (HELO redsun50.ssa.fujisawa.hgst.com) ([10.149.66.24]) by uls-op-cesaip02.wdc.com with ESMTP; 23 Sep 2020 11:20:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1600886176; x=1632422176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BYQ28XH8Ylx9Dq0KVPfvBpBWZp+s9KZQXJ7UPhfutPQ=; b=bT90MOzqUNHAZGkkWF0Xl4HYDE9tQLrAXqvPHUeOyyFCf+Em/jmvgicZ lPiWMwNZHxTKOWLsXYPEJdUkJHu+jy3DlUJOFNQq84kxg7KFxc8F5v0ef PkVwhXLbdOVC6EfAFnANTVyfVsGXDzcGsScl+9K1MFfv6XzCl1wKKZGgB B2ioBzuwMmZ5pH1eaCEATgry3gqSlBnvyp+h0XngegJ3+li6Kk+piMcKa 8q04YugtseRJ1lFvERQInVKHQwNdKsVeM9OG5erPUWbUouUyDAGtz0+iv HdccHdp42pzNvxT2ZZsyREarbqEp3vUpAoMHsZs3w7ltf+eCoVc6ReCD0 w==; IronPort-SDR: TiHUSmltTziy/7j1qOPpkAix79fxamHQUCgQF4kACKxjKT0mlgaBXLJk3b+JXzajEaySOUHTwP GhGIOhqKmaWchZs9nKR9HI2Of3X8XiCCF64VaTJj1BHMf46cohUYZk6PHlpG8DXXj+Zk3oZilO RK3xmUiL995Yd+9AeRgJGFD3jsP/LbPcd+M2rKdcHfsQ/XROgwRQC63jJeKQh/0QfahuREuZQw eZsDD9FFZhXKxgMc8NjqDdCgMHDYPYcWaK4u7WQZnRgWRObnZkmgmBjp4ynvw018Sx4LRMFpAn K0k= X-IronPort-AV: E=Sophos;i="5.77,293,1596470400"; d="scan'208";a="251496337" IronPort-SDR: C3iNJLdz73zPLik5kncSLPqdYqBl1uAQn3rzY4++wryxDVv6XMQAO4MedtATsxg/vo6TpXU86H WW3MBRqfyXpg== IronPort-SDR: C98WqivzRrZP8+CiQ9nZMdxF9CZO784NGohbNFFi1Zjh/3QAQfW/U9nFkBvL+8ZjaLrAd8G2di 3UcBUV2H1yuQ== WDCIronportException: Internal From: Dmitry Fomichev To: Keith Busch , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Maxim Levitsky , Fam Zheng Subject: [PATCH v4 01/14] hw/block/nvme: Report actual LBA data shift in LBAF Date: Thu, 24 Sep 2020 03:20:08 +0900 Message-Id: <20200923182021.3724-2-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200923182021.3724-1-dmitry.fomichev@wdc.com> References: <20200923182021.3724-1-dmitry.fomichev@wdc.com> 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=68.232.143.124; envelope-from=prvs=5287de305=dmitry.fomichev@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/23 14:20:48 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: Niklas Cassel , Damien Le Moal , qemu-block@nongnu.org, Dmitry Fomichev , qemu-devel@nongnu.org, Alistair Francis , Matias Bjorling Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Signature date is more than 7 minutes in the future.) Content-Type: text/plain; charset="utf-8" Calculate the data shift value to report based on the set value of logical_block_size device property. In the process, use a local variable to calculate the LBA format index instead of the hardcoded value 0. This makes the code more readable and it will make it easier to add support for multiple LBA formats in the future. Signed-off-by: Dmitry Fomichev Reviewed-by: Klaus Jensen --- hw/block/nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 63078f6009..f60e968c4a 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -2203,6 +2203,7 @@ static void nvme_init_namespace(NvmeCtrl *n, NvmeName= space *ns, Error **errp) { int64_t bs_size; NvmeIdNs *id_ns =3D &ns->id_ns; + int lba_index; =20 bs_size =3D blk_getlength(n->conf.blk); if (bs_size < 0) { @@ -2212,7 +2213,8 @@ static void nvme_init_namespace(NvmeCtrl *n, NvmeName= space *ns, Error **errp) =20 n->ns_size =3D bs_size; =20 - id_ns->lbaf[0].ds =3D BDRV_SECTOR_BITS; + lba_index =3D NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); + id_ns->lbaf[lba_index].ds =3D 31 - clz32(n->conf.logical_block_size); id_ns->nsze =3D cpu_to_le64(nvme_ns_nlbas(n, ns)); =20 /* no thin provisioning */ --=20 2.21.0