Skip to contentSkip to conversation

lightnvm: calculate device values correctly

PATCH In review Wenwei Tao 2 participants 4 messages Nov 22, 2015 – Nov 23, 2015

lore
Share & tools
lore

Wenwei Tao

author
#0 lore raw

PATCH 1/1 lightnvm: calculate device values correctly

In the original calculation, the relationships among block, plane and lun was confusing, refine it on the basis of Open-channelSSDInterfaceSpecification.

---
 drivers/lightnvm/core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/lightnvm/core.c +4 -5
index f659e60..1864b94 100644
@@ -174,8 +174,8 @@ static int nvm_core_init(struct nvm_dev *dev)
 	dev->nr_chnls = grp->num_ch;
 	dev->luns_per_chnl = grp->num_lun;
 	dev->pgs_per_blk = grp->num_pg;
-	dev->blks_per_lun = grp->num_blk;
 	dev->nr_planes = grp->num_pln;
+	dev->blks_per_lun = grp->num_blk * grp->num_pln;
 	dev->sec_size = grp->csecs;
 	dev->oob_size = grp->sos;
 	dev->sec_per_pg = grp->fpg_sz / grp->csecs;
@@ -191,13 +191,12 @@ static int nvm_core_init(struct nvm_dev *dev)
 		dev->plane_mode = NVM_PLANE_QUAD;
 
 	/* calculated values */
-	dev->sec_per_pl = dev->sec_per_pg * dev->nr_planes;
-	dev->sec_per_blk = dev->sec_per_pl * dev->pgs_per_blk;
+	dev->sec_per_blk = dev->sec_per_pg * dev->pgs_per_blk;
+	dev->sec_per_pl = dev->sec_per_blk * grp->num_blk;
 	dev->sec_per_lun = dev->sec_per_blk * dev->blks_per_lun;
 	dev->nr_luns = dev->luns_per_chnl * dev->nr_chnls;
 
-	dev->total_blocks = dev->nr_planes *
-				dev->blks_per_lun *
+	dev->total_blocks = dev->blks_per_lun *
 				dev->luns_per_chnl *
 				dev->nr_chnls;
 	dev->total_pages = dev->total_blocks * dev->pgs_per_blk;
Signature · 1 line
1.9.1
author
#1 lore raw

I'm a new guy to flash, if I'm wrong about this patch, please correct me. Thanks.

2015-11-22 21:51 GMT+08:00 Wenwei Tao <[email protected]>:

Quoted 43 lines

In the original calculation, the relationships among block, plane and lun was confusing, refine it on the basis of Open-channelSSDInterfaceSpecification.

---
 drivers/lightnvm/core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/lightnvm/core.c +4 -6
index f659e60..1864b94 100644
@@ -174,8 +174,8 @@ static int nvm_core_init(struct nvm_dev *dev)
        dev->nr_chnls = grp->num_ch;
        dev->luns_per_chnl = grp->num_lun;
        dev->pgs_per_blk = grp->num_pg;
-       dev->blks_per_lun = grp->num_blk;
        dev->nr_planes = grp->num_pln;
+       dev->blks_per_lun = grp->num_blk * grp->num_pln;
        dev->sec_size = grp->csecs;
        dev->oob_size = grp->sos;
        dev->sec_per_pg = grp->fpg_sz / grp->csecs;
@@ -191,13 +191,12 @@ static int nvm_core_init(struct nvm_dev *dev)
                dev->plane_mode = NVM_PLANE_QUAD;
 
        /* calculated values */
-       dev->sec_per_pl = dev->sec_per_pg * dev->nr_planes;
-       dev->sec_per_blk = dev->sec_per_pl * dev->pgs_per_blk;
+       dev->sec_per_blk = dev->sec_per_pg * dev->pgs_per_blk;
+       dev->sec_per_pl = dev->sec_per_blk * grp->num_blk;
        dev->sec_per_lun = dev->sec_per_blk * dev->blks_per_lun;
        dev->nr_luns = dev->luns_per_chnl * dev->nr_chnls;
 
-       dev->total_blocks = dev->nr_planes *
-                               dev->blks_per_lun *
+       dev->total_blocks = dev->blks_per_lun *
                                dev->luns_per_chnl *
                                dev->nr_chnls;
        dev->total_pages = dev->total_blocks * dev->pgs_per_blk;
--

1.9.1

#2 lore raw
In reply to Wenwei Tao
Quoted 31 lines · Wenwei Tao

In the original calculation, the relationships among block, plane and lun was confusing, refine it on the basis of Open-channelSSDInterfaceSpecification.

---
  drivers/lightnvm/core.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
drivers/lightnvm/core.c +2 -3
index f659e60..1864b94 100644
@@ -174,8 +174,8 @@ static int nvm_core_init(struct nvm_dev *dev)
  	dev->nr_chnls = grp->num_ch;
  	dev->luns_per_chnl = grp->num_lun;
  	dev->pgs_per_blk = grp->num_pg;
-	dev->blks_per_lun = grp->num_blk;
  	dev->nr_planes = grp->num_pln;
+	dev->blks_per_lun = grp->num_blk * grp->num_pln;
  	dev->sec_size = grp->csecs;
  	dev->oob_size = grp->sos;
  	dev->sec_per_pg = grp->fpg_sz / grp->csecs;
@@ -191,13 +191,12 @@ static int nvm_core_init(struct nvm_dev *dev)
  		dev->plane_mode = NVM_PLANE_QUAD;
 
  	/* calculated values */
-	dev->sec_per_pl = dev->sec_per_pg * dev->nr_planes;
-	dev->sec_per_blk = dev->sec_per_pl * dev->pgs_per_blk;
+	dev->sec_per_blk = dev->sec_per_pg * dev->pgs_per_blk;

drivers/lightnvm/core.c static int nvm_core_init(struct nvm_dev *dev) · line 202

Quoted 10 lines
drivers/lightnvm/core.c +2 -2
+	dev->sec_per_pl = dev->sec_per_blk * grp->num_blk;
  	dev->sec_per_lun = dev->sec_per_blk * dev->blks_per_lun;
  	dev->nr_luns = dev->luns_per_chnl * dev->nr_chnls;
 
-	dev->total_blocks = dev->nr_planes *
-				dev->blks_per_lun *
+	dev->total_blocks = dev->blks_per_lun *
  				dev->luns_per_chnl *
  				dev->nr_chnls;
  	dev->total_pages = dev->total_blocks * dev->pgs_per_blk;

The reason I had it as before, was because I wanted to drive the device in either single/double/quad read/write/erase plane mode. That way we could get away with only managing 1/4 or 1/2 of the block metadata.

What is your use case? It could make sense, but it will require a little more work to build up the framework for having the various modes. i.e. detect supported plane mode, make a explicit decision about which plane mode to always use (or dynamically) and afterwards allocate the appropriate data structures.

author
#3 lore raw

OK, I see. Thanks for the explanation.

2015-11-23 2:34 GMT+08:00 Matias <[email protected]>:

Quoted 53 lines · Wenwei Tao
Quoted 32 lines

In the original calculation, the relationships among block, plane and lun was confusing, refine it on the basis of Open-channelSSDInterfaceSpecification.

---
  drivers/lightnvm/core.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
drivers/lightnvm/core.c +2 -3
index f659e60..1864b94 100644
@@ -174,8 +174,8 @@ static int nvm_core_init(struct nvm_dev *dev)
        dev->nr_chnls = grp->num_ch;
        dev->luns_per_chnl = grp->num_lun;
        dev->pgs_per_blk = grp->num_pg;
-       dev->blks_per_lun = grp->num_blk;
        dev->nr_planes = grp->num_pln;
+       dev->blks_per_lun = grp->num_blk * grp->num_pln;
        dev->sec_size = grp->csecs;
        dev->oob_size = grp->sos;
        dev->sec_per_pg = grp->fpg_sz / grp->csecs;
@@ -191,13 +191,12 @@ static int nvm_core_init(struct nvm_dev *dev)
                dev->plane_mode = NVM_PLANE_QUAD;
 
        /* calculated values */
-       dev->sec_per_pl = dev->sec_per_pg * dev->nr_planes;
-       dev->sec_per_blk = dev->sec_per_pl * dev->pgs_per_blk;
+       dev->sec_per_blk = dev->sec_per_pg * dev->pgs_per_blk;

drivers/lightnvm/core.c static int nvm_core_init(struct nvm_dev *dev) · line 202

Quoted 10 lines
drivers/lightnvm/core.c +2 -2
+       dev->sec_per_pl = dev->sec_per_blk * grp->num_blk;
        dev->sec_per_lun = dev->sec_per_blk * dev->blks_per_lun;
        dev->nr_luns = dev->luns_per_chnl * dev->nr_chnls;
 
-       dev->total_blocks = dev->nr_planes *
-                               dev->blks_per_lun *
+       dev->total_blocks = dev->blks_per_lun *
                                dev->luns_per_chnl *
                                dev->nr_chnls;
        dev->total_pages = dev->total_blocks * dev->pgs_per_blk;

The reason I had it as before, was because I wanted to drive the device in either single/double/quad read/write/erase plane mode. That way we could get away with only managing 1/4 or 1/2 of the block metadata.

What is your use case? It could make sense, but it will require a little more work to build up the framework for having the various modes. i.e. detect supported plane mode, make a explicit decision about which plane mode to always use (or dynamically) and afterwards allocate the appropriate data structures.