mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Matias Bjørling" <mb@lightnvm.io>
To: axboe@fb.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	keith.busch@intel.com, javier@cnexlabs.com,
	"Matias Bjørling" <mb@lightnvm.io>
Subject: [GIT PULL 24/37] lightnvm: add minor version to generic geometry
Date: Fri, 30 Mar 2018 00:05:11 +0200	[thread overview]
Message-ID: <20180329220524.30363-25-mb@lightnvm.io> (raw)
In-Reply-To: <20180329220524.30363-1-mb@lightnvm.io>

From: Javier González <javier@cnexlabs.com>

Separate the version between major and minor on the generic geometry and
represent it through sysfs in the 2.0 path. The 1.2 path only shows the
major version to preserve the existing user space interface.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
---
 drivers/lightnvm/core.c      |  4 ++--
 drivers/nvme/host/lightnvm.c | 25 ++++++++++++++++++++-----
 include/linux/lightnvm.h     |  3 ++-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 9dec936ac1dc..103e0ad9622c 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -890,8 +890,8 @@ static int nvm_init(struct nvm_dev *dev)
 		goto err;
 	}
 
-	pr_debug("nvm: ver:%u nvm_vendor:%x\n",
-				geo->ver_id,
+	pr_debug("nvm: ver:%u.%u nvm_vendor:%x\n",
+				geo->major_ver_id, geo->minor_ver_id,
 				geo->vmnt);
 
 	ret = nvm_core_init(dev);
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 29c8f44eb25b..de4105544956 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -295,7 +295,9 @@ static int nvme_nvm_setup_12(struct nvme_nvm_id12 *id,
 		return -EINVAL;
 	}
 
-	geo->ver_id = id->ver_id;
+	/* 1.2 spec. only reports a single version id - unfold */
+	geo->major_ver_id = id->ver_id;
+	geo->minor_ver_id = 2;
 
 	geo->nr_chnls = src->num_ch;
 	geo->nr_luns = src->num_lun;
@@ -379,7 +381,14 @@ static void nvme_nvm_set_addr_20(struct nvm_addrf *dst,
 static int nvme_nvm_setup_20(struct nvme_nvm_id20 *id,
 			     struct nvm_geo *geo)
 {
-	geo->ver_id = id->mjr;
+	geo->major_ver_id = id->mjr;
+	geo->minor_ver_id = id->mnr;
+
+	if (!(geo->major_ver_id == 2 && geo->minor_ver_id == 0)) {
+		pr_err("nvm: OCSSD version not supported (v%d.%d)\n",
+				geo->major_ver_id, geo->minor_ver_id);
+		return -EINVAL;
+	}
 
 	geo->nr_chnls = le16_to_cpu(id->num_grp);
 	geo->nr_luns = le16_to_cpu(id->num_pu);
@@ -914,7 +923,13 @@ static ssize_t nvm_dev_attr_show(struct device *dev,
 	attr = &dattr->attr;
 
 	if (strcmp(attr->name, "version") == 0) {
-		return scnprintf(page, PAGE_SIZE, "%u\n", geo->ver_id);
+		if (geo->major_ver_id == 1)
+			return scnprintf(page, PAGE_SIZE, "%u\n",
+						geo->major_ver_id);
+		else
+			return scnprintf(page, PAGE_SIZE, "%u.%u\n",
+						geo->major_ver_id,
+						geo->minor_ver_id);
 	} else if (strcmp(attr->name, "capabilities") == 0) {
 		return scnprintf(page, PAGE_SIZE, "%u\n", geo->cap);
 	} else if (strcmp(attr->name, "read_typ") == 0) {
@@ -1167,7 +1182,7 @@ int nvme_nvm_register_sysfs(struct nvme_ns *ns)
 	if (!ndev)
 		return -EINVAL;
 
-	switch (geo->ver_id) {
+	switch (geo->major_ver_id) {
 	case 1:
 		return sysfs_create_group(&disk_to_dev(ns->disk)->kobj,
 					&nvm_dev_attr_group_12);
@@ -1184,7 +1199,7 @@ void nvme_nvm_unregister_sysfs(struct nvme_ns *ns)
 	struct nvm_dev *ndev = ns->ndev;
 	struct nvm_geo *geo = &ndev->geo;
 
-	switch (geo->ver_id) {
+	switch (geo->major_ver_id) {
 	case 1:
 		sysfs_remove_group(&disk_to_dev(ns->disk)->kobj,
 					&nvm_dev_attr_group_12);
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index 6e650563b379..7ed8b92d6744 100644
--- a/include/linux/lightnvm.h
+++ b/include/linux/lightnvm.h
@@ -263,7 +263,8 @@ enum {
 /* Instance geometry */
 struct nvm_geo {
 	/* device reported version */
-	u8	ver_id;
+	u8	major_ver_id;
+	u8	minor_ver_id;
 
 	/* instance specific geometry */
 	int nr_chnls;
-- 
2.11.0

  parent reply	other threads:[~2018-03-29 22:07 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 22:04 [GIT PULL 00/37] lightnvm patches for 4.17 Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 01/37] lightnvm/pblk-gc: Delete an error message for a failed memory allocation in pblk_gc_line_prepare_ws() Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 02/37] lightnvm: remove chnl_offset in nvme_nvm_identity Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 03/37] lightnvm: pblk: handle bad sectors in the emeta area correctly Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 04/37] lightnvm: pblk: check data lines version on recovery Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 05/37] lightnvm: pblk: export write amplification counters to sysfs Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 06/37] lightnvm: remove mlc pairs structure Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 07/37] lightnvm: remove multiple groups in 1.2 data structure Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 08/37] lightnvm: pblk: add padding distribution sysfs attribute Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 09/37] lightnvm: pblk: delete writer kick timer before stopping thread Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 10/37] lightnvm: pblk: allow allocation of new lines during shutdown Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 11/37] lightnvm: pblk: prevent race in pblk_rb_flush_point_set Matias Bjørling
2018-03-29 22:04 ` [GIT PULL 12/37] lightnvm: pblk: refactor bad block identification Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 13/37] lightnvm: make 1.2 data structures explicit Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 14/37] lightnvm: flatten nvm_id_group into nvm_id Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 15/37] lightnvm: add 2.0 geometry identification Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 16/37] lightnvm: remove max_rq_size Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 17/37] lightnvm: remove nvm_dev_ops->max_phys_sect Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 18/37] nvme: lightnvm: add late setup of block size and metadata Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 19/37] lightnvm: fix bad block initialization Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 20/37] lightnvm: centralize permission check for lightnvm ioctl Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 21/37] lightnvm: Avoid validation of default op value Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 22/37] lightnvm: pblk: refactor init/exit sequences Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 23/37] lightnvm: simplify geometry structure Matias Bjørling
2018-03-29 22:05 ` Matias Bjørling [this message]
2018-03-29 22:05 ` [GIT PULL 25/37] lightnvm: add shorten OCSSD version in geo Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 26/37] lightnvm: complete geo structure with maxoc* Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 27/37] lightnvm: normalize geometry nomenclature Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 28/37] lightnvm: add support for 2.0 address format Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 29/37] lightnvm: make address conversions depend on generic device Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 30/37] lightnvm: implement get log report chunk helpers Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 31/37] lightnvm: pblk: check for supported version Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 32/37] lightnvm: pblk: rename ppaf* to addrf* Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 33/37] lightnvm: pblk: implement get log report chunk Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 34/37] lightnvm: pblk: implement 2.0 support Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 35/37] lightnvm: pblk: don't recover unwritten lines Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 36/37] lightnvm: pblk: remove some unnecessary NULL checks Matias Bjørling
2018-03-29 22:05 ` [GIT PULL 37/37] lightnvm: remove function name in strings Matias Bjørling
2018-03-29 23:30 ` [GIT PULL 00/37] lightnvm patches for 4.17 Jens Axboe

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=20180329220524.30363-25-mb@lightnvm.io \
    --to=mb@lightnvm.io \
    --cc=axboe@fb.com \
    --cc=javier@cnexlabs.com \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®