aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/lightnvm/core.c4
-rw-r--r--drivers/nvme/host/lightnvm.c25
-rw-r--r--include/linux/lightnvm.h3
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)
890 goto err; 890 goto err;
891 } 891 }
892 892
893 pr_debug("nvm: ver:%u nvm_vendor:%x\n", 893 pr_debug("nvm: ver:%u.%u nvm_vendor:%x\n",
894 geo->ver_id, 894 geo->major_ver_id, geo->minor_ver_id,
895 geo->vmnt); 895 geo->vmnt);
896 896
897 ret = nvm_core_init(dev); 897 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,
295 return -EINVAL; 295 return -EINVAL;
296 } 296 }
297 297
298 geo->ver_id = id->ver_id; 298 /* 1.2 spec. only reports a single version id - unfold */
299 geo->major_ver_id = id->ver_id;
300 geo->minor_ver_id = 2;
299 301
300 geo->nr_chnls = src->num_ch; 302 geo->nr_chnls = src->num_ch;
301 geo->nr_luns = src->num_lun; 303 geo->nr_luns = src->num_lun;
@@ -379,7 +381,14 @@ static void nvme_nvm_set_addr_20(struct nvm_addrf *dst,
379static int nvme_nvm_setup_20(struct nvme_nvm_id20 *id, 381static int nvme_nvm_setup_20(struct nvme_nvm_id20 *id,
380 struct nvm_geo *geo) 382 struct nvm_geo *geo)
381{ 383{
382 geo->ver_id = id->mjr; 384 geo->major_ver_id = id->mjr;
385 geo->minor_ver_id = id->mnr;
386
387 if (!(geo->major_ver_id == 2 && geo->minor_ver_id == 0)) {
388 pr_err("nvm: OCSSD version not supported (v%d.%d)\n",
389 geo->major_ver_id, geo->minor_ver_id);
390 return -EINVAL;
391 }
383 392
384 geo->nr_chnls = le16_to_cpu(id->num_grp); 393 geo->nr_chnls = le16_to_cpu(id->num_grp);
385 geo->nr_luns = le16_to_cpu(id->num_pu); 394 geo->nr_luns = le16_to_cpu(id->num_pu);
@@ -914,7 +923,13 @@ static ssize_t nvm_dev_attr_show(struct device *dev,
914 attr = &dattr->attr; 923 attr = &dattr->attr;
915 924
916 if (strcmp(attr->name, "version") == 0) { 925 if (strcmp(attr->name, "version") == 0) {
917 return scnprintf(page, PAGE_SIZE, "%u\n", geo->ver_id); 926 if (geo->major_ver_id == 1)
927 return scnprintf(page, PAGE_SIZE, "%u\n",
928 geo->major_ver_id);
929 else
930 return scnprintf(page, PAGE_SIZE, "%u.%u\n",
931 geo->major_ver_id,
932 geo->minor_ver_id);
918 } else if (strcmp(attr->name, "capabilities") == 0) { 933 } else if (strcmp(attr->name, "capabilities") == 0) {
919 return scnprintf(page, PAGE_SIZE, "%u\n", geo->cap); 934 return scnprintf(page, PAGE_SIZE, "%u\n", geo->cap);
920 } else if (strcmp(attr->name, "read_typ") == 0) { 935 } else if (strcmp(attr->name, "read_typ") == 0) {
@@ -1167,7 +1182,7 @@ int nvme_nvm_register_sysfs(struct nvme_ns *ns)
1167 if (!ndev) 1182 if (!ndev)
1168 return -EINVAL; 1183 return -EINVAL;
1169 1184
1170 switch (geo->ver_id) { 1185 switch (geo->major_ver_id) {
1171 case 1: 1186 case 1:
1172 return sysfs_create_group(&disk_to_dev(ns->disk)->kobj, 1187 return sysfs_create_group(&disk_to_dev(ns->disk)->kobj,
1173 &nvm_dev_attr_group_12); 1188 &nvm_dev_attr_group_12);
@@ -1184,7 +1199,7 @@ void nvme_nvm_unregister_sysfs(struct nvme_ns *ns)
1184 struct nvm_dev *ndev = ns->ndev; 1199 struct nvm_dev *ndev = ns->ndev;
1185 struct nvm_geo *geo = &ndev->geo; 1200 struct nvm_geo *geo = &ndev->geo;
1186 1201
1187 switch (geo->ver_id) { 1202 switch (geo->major_ver_id) {
1188 case 1: 1203 case 1:
1189 sysfs_remove_group(&disk_to_dev(ns->disk)->kobj, 1204 sysfs_remove_group(&disk_to_dev(ns->disk)->kobj,
1190 &nvm_dev_attr_group_12); 1205 &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 {
263/* Instance geometry */ 263/* Instance geometry */
264struct nvm_geo { 264struct nvm_geo {
265 /* device reported version */ 265 /* device reported version */
266 u8 ver_id; 266 u8 major_ver_id;
267 u8 minor_ver_id;
267 268
268 /* instance specific geometry */ 269 /* instance specific geometry */
269 int nr_chnls; 270 int nr_chnls;