From patchwork Fri Jul 12 02:36:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changqi Lu X-Patchwork-Id: 1959662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Oj2IMflT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WKwm30nWcz1xqj for ; Fri, 12 Jul 2024 12:39:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sS6AV-0005GA-RJ; Thu, 11 Jul 2024 22:37:55 -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 1sS6AS-00052O-4N for qemu-devel@nongnu.org; Thu, 11 Jul 2024 22:37:52 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sS6AQ-0003TO-1J for qemu-devel@nongnu.org; Thu, 11 Jul 2024 22:37:51 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2c98db7a10cso1185127a91.3 for ; Thu, 11 Jul 2024 19:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1720751868; x=1721356668; 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=Oj2IMflTTQ9DAHyIzQGZyWspe4fs8o+QGMPpah4xOBBBaK3RdwF2DhtKvcMedktwWQ QzlRXD8Dcc12L1+uBYR6bMiMEPrHi4bNyxVgAQQXkRoIh0wAhworVK8clfdyValOuQbh uJUxe4ktPU081UPvAC7792cRMCYaeXYoq/H/8QVyJPQPFmSB8dqYZpWPWBdAVo4nL3fV UqYtmzSvFyOYHfx/NrGGUKpIX3L7crn19B23HFpuXFZRFyX0JG7pGnitGUNxo/Pv+mrD 1aPFkpE8kYboQ50hDzqimE8SLYKkPyM5YSilWufC/aTK+ZDpLZg7yK02JwXHoORVNeqN SsMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720751868; x=1721356668; 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=SChi3wblsc4WRo9UvnYdbtWm96nmDXhc/JVcW+W03hsh65K/tSwcHztxzLoYWQdRSY NCd96R5DjAVkIqDoGfCkc+kMzu7UR5RSXOj32r8BeqvrAXxNSAu+cEHEleNYna0d3Q2U FR8Xn6Ag4bKalZxKyUjLF7nQQubvJCnTX6a30oFOg/Hc1q51yIY2AHxCe0JI5xbon8sC odg+Hzy5GofuUNnCQGoLa0J8yZG44Ey/nw12UePk7qV0++T5OrVJNwmciepBeWvIiugs FeV611AlRlzilRuiIWIZvy14i8cBTx4I+imCxizCqIfb9UyoWs2A+zrCj9AolIPu2fOG Gd2Q== X-Forwarded-Encrypted: i=1; AJvYcCX5SZp5mh6tO2tUUNd1TetB9ZmWS/gveb4itTAp8ZMRzOg31uNI84WaHOyEnJ9efV7LloclI3CS7uJRT/cffhZRQx2FO+E= X-Gm-Message-State: AOJu0YytWRhU4aKOWMU3gSDT8zS7k6VvgsNyHzW7EkyynrtUwe4DVyYA +Vn5KiFqvaG4F8Zduy/hwyAK//3rcE81p7i7URr1mZO+sA9ssQoQx4sJTfCyD94= X-Google-Smtp-Source: AGHT+IE6ZxQLSUDvvUk03xZkY6BM5VuNNhIRzTdmbyBZOvEJ8hF1MF5utYwnDrYqK+6b1JOMQwY+Xw== X-Received: by 2002:a17:90a:c590:b0:2c7:ab29:a751 with SMTP id 98e67ed59e1d1-2ca35c78f02mr8361840a91.29.1720751868410; Thu, 11 Jul 2024 19:37:48 -0700 (PDT) Received: from TF4D9JK212.bytedance.net ([61.213.176.12]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cacd65fc43sm297453a91.39.2024.07.11.19.37.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Jul 2024 19:37:48 -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, Changqi Lu , Klaus Jensen Subject: [PATCH v9 08/10] hw/nvme: enable ONCS and rescap function Date: Fri, 12 Jul 2024 10:36:48 +0800 Message-Id: <20240712023650.45626-9-luchangqi.123@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240712023650.45626-1-luchangqi.123@bytedance.com> References: <20240712023650.45626-1-luchangqi.123@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=luchangqi.123@bytedance.com; helo=mail-pj1-x1030.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 *pci_dev) id->nn = cpu_to_le32(NVME_MAX_NAMESPACES); id->oncs = 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); /* * 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" #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; ns->lbaf = id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(id_ns->flbas)]; ns->lbasz = 1 << ns->lbaf.ds; @@ -55,6 +57,9 @@ void nvme_ns_init_format(NvmeNamespace *ns) } id_ns->npda = id_ns->npdg = npdg - 1; + + blk_pr_cap = blk_bs(ns->blkconf.blk)->bl.pr_cap; + id_ns->rescap = block_pr_cap_to_nvme(blk_pr_cap); } 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 = 1 << 2, NVME_ONCS_WRITE_ZEROES = 1 << 3, NVME_ONCS_FEATURES = 1 << 4, - NVME_ONCS_RESRVATIONS = 1 << 5, + NVME_ONCS_RESERVATIONS = 1 << 5, NVME_ONCS_TIMESTAMP = 1 << 6, NVME_ONCS_VERIFY = 1 << 7, NVME_ONCS_COPY = 1 << 8,