From: Wang Yugui <wangyugui@e16-tech.com>
To: linux-nvme@lists.infradead.org
Cc: Wang Yugui <wangyugui@e16-tech.com>
Subject: [PATCH RFC v3] nvme: basic RMEDIA support for host
Date: Tue, 6 Aug 2024 08:48:23 +0800 [thread overview]
Message-ID: <20240806004823.27417-1-wangyugui@e16-tech.com> (raw)
In-Reply-To: <20240723232419.19753-1-wangyugui@e16-tech.com>
Rotational media(RMEDIA) support is added to the NVMe 2.0 specification.
We add Rotational media(RMEDIA) basic support to nvme host firstly.
Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
---
changelog of RFC v3
- rename var based on comments.
change is_rmedia to is_rotational;
but keep RMEDIA of NVME_INDEP_NS_FEAT_RMEDIA to match NVME spec 2.0.
drivers/nvme/host/core.c | 5 +++++
drivers/nvme/host/multipath.c | 3 +++
drivers/nvme/host/nvme.h | 1 +
include/linux/nvme.h | 1 +
4 files changed, 10 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 19917253ba7b..f4c41bf70b19 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -40,6 +40,7 @@ struct nvme_ns_info {
bool is_readonly;
bool is_ready;
bool is_removed;
+ bool is_rotational;
};
unsigned int admin_timeout = 60;
@@ -1622,6 +1623,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_INDEP_NS_FEAT_RMEDIA;
}
kfree(id);
return ret;
@@ -3613,6 +3618,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
head->ns_id = info->nsid;
head->ids = info->ids;
head->shared = info->is_shared;
+ head->rotational = info->is_rotational;
ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1);
ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE);
kref_init(&head->ref);
@@ -3816,6 +3816,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
if (ctrl->opts && ctrl->opts->data_digest)
lim.features |= BLK_FEAT_STABLE_WRITES;
+ if (info->is_rotational)
+ lim.features |= BLK_FEAT_ROTATIONAL;
if (ctrl->ops->supports_pci_p2pdma &&
ctrl->ops->supports_pci_p2pdma(ctrl))
lim.features |= BLK_FEAT_PCI_P2PDMA;
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 91d9eb3c22ef..a3cd6525d24d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -626,6 +626,9 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
head->disk->private_data = head;
sprintf(head->disk->disk_name, "nvme%dn%d",
ctrl->subsys->instance, head->instance);
+
+ if (head->rotational)
+ lim.features |= BLK_FEAT_ROTATIONAL;
return 0;
}
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index f900e44243ae..9f2789c44249 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -465,6 +465,7 @@ struct nvme_ns_head {
struct list_head entry;
struct kref ref;
bool shared;
+ bool rotational;
bool passthru_err_log_enabled;
int instance;
struct nvme_effects_log *effects;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index c12a329dd463..2c259d126f80 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -546,6 +546,7 @@ enum {
NVME_NS_FEAT_THIN = 1 << 0,
NVME_NS_FEAT_ATOMICS = 1 << 1,
NVME_NS_FEAT_IO_OPT = 1 << 4,
+ NVME_INDEP_NS_FEAT_RMEDIA = 1 << 4,
NVME_NS_ATTR_RO = 1 << 0,
NVME_NS_FLBAS_LBA_MASK = 0xf,
NVME_NS_FLBAS_LBA_UMASK = 0x60,
--
2.36.2
next prev parent reply other threads:[~2024-08-06 0:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 23:24 [PATCH RFC] basic RMEDIA support for nvme host Wang Yugui
2024-07-24 12:30 ` [PATCH RFC v2] nvme: basic RMEDIA support for host Wang Yugui
2024-07-25 0:43 ` Damien Le Moal
2024-07-25 1:56 ` Wang Yugui
2024-07-25 14:10 ` Christoph Hellwig
2024-07-25 22:59 ` Damien Le Moal
2024-08-12 14:28 ` Hannes Reinecke
2024-07-25 14:09 ` Christoph Hellwig
2024-08-06 0:48 ` Wang Yugui [this message]
2024-08-06 0:49 ` [PATCH RFC] nvmet: basic RMEDIA support for target Wang Yugui
2024-08-06 8:11 ` Sagi Grimberg
2024-08-06 9:08 ` Wang Yugui
2024-08-06 9:42 ` [PATCH RFC v2] " Wang Yugui
2024-08-06 12:40 ` [PATCH RFC v3] " Wang Yugui
2024-08-07 12:14 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240806004823.27417-1-wangyugui@e16-tech.com \
--to=wangyugui@e16-tech.com \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox