From nobody Tue Apr 7 18:45:33 2026 Received: from mail-pl1-f225.google.com (mail-pl1-f225.google.com [209.85.214.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52CDE44CAE5 for ; Thu, 26 Feb 2026 19:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772132670; cv=none; b=hvf2ODB2l6YuO0WTQnFT3z4sh9HFCxDmIkZ3IOTrymxOpJWvl/rk2pV00X7t6obF9xCVtvWwWrDCmDL7vP4eS6AR13cps0xyBFDbO/gdmmvN81LJ1rN3Ye5NU8nf0bz/BL3jISPkbbqWqYg87/qNepDwmc7YXeziemJr317wWFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772132670; c=relaxed/simple; bh=62cRCccrSguAwwqDGJINO/15pCmBCVwknmS2odJqMIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EbX+jSc1oWjrPUZxYhNop54Ok5YyU8AWdAXWDQ3BHeAAYMdwUvQRWuF+nyW2GJQwBKYZhNU4r5tG9Jdrg7GJfdzu3xtDaSoXnMHEpjs01ghoMyhmGLWndE1uytoRS12ZXmokJFzFTtHmzMgMT4VdqtfTMyZ4yW3desNvmqvgED4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=a+RgoX3H; arc=none smtp.client-ip=209.85.214.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="a+RgoX3H" Received: by mail-pl1-f225.google.com with SMTP id d9443c01a7336-2a8720818aeso1525445ad.1 for ; Thu, 26 Feb 2026 11:04:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1772132661; x=1772737461; darn=vger.kernel.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=ooHjh6HrTZHmSmxByDLdiCmY2zTnKYEXcZkNLfcMiWM=; b=a+RgoX3H++g18PFD3+KG0R42deTH043RaCR4+5x94dUDusFFMg7eUBTBIB46UNO/44 iRBfXM50N2k3kAlTmLNAUc2ON7iMZv760xCIKq07Yw3+3hT3kHuMNg8w0T/36E+bl+3h Dd2du6oDGAm7ie10fZL9CFSODbXRkUnSBG/BtZTjfc3IdE0hDBZ+MrFIwjYsFyzcK+aM slfBAtqfXd4bx7LgZiMaSAlCldJrRFvR6kEZdbeQWWf0kaO5V2KSTidvjFMq4tH11FrE mCT8uGPw8ZW2DINkBqO0ev2lA7rrIPxR4+Z2EBO6WiL+Gy4uxpfcInxzg+fCWDhlFIjg gBUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772132661; x=1772737461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ooHjh6HrTZHmSmxByDLdiCmY2zTnKYEXcZkNLfcMiWM=; b=wU70XZea1arQw0E/nwOQm/mXvjfzn0kWb1MpBNZNLreYsktTMKRoXeFwKT/dg/e9qy Fs2STSw6EAl2qsncAy1dMK4FwNRxUKHyfJzYIaaf+HDLyBN8Kh51gVoSEqvgE2xTNOyi MUzXwmbXrMNzWzdtfPtWDO6NAaBHszeeU/fppNiEy5DVS0AbYS6G3dMDsLmEKnCDPTPM CToOnU0V2la3UYkG6bXB0hfcQRSXF0vr9sHaUdrLTec4CrE9JlEDGOR/+HTgWFSKQBRB FhyOTvqPk6ykPb1leMQQ9JJlF61zdvGrTop6VluuZVdddX3PK4RaOjBZa7nXp1HtZ7LR kXTA== X-Forwarded-Encrypted: i=1; AJvYcCV9TKFpQ93FUJFWIMMtDX4quJTAYztzEwyW/wz+T9h/WU6xByXcb/QHuCrXsProW0Bae/fHp6VHpqLkTTk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/khoh93IBCnU/FsPxOvhWI3OOU4+Va2C35cg1/HRyc3OkxDHA Hn8FCRJv8qTq5+o1UQedO++QlaOthXq4C3+Z0Kwb9zwSUx1U7xDv2CcDonGMgfVMpq1PK/2X+Yl 5536KKZgLsGLY4y+bqU5XedFP2M2aEONkOtkA X-Gm-Gg: ATEYQzwH0vrccmIwNBm5cSFzc5SwDas5csPHIAgWykxUoKXrPhS89KmnLsl1M5by4RC fDt3wA7OViLTy0ctVBa1n/S0X4B5zVRh8yrittOY+E//YRkjmjwkeg4C2BdyL0KCknn/Xp7GLjy /elvZL0LW6tUmLIwfaRP65VcDayftvXQcLHFHoq4SmslX4+xfCFFewIMu3d7e3FtgbHn6h7jjFB beoVWJeVfXqD8U3XC15x7UeFBetL4VHknv33Lz/kbiR56fiYHZbZS5VeBe1udGWaSFxeeM1HzTh w+sTmbEbCtg8MwMMxbo29bcrMTzTRd6MUVq7jt6fdZuT1esulAGMAAQsCCzDyM/RiBSk0ptNE8a eEtAJAno6k7IhW3VzTC0iSFkH82HX5bFyawCOVIwF+GuNaXkwFrmtPg== X-Received: by 2002:a17:903:1a4d:b0:2ad:c651:46f with SMTP id d9443c01a7336-2ae2e1322d5mr254715ad.0.1772132661273; Thu, 26 Feb 2026 11:04:21 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id d9443c01a7336-2adfb05e386sm3591335ad.1.2026.02.26.11.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 11:04:21 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 1F2E63407D1; Thu, 26 Feb 2026 12:04:20 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 19D67E41254; Thu, 26 Feb 2026 12:04:20 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v4 3/8] nvme: update nvme_id_ns OPTPERF constants Date: Thu, 26 Feb 2026 12:04:10 -0700 Message-ID: <20260226190416.297725-4-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260226190416.297725-1-csander@purestorage.com> References: <20260226190416.297725-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In NVMe verson 2.0 and below, OPTPERF comprises only bit 4 of NSFEAT in the Identify Namespace structure. Since version 2.1, OPTPERF includes both bits 4 and 5 of NSFEAT. Replace the NVME_NS_FEAT_IO_OPT constant with NVME_NS_FEAT_OPTPERF_SHIFT, NVME_NS_FEAT_OPTPERF_MASK, and NVME_NS_FEAT_OPTPERF_MASK_2_1, representing the first bit, pre-2.1 bit width, and post-2.1 bit width of OPTPERF. Update nvme_update_disk_info() to check both OPTPERF bits for controllers that report version 2.1 or newer, as NPWG and NOWS are supported even if only bit 5 is set. Signed-off-by: Caleb Sander Mateos --- drivers/nvme/host/core.c | 8 +++++++- include/linux/nvme.h | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 8dda2fe69789..bff6f26d7bcf 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2062,10 +2062,11 @@ static bool nvme_update_disk_info(struct nvme_ns *n= s, struct nvme_id_ns *id, struct nvme_ns_head *head =3D ns->head; struct nvme_ctrl *ctrl =3D ns->ctrl; u32 bs =3D 1U << head->lba_shift; u32 atomic_bs, phys_bs, io_opt =3D 0; bool valid =3D true; + u8 optperf; =20 /* * The block layer can't support LBA sizes larger than the page size * or smaller than a sector size yet, so catch this early and don't * allow block I/O. @@ -2076,11 +2077,16 @@ static bool nvme_update_disk_info(struct nvme_ns *n= s, struct nvme_id_ns *id, } =20 phys_bs =3D bs; atomic_bs =3D nvme_configure_atomic_write(ns, id, lim, bs); =20 - if (id->nsfeat & NVME_NS_FEAT_IO_OPT) { + optperf =3D id->nsfeat >> NVME_NS_FEAT_OPTPERF_SHIFT; + if (ctrl->vs >=3D NVME_VS(2, 1, 0)) + optperf &=3D NVME_NS_FEAT_OPTPERF_MASK_2_1; + else + optperf &=3D NVME_NS_FEAT_OPTPERF_MASK; + if (optperf) { /* NPWG =3D Namespace Preferred Write Granularity */ phys_bs =3D bs * (1 + le16_to_cpu(id->npwg)); /* NOWS =3D Namespace Optimal Write Size */ if (id->nows) io_opt =3D bs * (1 + le16_to_cpu(id->nows)); diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 1134e6bf2d5c..d840f5fe79fa 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -595,11 +595,15 @@ enum { }; =20 enum { NVME_NS_FEAT_THIN =3D 1 << 0, NVME_NS_FEAT_ATOMICS =3D 1 << 1, - NVME_NS_FEAT_IO_OPT =3D 1 << 4, + NVME_NS_FEAT_OPTPERF_SHIFT =3D 4, + /* In NVMe version 2.0 and below, OPTPERF is only bit 4 of NSFEAT */ + NVME_NS_FEAT_OPTPERF_MASK =3D 0x1, + /* Since version 2.1, OPTPERF is bits 4 and 5 of NSFEAT */ + NVME_NS_FEAT_OPTPERF_MASK_2_1 =3D 0x3, NVME_NS_ATTR_RO =3D 1 << 0, NVME_NS_FLBAS_LBA_MASK =3D 0xf, NVME_NS_FLBAS_LBA_UMASK =3D 0x60, NVME_NS_FLBAS_LBA_SHIFT =3D 1, NVME_NS_FLBAS_META_EXT =3D 0x10, --=20 2.45.2