From nobody Sun Nov 24 09:28:50 2024 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; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1725881843; cv=none; d=zohomail.com; s=zohoarc; b=bbY7dD6lu2+mFFmssZJml/w2AiF5ZMOHj6f/n0dHho+oIG+yDr3eWiVMr/qKmzkvOyoSfnJ/e2/LxU0QOwi6rkwaYao+MxCuGfGNYXvTNfTyEpxPeBUlNhbjchRHF966IDCBoQU6yP+ZRXOALUe85E0XD6Rsx2Yi637ahdIqtwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725881843; 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=FpXCvHD2Qslc03OqNFilh7DiBfbBLmsoxBWva+ViCzE=; b=G3NApDA9dVGkJD9HYGcYn/A9slyANAQD7YeIQ1+kODG56lbpaltQ4ktAr+Cg2Ne3YZKLvc3G+FkDoxfh97rkJuz8cmeuw8M4yNCQQzQnKkFXcN1opNTHFEPEaCZhRVwIHwn94uxgKJJq+dAq4SOWTvOKim9lDumzfs094pLtUmQ= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725881843288866.1361212442552; Mon, 9 Sep 2024 04:37:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sncgU-000318-2M; Mon, 09 Sep 2024 07:35:54 -0400 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 1sncgP-0002r6-2R for qemu-devel@nongnu.org; Mon, 09 Sep 2024 07:35:49 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sncgK-00016q-NA for qemu-devel@nongnu.org; Mon, 09 Sep 2024 07:35:47 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1fc47abc040so36344005ad.0 for ; Mon, 09 Sep 2024 04:35:43 -0700 (PDT) Received: from TF4D9JK212.bytedance.net ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710e328aasm32378605ad.91.2024.09.09.04.35.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Sep 2024 04:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1725881743; x=1726486543; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FpXCvHD2Qslc03OqNFilh7DiBfbBLmsoxBWva+ViCzE=; b=VF0/IqaUDemtooYWUYP/hjmgI1bJ78jsmOVUuVbzPHxTvQldMbvP/Cb86oVYM7HC1f LlcLaVHDRJVf7TEK+uQ7cJEzcfvRj7zOlpMmpyftXs4J77NtfBZMOTqaWz6qhxMtsR3m 7w8EaUnn2iSghPZeh2hKJNGLvN3/8bJZMyvMJbhBfkHedgnIeEN+B1znt1Zn1hCw7n6c ToD12Zym4ihKw/qWw0UsACTisBARpHvy7MEwF2GfW1qqIWVx0p+aV7TTiX7OKF5EdT8j bomZV9vxHfpLWIRD7kz7/lYou9Ld7DMyBN0sjfQlfUwJ0FHuig8JcFf9AZMiV2oTJbkT w9jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725881743; x=1726486543; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FpXCvHD2Qslc03OqNFilh7DiBfbBLmsoxBWva+ViCzE=; b=m7wMIPplxRsnlkW/Etf8FA/Fz/DYhElXfMBvgnWvyarfFjKnsku9zTodj1Fbj1+13+ H4yk0Vs0j1IQIE1O/CXULP4sPOYGYIYo64aDg5SJW6aln9fYpGixwKuDz5hOigfbG/WF OaK22I5Y82pLtXaEEpFJUM1Gr963A5q3B5zanCHxPoiux6R5bEHBpL6nfSl+u3I4hBC7 WE0UIlQfbv6yW4X+ZVoR3z42xGI62hVEtE63mMmx+00rZsTmXFvtmRjR1BpUDsxIJxbD +LQlgurc1/BmAQVGbGM5Ac+MT8sLVeLi4pLER/4iWzmnZaGVz3l9JNP5umYMSDafSEfX Dp4A== X-Forwarded-Encrypted: i=1; AJvYcCV5o4l73K+/Dx0cLs9S4yMwRtJQymMc+3UHHs1AqwE7oYeSnodgJO82ylMq6l9WhQjwzSnFVXULlXZg@nongnu.org X-Gm-Message-State: AOJu0Yymn/THDgajBaM7pG6WyZpxdSK8L9HFUhg0tuXksTaFIqXbRkjx 8+zo/+TdOqYZv6dwNWx9l5V22GexbCvUy5GbcEpuPID6GR9oQwetfxKdTnARuG0= X-Google-Smtp-Source: AGHT+IFsDCJJHK01GE/1dMRpO9kWa1a6uXU6mLFrXIuL7Qa63eUFTYqP2RCqTYpQJv/1L8KuWRrBKA== X-Received: by 2002:a17:902:e5d0:b0:205:5bc9:37fb with SMTP id d9443c01a7336-2070c200f88mr101006355ad.61.1725881742965; Mon, 09 Sep 2024 04:35:42 -0700 (PDT) From: Changqi Lu To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: kwolf@redhat.com, hreitz@redhat.com, stefanha@redhat.com, fam@euphon.net, ronniesahlberg@gmail.com, pbonzini@redhat.com, pl@dlhnet.de, kbusch@kernel.org, its@irrelevant.dk, foss@defmacro.it, philmd@linaro.org, pizhenwei@bytedance.com, k.jensen@samsung.com, Changqi Lu Subject: [PATCH v11 08/10] hw/nvme: enable ONCS and rescap function Date: Mon, 9 Sep 2024 19:34:51 +0800 Message-Id: <20240909113453.64527-9-luchangqi.123@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240909113453.64527-1-luchangqi.123@bytedance.com> References: <20240909113453.64527-1-luchangqi.123@bytedance.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=2607:f8b0:4864:20::630; envelope-from=luchangqi.123@bytedance.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=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 @bytedance.com) X-ZM-MESSAGEID: 1725881844901116600 Content-Type: text/plain; charset="utf-8" This commit enables ONCS to support the reservation function at the controller level. Also enables rescap function in the namespace by detecting the supported reservation function in the backend driver. Reviewed-by: Klaus Jensen Signed-off-by: Changqi Lu Signed-off-by: zhenwei pi Reviewed-by: Stefan Hajnoczi --- hw/nvme/ctrl.c | 3 ++- hw/nvme/ns.c | 5 +++++ include/block/nvme.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 127c3d2383..ad212de723 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8248,7 +8248,8 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pc= i_dev) id->nn =3D cpu_to_le32(NVME_MAX_NAMESPACES); id->oncs =3D cpu_to_le16(NVME_ONCS_WRITE_ZEROES | NVME_ONCS_TIMESTAMP | NVME_ONCS_FEATURES | NVME_ONCS_DSM | - NVME_ONCS_COMPARE | NVME_ONCS_COPY); + NVME_ONCS_COMPARE | NVME_ONCS_COPY | + NVME_ONCS_RESERVATIONS); =20 /* * NOTE: If this device ever supports a command set that does NOT use = 0x0 diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index ea8db175db..a5c903d727 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -20,6 +20,7 @@ #include "qemu/bitops.h" #include "sysemu/sysemu.h" #include "sysemu/block-backend.h" +#include "block/block_int.h" =20 #include "nvme.h" #include "trace.h" @@ -33,6 +34,7 @@ void nvme_ns_init_format(NvmeNamespace *ns) BlockDriverInfo bdi; int npdg, ret; int64_t nlbas; + uint8_t blk_pr_cap; =20 ns->lbaf =3D id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(id_ns->flbas)]; ns->lbasz =3D 1 << ns->lbaf.ds; @@ -55,6 +57,9 @@ void nvme_ns_init_format(NvmeNamespace *ns) } =20 id_ns->npda =3D id_ns->npdg =3D npdg - 1; + + blk_pr_cap =3D blk_bs(ns->blkconf.blk)->bl.pr_cap; + id_ns->rescap =3D block_pr_cap_to_nvme(blk_pr_cap); } =20 static int nvme_ns_init(NvmeNamespace *ns, Error **errp) diff --git a/include/block/nvme.h b/include/block/nvme.h index 8b125f7769..9b9eaeb3a7 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1251,7 +1251,7 @@ enum NvmeIdCtrlOncs { NVME_ONCS_DSM =3D 1 << 2, NVME_ONCS_WRITE_ZEROES =3D 1 << 3, NVME_ONCS_FEATURES =3D 1 << 4, - NVME_ONCS_RESRVATIONS =3D 1 << 5, + NVME_ONCS_RESERVATIONS =3D 1 << 5, NVME_ONCS_TIMESTAMP =3D 1 << 6, NVME_ONCS_VERIFY =3D 1 << 7, NVME_ONCS_COPY =3D 1 << 8, --=20 2.20.1