From patchwork Tue Oct 8 14:55:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 13826617 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D4FD1E4B2; Tue, 8 Oct 2024 14:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728399326; cv=none; b=gXB7hGNWV0WK9JuSZzn0pVEQkKZWD5srMZ57yzRq7vWeUhHalFeoPAlYcHPp4SK2nzXnVTAZomiQLzl2/2GaLx/e0Dv2hhfor8UxP41fn5gzpV+3mqsVTA0YXrRteTI7Gly/2nthurKQ/9rH6ClMQ9VmR7XMek0zDpvM/o7/qNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728399326; c=relaxed/simple; bh=KjCh9TiB71GCKtR9M/0flwzyy5d+37QXAkq6HOcgcOk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WI7oaWOwdPTsjnMPdd1PE6ZlCoCPF1fMYMpQ+AM31t14EhG7cELauB3pyFm6VKqwfYxmZjwkU2S+LNjASF/Bga7St25aorwQ5S/VjHHvHFNSqstCLF6VDCgmfl25aoVyA7wb4m7zCAFyvNjFskoZhz+26CwWCN7OWKekeFmo9bM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bjorling.me; spf=pass smtp.mailfrom=bjorling.me; dkim=pass (2048-bit key) header.d=bjorling.me header.i=@bjorling.me header.b=DcMx4pbY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Rsj04EuS; arc=none smtp.client-ip=103.168.172.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bjorling.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bjorling.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bjorling.me header.i=@bjorling.me header.b="DcMx4pbY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Rsj04EuS" Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 703EC1140217; Tue, 8 Oct 2024 10:55:23 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Tue, 08 Oct 2024 10:55:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1728399323; x=1728485723; bh=xHIs0lcNCSIzydBGO9Xs3o6nAYW19CDkOevo4gGwYu4=; b= DcMx4pbYDXNfOI0ZNkGk7yyVOvkXptjzUiZddcLMvwZBXoDp6/DHirz20+d1p9ck QEvkp4iEUQJW+AliN2YiGMGvq2NHdivjgRt2f7ZNqV8F/HYUPjQoAZ0hlD3P94lL toLGxIOHsQkQ78MovQ5YBByEXUtC28KD+kSfG+kX/AmVZxYRrbDXnz7C1GlALG1u tCt9B2R+okfYHjDLdAtEfq+FqS4m2FiA1Qi2GgcyS4lGNTCnGlsf2bf9x2nt/spI BxBA7EE8VeJiNYGd7YW2Kn1NaM7wtQ7JhU7JpQlmUT7O7Pn8OJGZPm0iqD3xeheO o+QYvGWKFf1e7OiAt3solQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1728399323; x= 1728485723; bh=xHIs0lcNCSIzydBGO9Xs3o6nAYW19CDkOevo4gGwYu4=; b=R sj04EuSilxF4HwEnKRv8M6CqdhPLjPTwghmuHwpxOz97ozIYsoB6Q8T3gpz+jSti FfbJ41wFC05p6x8QNBMMxrjFDDn3dW6ZUSXQ/k+Gn+HMZKOBYDoZxRTbpjEuZf0M SmRmi1wk21iuE1xR6cyfXUG/DEeNfeh3K2RRBmaXCVj9PyN9IPUsRKn1gqoECeZ9 tCYj7M/zKCzOGP17MWovcT8wnp7w6VgCeCnu56167RT+NQsjVYyPh+pZXmPPz0vD Mc7RRXaW00g+eh9mD178q9xIMuBVhwf0w5ZTCBfBB6/0mxkad+cRxYAEL/2VdAa+ osVnL6n5MQJptvJn1OkLQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefuddgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepofgrthhirghsuceujhpprhhl ihhnghcuoehmsegsjhhorhhlihhnghdrmhgvqeenucggtffrrghtthgvrhhnpeffkeegvd fggeefgfffteeghfetteetudeiteejgfevudeifeelffeuiedvueelheenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmsegsjhhorhhlihhngh drmhgvpdhnsggprhgtphhtthhopeekpdhmohguvgepshhmthhpohhuthdprhgtphhtthho pehksghushgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhgthheslhhsthdrug gvpdhrtghpthhtohepughlvghmohgrlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tggrshhsvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhnvhhmvg eslhhishhtshdrihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehlihhnuhigqdgs lhhotghksehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkh gvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhgrthhirghs rdgsjhhorhhlihhnghesfigutgdrtghomh X-ME-Proxy: Feedback-ID: if4314918:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 8 Oct 2024 10:55:22 -0400 (EDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: kbusch@kernel.org, hch@lst.de, dlemoal@kernel.org, cassel@kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [PATCH 1/2] nvme: make independent ns identify default Date: Tue, 8 Oct 2024 16:55:02 +0200 Message-ID: <20241008145503.987195-2-m@bjorling.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241008145503.987195-1-m@bjorling.me> References: <20241008145503.987195-1-m@bjorling.me> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Matias Bjørling The NVMe 2.0 specification adds an independent identify namespace data structure that contains generic attributes that apply to all namespace types. Some attributes carry over from the NVM command set identify namespace data structure, and others are new. Currently, the data structure only considered when CRIMS is enabled or when the namespace type is key-value. However, the independent namespace data structure is mandatory for devices that implement features from the 2.0+ specification. Therefore, we can check this data structure first. If unavailable, retrieve the generic attributes from the NVM command set identify namespace data structure. Signed-off-by: Matias Bjørling --- drivers/nvme/host/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0dc8bcc664f2..9cbef6342c39 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3999,7 +3999,7 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid) { struct nvme_ns_info info = { .nsid = nsid }; struct nvme_ns *ns; - int ret; + int ret = 1; if (nvme_identify_ns_descs(ctrl, &info)) return; @@ -4015,10 +4015,9 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid) * data structure to find all the generic information that is needed to * set up a namespace. If not fall back to the legacy version. */ - if ((ctrl->cap & NVME_CAP_CRMS_CRIMS) || - (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS)) + if (!nvme_ctrl_limited_cns(ctrl)) ret = nvme_ns_info_from_id_cs_indep(ctrl, &info); - else + if (ret > 0) ret = nvme_ns_info_from_identify(ctrl, &info); if (info.is_removed) From patchwork Tue Oct 8 14:55:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 13826618 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF4351E00AA; Tue, 8 Oct 2024 14:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728399329; cv=none; b=A3XVddJoCqFRHEHrTDrkqRV823h2abEBnVdxEpEyuTFI7kQNK+U5OGSDkOSR/KtfhBYfYPTVZh9pvRJz336ZErPcyZ9v/SDp8DUXH7KpBgJQTjCaN+vug62GLV30chioJ48rqH1BUsh10wfE346WHhysdhyd8gs4nf79kasvKI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728399329; c=relaxed/simple; bh=Bk7QM+rVFv2wXy/wHI+36XVT2XALN+uWLT7lljS6dPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ax4Y7dVtYT79hZZODAdX/Zk2fDK/PZ8tGzFq4CDoYLrnCHpVMVh8CZz9Iylv1HBB02fC3uXlhBomwC26PVBDoWn2pmS0qH+m0GDr6naOG3VqAYPQRiL2MC6Beo7bhmCQSV1OtclUWxgYiol8cOD4SnZ9M9D8E9kO1eCpXNoZwvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bjorling.me; spf=pass smtp.mailfrom=bjorling.me; dkim=pass (2048-bit key) header.d=bjorling.me header.i=@bjorling.me header.b=U/vQRSjy; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jl2f0yGv; arc=none smtp.client-ip=103.168.172.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bjorling.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bjorling.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bjorling.me header.i=@bjorling.me header.b="U/vQRSjy"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jl2f0yGv" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id DF83C114022E; Tue, 8 Oct 2024 10:55:24 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 08 Oct 2024 10:55:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1728399324; x=1728485724; bh=js32dkdye8YTfXqTgEmAVBWITQHNETUK2Lpip3icE50=; b= U/vQRSjy+i77DB0y59gXsJjy04HUktwLx1/zz/Uy3qdatQ2pVrIoo6h3lFeVyd21 VJthMFWmKCdURq4rvawwAWj+10p+9W4xgYIymldvbyjxWgXjp9MjcbuHuKCVIGFZ mmNBoi8iaOI0IJ8Xe14InMdkwKwQ26BCBV6YavZG4jhf6mFiudNQQAjafQb4B995 7WS7qXu2bHJ6jOIZEAQ8wqGQnqVye8LyahU9/Zx3YZpIp+uUxkBwNuFlL9qOnA7p KBaS9eoqpW8wfwNghej8kXljtxv4shJ81HFdNpd8u1koWELVPrtGhFM7q7Q7acyn UtRQmn2ZI7lJ9gatOHC6OQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1728399324; x= 1728485724; bh=js32dkdye8YTfXqTgEmAVBWITQHNETUK2Lpip3icE50=; b=j l2f0yGv7QaJeZIMh0Wxb2CDHkn801m9dbgtu93nMIGmDk0RJcfXvbjm3vRktepTp PoaHBwb6Ny2tJJju4TVZ7TKb7yiFtIxiugJTOwjol4UiFJCrN9th5/Nnt/gZsSIp q3m0yIFNdEgNgB0WUkzJ8IKIEzAhgGDP/YRzsyP//gTqg7cOGJe9ykNb9fLCVH7k BvbKUPmEOjks/8vhQ1zVySI/9/OI3wNm/smdLCPAU4xAvxheUWmemtYtZU5ndHg4 rJFLZlqvpXZvMyV45uHqbw8SAHIcm8rEJxb5CLjI6NWZFfgyhhfxalttTdNRsikw yjhskx3q2oeGib+lK2cqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefuddgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepofgrthhirghsuceujhpprhhl ihhnghcuoehmsegsjhhorhhlihhnghdrmhgvqeenucggtffrrghtthgvrhhnpeffkeegvd fggeefgfffteeghfetteetudeiteejgfevudeifeelffeuiedvueelheenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmsegsjhhorhhlihhngh drmhgvpdhnsggprhgtphhtthhopeekpdhmohguvgepshhmthhpohhuthdprhgtphhtthho pehksghushgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhgthheslhhsthdrug gvpdhrtghpthhtohepughlvghmohgrlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tggrshhsvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhnvhhmvg eslhhishhtshdrihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehlihhnuhigqdgs lhhotghksehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkh gvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhgrthhirghs rdgsjhhorhhlihhnghesfigutgdrtghomh X-ME-Proxy: Feedback-ID: if4314918:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 8 Oct 2024 10:55:23 -0400 (EDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: kbusch@kernel.org, hch@lst.de, dlemoal@kernel.org, cassel@kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [PATCH 2/2] nvme: add rotational support Date: Tue, 8 Oct 2024 16:55:03 +0200 Message-ID: <20241008145503.987195-3-m@bjorling.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241008145503.987195-1-m@bjorling.me> References: <20241008145503.987195-1-m@bjorling.me> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Matias Bjørling Rotational devices, such as hard-drives, can be detected using the rotational bit in the namespace independent identify namespace data structure. Make the bit visible to the block layer through the rotational queue setting. Note that rotational devices typically can be used to generate random entropy, the device is therefore also added as a block device that adds entropy. Signed-off-by: Matias Bjørling Reviewed-by: Hannes Reinecke --- drivers/nvme/host/core.c | 5 +++++ include/linux/nvme.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 9cbef6342c39..a445f13f5a28 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -41,6 +41,7 @@ struct nvme_ns_info { bool is_readonly; bool is_ready; bool is_removed; + bool is_rotational; }; unsigned int admin_timeout = 60; @@ -1623,6 +1624,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl, info->is_shared = id->nmic & NVME_NS_NMIC_SHARED; info->is_readonly = id->nsattr & NVME_NS_ATTR_RO; info->is_ready = id->nstat & NVME_NSTAT_NRDY; + info->is_rotational = id->nsfeat & NVME_NS_ROTATIONAL; } kfree(id); return ret; @@ -2170,6 +2172,9 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, else lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA); + if (info->is_rotational) + lim.features |= BLK_FEAT_ROTATIONAL | BLK_FEAT_ADD_RANDOM; + /* * Register a metadata profile for PI, or the plain non-integrity NVMe * metadata masquerading as Type 0 if supported, otherwise reject block diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 7b2ae2e43544..6d0eebb57544 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -560,6 +560,7 @@ enum { NVME_NS_FLBAS_LBA_SHIFT = 1, NVME_NS_FLBAS_META_EXT = 0x10, NVME_NS_NMIC_SHARED = 1 << 0, + NVME_NS_ROTATIONAL = 1 << 4, NVME_LBAF_RP_BEST = 0, NVME_LBAF_RP_BETTER = 1, NVME_LBAF_RP_GOOD = 2,