]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
lightnvm: add minor version to generic geometry
authorJavier González <javier@cnexlabs.com>
Thu, 29 Mar 2018 22:05:11 +0000 (00:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Mar 2018 23:29:09 +0000 (17:29 -0600)
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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/core.c
drivers/nvme/host/lightnvm.c
include/linux/lightnvm.h

index 9dec936ac1dcce8fa32dc583c5fa6273a803d38e..103e0ad9622cf59399f38ae791aff5a647e01028 100644 (file)
@@ -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);
index 29c8f44eb25b605b2f070b152e48e7f4697e8709..de4105544956a0ccab11d892ffa30ee4d3cd0479 100644 (file)
@@ -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);
index 6e650563b3791271f3ce51d1fcb14ee083f9aa29..7ed8b92d674497da35f0306847e9ad1f6f351d8d 100644 (file)
@@ -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;