Commit 19bd6fe7 authored by Matias Bjørling's avatar Matias Bjørling Committed by Jens Axboe

lightnvm: reduce number of nvm_id groups to one

The number of configuration groups has been limited to one in current
code, even if there is support for up to four. With the introduction
of the open-channel SSD 1.3 specification, only a single
group is exposed onwards. Reflect this in the nvm_id structure.
Signed-off-by: default avatarMatias Bjørling <matias@cnexlabs.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent dab8ee9e
...@@ -460,7 +460,6 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id) ...@@ -460,7 +460,6 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id)
id->ver_id = 0x1; id->ver_id = 0x1;
id->vmnt = 0; id->vmnt = 0;
id->cgrps = 1;
id->cap = 0x2; id->cap = 0x2;
id->dom = 0x1; id->dom = 0x1;
...@@ -479,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id) ...@@ -479,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id)
sector_div(size, bs); /* convert size to pages */ sector_div(size, bs); /* convert size to pages */
size >>= 8; /* concert size to pgs pr blk */ size >>= 8; /* concert size to pgs pr blk */
grp = &id->groups[0]; grp = &id->grp;
grp->mtype = 0; grp->mtype = 0;
grp->fmtype = 0; grp->fmtype = 0;
grp->num_ch = 1; grp->num_ch = 1;
......
...@@ -884,7 +884,7 @@ static int nvm_init_mlc_tbl(struct nvm_dev *dev, struct nvm_id_group *grp) ...@@ -884,7 +884,7 @@ static int nvm_init_mlc_tbl(struct nvm_dev *dev, struct nvm_id_group *grp)
static int nvm_core_init(struct nvm_dev *dev) static int nvm_core_init(struct nvm_dev *dev)
{ {
struct nvm_id *id = &dev->identity; struct nvm_id *id = &dev->identity;
struct nvm_id_group *grp = &id->groups[0]; struct nvm_id_group *grp = &id->grp;
struct nvm_geo *geo = &dev->geo; struct nvm_geo *geo = &dev->geo;
int ret; int ret;
...@@ -988,20 +988,14 @@ static int nvm_init(struct nvm_dev *dev) ...@@ -988,20 +988,14 @@ static int nvm_init(struct nvm_dev *dev)
goto err; goto err;
} }
pr_debug("nvm: ver:%x nvm_vendor:%x groups:%u\n", pr_debug("nvm: ver:%x nvm_vendor:%x\n",
dev->identity.ver_id, dev->identity.vmnt, dev->identity.ver_id, dev->identity.vmnt);
dev->identity.cgrps);
if (dev->identity.ver_id != 1) { if (dev->identity.ver_id != 1) {
pr_err("nvm: device not supported by kernel."); pr_err("nvm: device not supported by kernel.");
goto err; goto err;
} }
if (dev->identity.cgrps != 1) {
pr_err("nvm: only one group configuration supported.");
goto err;
}
ret = nvm_core_init(dev); ret = nvm_core_init(dev);
if (ret) { if (ret) {
pr_err("nvm: could not initialize core structures.\n"); pr_err("nvm: could not initialize core structures.\n");
......
...@@ -248,50 +248,48 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id) ...@@ -248,50 +248,48 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
{ {
struct nvme_nvm_id_group *src; struct nvme_nvm_id_group *src;
struct nvm_id_group *dst; struct nvm_id_group *dst;
int i, end;
if (nvme_nvm_id->cgrps != 1)
end = min_t(u32, 4, nvm_id->cgrps); return -EINVAL;
for (i = 0; i < end; i++) { src = &nvme_nvm_id->groups[0];
src = &nvme_nvm_id->groups[i]; dst = &nvm_id->grp;
dst = &nvm_id->groups[i];
dst->mtype = src->mtype;
dst->mtype = src->mtype; dst->fmtype = src->fmtype;
dst->fmtype = src->fmtype; dst->num_ch = src->num_ch;
dst->num_ch = src->num_ch; dst->num_lun = src->num_lun;
dst->num_lun = src->num_lun; dst->num_pln = src->num_pln;
dst->num_pln = src->num_pln;
dst->num_pg = le16_to_cpu(src->num_pg);
dst->num_pg = le16_to_cpu(src->num_pg); dst->num_blk = le16_to_cpu(src->num_blk);
dst->num_blk = le16_to_cpu(src->num_blk); dst->fpg_sz = le16_to_cpu(src->fpg_sz);
dst->fpg_sz = le16_to_cpu(src->fpg_sz); dst->csecs = le16_to_cpu(src->csecs);
dst->csecs = le16_to_cpu(src->csecs); dst->sos = le16_to_cpu(src->sos);
dst->sos = le16_to_cpu(src->sos);
dst->trdt = le32_to_cpu(src->trdt);
dst->trdt = le32_to_cpu(src->trdt); dst->trdm = le32_to_cpu(src->trdm);
dst->trdm = le32_to_cpu(src->trdm); dst->tprt = le32_to_cpu(src->tprt);
dst->tprt = le32_to_cpu(src->tprt); dst->tprm = le32_to_cpu(src->tprm);
dst->tprm = le32_to_cpu(src->tprm); dst->tbet = le32_to_cpu(src->tbet);
dst->tbet = le32_to_cpu(src->tbet); dst->tbem = le32_to_cpu(src->tbem);
dst->tbem = le32_to_cpu(src->tbem); dst->mpos = le32_to_cpu(src->mpos);
dst->mpos = le32_to_cpu(src->mpos); dst->mccap = le32_to_cpu(src->mccap);
dst->mccap = le32_to_cpu(src->mccap);
dst->cpar = le16_to_cpu(src->cpar);
dst->cpar = le16_to_cpu(src->cpar);
if (dst->fmtype == NVM_ID_FMTYPE_MLC) {
if (dst->fmtype == NVM_ID_FMTYPE_MLC) { memcpy(dst->lptbl.id, src->lptbl.id, 8);
memcpy(dst->lptbl.id, src->lptbl.id, 8); dst->lptbl.mlc.num_pairs =
dst->lptbl.mlc.num_pairs = le16_to_cpu(src->lptbl.mlc.num_pairs);
le16_to_cpu(src->lptbl.mlc.num_pairs);
if (dst->lptbl.mlc.num_pairs > NVME_NVM_LP_MLC_PAIRS) {
if (dst->lptbl.mlc.num_pairs > NVME_NVM_LP_MLC_PAIRS) { pr_err("nvm: number of MLC pairs not supported\n");
pr_err("nvm: number of MLC pairs not supported\n"); return -EINVAL;
return -EINVAL;
}
memcpy(dst->lptbl.mlc.pairs, src->lptbl.mlc.pairs,
dst->lptbl.mlc.num_pairs);
} }
memcpy(dst->lptbl.mlc.pairs, src->lptbl.mlc.pairs,
dst->lptbl.mlc.num_pairs);
} }
return 0; return 0;
...@@ -321,7 +319,6 @@ static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id) ...@@ -321,7 +319,6 @@ static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id)
nvm_id->ver_id = nvme_nvm_id->ver_id; nvm_id->ver_id = nvme_nvm_id->ver_id;
nvm_id->vmnt = nvme_nvm_id->vmnt; nvm_id->vmnt = nvme_nvm_id->vmnt;
nvm_id->cgrps = nvme_nvm_id->cgrps;
nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap); nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap);
nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom); nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom);
memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf, memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf,
...@@ -622,7 +619,7 @@ static ssize_t nvm_dev_attr_show(struct device *dev, ...@@ -622,7 +619,7 @@ static ssize_t nvm_dev_attr_show(struct device *dev,
return 0; return 0;
id = &ndev->identity; id = &ndev->identity;
grp = &id->groups[0]; grp = &id->grp;
attr = &dattr->attr; attr = &dattr->attr;
if (strcmp(attr->name, "version") == 0) { if (strcmp(attr->name, "version") == 0) {
......
...@@ -200,11 +200,10 @@ struct nvm_addr_format { ...@@ -200,11 +200,10 @@ struct nvm_addr_format {
struct nvm_id { struct nvm_id {
u8 ver_id; u8 ver_id;
u8 vmnt; u8 vmnt;
u8 cgrps;
u32 cap; u32 cap;
u32 dom; u32 dom;
struct nvm_addr_format ppaf; struct nvm_addr_format ppaf;
struct nvm_id_group groups[4]; struct nvm_id_group grp;
} __packed; } __packed;
struct nvm_target { struct nvm_target {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment