diff options
author | Matias Bjørling <mb@lightnvm.io> | 2018-03-29 18:05:04 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-03-29 19:29:09 -0400 |
commit | 89a09c5643e01f5e5d3c5f2e720053473a60a90b (patch) | |
tree | 4e3c80694912bc336479de619de61a0d3f5d8837 | |
parent | af569398c390810fca773c903a85b71dfd870bb0 (diff) |
lightnvm: remove nvm_dev_ops->max_phys_sect
The value of max_phys_sect is always static. Instead of
defining it in the nvm_dev_ops structure, declare it as a global
value.
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | drivers/lightnvm/core.c | 28 | ||||
-rw-r--r-- | drivers/lightnvm/pblk-init.c | 9 | ||||
-rw-r--r-- | drivers/lightnvm/pblk-recovery.c | 8 | ||||
-rw-r--r-- | drivers/nvme/host/lightnvm.c | 5 | ||||
-rw-r--r-- | include/linux/lightnvm.h | 5 |
5 files changed, 16 insertions, 39 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index a59ad29600c3..9704db219866 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c | |||
@@ -407,7 +407,8 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) | |||
407 | tdisk->private_data = targetdata; | 407 | tdisk->private_data = targetdata; |
408 | tqueue->queuedata = targetdata; | 408 | tqueue->queuedata = targetdata; |
409 | 409 | ||
410 | blk_queue_max_hw_sectors(tqueue, 8 * dev->ops->max_phys_sect); | 410 | blk_queue_max_hw_sectors(tqueue, |
411 | (dev->geo.sec_size >> 9) * NVM_MAX_VLBA); | ||
411 | 412 | ||
412 | set_capacity(tdisk, tt->capacity(targetdata)); | 413 | set_capacity(tdisk, tt->capacity(targetdata)); |
413 | add_disk(tdisk); | 414 | add_disk(tdisk); |
@@ -719,7 +720,7 @@ int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, | |||
719 | struct nvm_rq rqd; | 720 | struct nvm_rq rqd; |
720 | int ret; | 721 | int ret; |
721 | 722 | ||
722 | if (nr_ppas > dev->ops->max_phys_sect) { | 723 | if (nr_ppas > NVM_MAX_VLBA) { |
723 | pr_err("nvm: unable to update all blocks atomically\n"); | 724 | pr_err("nvm: unable to update all blocks atomically\n"); |
724 | return -EINVAL; | 725 | return -EINVAL; |
725 | } | 726 | } |
@@ -740,14 +741,6 @@ int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, | |||
740 | } | 741 | } |
741 | EXPORT_SYMBOL(nvm_set_tgt_bb_tbl); | 742 | EXPORT_SYMBOL(nvm_set_tgt_bb_tbl); |
742 | 743 | ||
743 | int nvm_max_phys_sects(struct nvm_tgt_dev *tgt_dev) | ||
744 | { | ||
745 | struct nvm_dev *dev = tgt_dev->parent; | ||
746 | |||
747 | return dev->ops->max_phys_sect; | ||
748 | } | ||
749 | EXPORT_SYMBOL(nvm_max_phys_sects); | ||
750 | |||
751 | int nvm_submit_io(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) | 744 | int nvm_submit_io(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) |
752 | { | 745 | { |
753 | struct nvm_dev *dev = tgt_dev->parent; | 746 | struct nvm_dev *dev = tgt_dev->parent; |
@@ -965,17 +958,10 @@ int nvm_register(struct nvm_dev *dev) | |||
965 | if (!dev->q || !dev->ops) | 958 | if (!dev->q || !dev->ops) |
966 | return -EINVAL; | 959 | return -EINVAL; |
967 | 960 | ||
968 | if (dev->ops->max_phys_sect > 256) { | 961 | dev->dma_pool = dev->ops->create_dma_pool(dev, "ppalist"); |
969 | pr_info("nvm: max sectors supported is 256.\n"); | 962 | if (!dev->dma_pool) { |
970 | return -EINVAL; | 963 | pr_err("nvm: could not create dma pool\n"); |
971 | } | 964 | return -ENOMEM; |
972 | |||
973 | if (dev->ops->max_phys_sect > 1) { | ||
974 | dev->dma_pool = dev->ops->create_dma_pool(dev, "ppalist"); | ||
975 | if (!dev->dma_pool) { | ||
976 | pr_err("nvm: could not create dma pool\n"); | ||
977 | return -ENOMEM; | ||
978 | } | ||
979 | } | 965 | } |
980 | 966 | ||
981 | ret = nvm_init(dev); | 967 | ret = nvm_init(dev); |
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 141036bd6afa..43b835678f48 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c | |||
@@ -260,8 +260,7 @@ static int pblk_core_init(struct pblk *pblk) | |||
260 | return -ENOMEM; | 260 | return -ENOMEM; |
261 | 261 | ||
262 | /* Internal bios can be at most the sectors signaled by the device. */ | 262 | /* Internal bios can be at most the sectors signaled by the device. */ |
263 | pblk->page_bio_pool = mempool_create_page_pool(nvm_max_phys_sects(dev), | 263 | pblk->page_bio_pool = mempool_create_page_pool(NVM_MAX_VLBA, 0); |
264 | 0); | ||
265 | if (!pblk->page_bio_pool) | 264 | if (!pblk->page_bio_pool) |
266 | goto free_global_caches; | 265 | goto free_global_caches; |
267 | 266 | ||
@@ -716,12 +715,12 @@ static int pblk_lines_init(struct pblk *pblk) | |||
716 | 715 | ||
717 | pblk->min_write_pgs = geo->sec_per_pl * (geo->sec_size / PAGE_SIZE); | 716 | pblk->min_write_pgs = geo->sec_per_pl * (geo->sec_size / PAGE_SIZE); |
718 | max_write_ppas = pblk->min_write_pgs * geo->all_luns; | 717 | max_write_ppas = pblk->min_write_pgs * geo->all_luns; |
719 | pblk->max_write_pgs = (max_write_ppas < nvm_max_phys_sects(dev)) ? | 718 | pblk->max_write_pgs = min_t(int, max_write_ppas, NVM_MAX_VLBA); |
720 | max_write_ppas : nvm_max_phys_sects(dev); | ||
721 | pblk_set_sec_per_write(pblk, pblk->min_write_pgs); | 719 | pblk_set_sec_per_write(pblk, pblk->min_write_pgs); |
722 | 720 | ||
723 | if (pblk->max_write_pgs > PBLK_MAX_REQ_ADDRS) { | 721 | if (pblk->max_write_pgs > PBLK_MAX_REQ_ADDRS) { |
724 | pr_err("pblk: cannot support device max_phys_sect\n"); | 722 | pr_err("pblk: vector list too big(%u > %u)\n", |
723 | pblk->max_write_pgs, PBLK_MAX_REQ_ADDRS); | ||
725 | return -EINVAL; | 724 | return -EINVAL; |
726 | } | 725 | } |
727 | 726 | ||
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index e75a1af2eebe..aaab9a5c17cc 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c | |||
@@ -21,17 +21,15 @@ void pblk_submit_rec(struct work_struct *work) | |||
21 | struct pblk_rec_ctx *recovery = | 21 | struct pblk_rec_ctx *recovery = |
22 | container_of(work, struct pblk_rec_ctx, ws_rec); | 22 | container_of(work, struct pblk_rec_ctx, ws_rec); |
23 | struct pblk *pblk = recovery->pblk; | 23 | struct pblk *pblk = recovery->pblk; |
24 | struct nvm_tgt_dev *dev = pblk->dev; | ||
25 | struct nvm_rq *rqd = recovery->rqd; | 24 | struct nvm_rq *rqd = recovery->rqd; |
26 | struct pblk_c_ctx *c_ctx = nvm_rq_to_pdu(rqd); | 25 | struct pblk_c_ctx *c_ctx = nvm_rq_to_pdu(rqd); |
27 | int max_secs = nvm_max_phys_sects(dev); | ||
28 | struct bio *bio; | 26 | struct bio *bio; |
29 | unsigned int nr_rec_secs; | 27 | unsigned int nr_rec_secs; |
30 | unsigned int pgs_read; | 28 | unsigned int pgs_read; |
31 | int ret; | 29 | int ret; |
32 | 30 | ||
33 | nr_rec_secs = bitmap_weight((unsigned long int *)&rqd->ppa_status, | 31 | nr_rec_secs = bitmap_weight((unsigned long int *)&rqd->ppa_status, |
34 | max_secs); | 32 | NVM_MAX_VLBA); |
35 | 33 | ||
36 | bio = bio_alloc(GFP_KERNEL, nr_rec_secs); | 34 | bio = bio_alloc(GFP_KERNEL, nr_rec_secs); |
37 | 35 | ||
@@ -74,8 +72,6 @@ int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx, | |||
74 | struct pblk_rec_ctx *recovery, u64 *comp_bits, | 72 | struct pblk_rec_ctx *recovery, u64 *comp_bits, |
75 | unsigned int comp) | 73 | unsigned int comp) |
76 | { | 74 | { |
77 | struct nvm_tgt_dev *dev = pblk->dev; | ||
78 | int max_secs = nvm_max_phys_sects(dev); | ||
79 | struct nvm_rq *rec_rqd; | 75 | struct nvm_rq *rec_rqd; |
80 | struct pblk_c_ctx *rec_ctx; | 76 | struct pblk_c_ctx *rec_ctx; |
81 | int nr_entries = c_ctx->nr_valid + c_ctx->nr_padded; | 77 | int nr_entries = c_ctx->nr_valid + c_ctx->nr_padded; |
@@ -86,7 +82,7 @@ int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx, | |||
86 | /* Copy completion bitmap, but exclude the first X completed entries */ | 82 | /* Copy completion bitmap, but exclude the first X completed entries */ |
87 | bitmap_shift_right((unsigned long int *)&rec_rqd->ppa_status, | 83 | bitmap_shift_right((unsigned long int *)&rec_rqd->ppa_status, |
88 | (unsigned long int *)comp_bits, | 84 | (unsigned long int *)comp_bits, |
89 | comp, max_secs); | 85 | comp, NVM_MAX_VLBA); |
90 | 86 | ||
91 | /* Save the context for the entries that need to be re-written and | 87 | /* Save the context for the entries that need to be re-written and |
92 | * update current context with the completed entries. | 88 | * update current context with the completed entries. |
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 8b243af8a949..e38d835b15b5 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c | |||
@@ -612,8 +612,6 @@ static struct nvm_dev_ops nvme_nvm_dev_ops = { | |||
612 | .destroy_dma_pool = nvme_nvm_destroy_dma_pool, | 612 | .destroy_dma_pool = nvme_nvm_destroy_dma_pool, |
613 | .dev_dma_alloc = nvme_nvm_dev_dma_alloc, | 613 | .dev_dma_alloc = nvme_nvm_dev_dma_alloc, |
614 | .dev_dma_free = nvme_nvm_dev_dma_free, | 614 | .dev_dma_free = nvme_nvm_dev_dma_free, |
615 | |||
616 | .max_phys_sect = 64, | ||
617 | }; | 615 | }; |
618 | 616 | ||
619 | static int nvme_nvm_submit_user_cmd(struct request_queue *q, | 617 | static int nvme_nvm_submit_user_cmd(struct request_queue *q, |
@@ -932,8 +930,7 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, | |||
932 | } else if (strcmp(attr->name, "media_capabilities") == 0) { | 930 | } else if (strcmp(attr->name, "media_capabilities") == 0) { |
933 | return scnprintf(page, PAGE_SIZE, "0x%08x\n", id->mccap); | 931 | return scnprintf(page, PAGE_SIZE, "0x%08x\n", id->mccap); |
934 | } else if (strcmp(attr->name, "max_phys_secs") == 0) { | 932 | } else if (strcmp(attr->name, "max_phys_secs") == 0) { |
935 | return scnprintf(page, PAGE_SIZE, "%u\n", | 933 | return scnprintf(page, PAGE_SIZE, "%u\n", NVM_MAX_VLBA); |
936 | ndev->ops->max_phys_sect); | ||
937 | } else { | 934 | } else { |
938 | return scnprintf(page, | 935 | return scnprintf(page, |
939 | PAGE_SIZE, | 936 | PAGE_SIZE, |
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 67b4fa8e4906..e55b10573c99 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h | |||
@@ -73,8 +73,6 @@ struct nvm_dev_ops { | |||
73 | nvm_destroy_dma_pool_fn *destroy_dma_pool; | 73 | nvm_destroy_dma_pool_fn *destroy_dma_pool; |
74 | nvm_dev_dma_alloc_fn *dev_dma_alloc; | 74 | nvm_dev_dma_alloc_fn *dev_dma_alloc; |
75 | nvm_dev_dma_free_fn *dev_dma_free; | 75 | nvm_dev_dma_free_fn *dev_dma_free; |
76 | |||
77 | unsigned int max_phys_sect; | ||
78 | }; | 76 | }; |
79 | 77 | ||
80 | #ifdef CONFIG_NVM | 78 | #ifdef CONFIG_NVM |
@@ -228,6 +226,8 @@ struct nvm_target { | |||
228 | #define NVM_VERSION_MINOR 0 | 226 | #define NVM_VERSION_MINOR 0 |
229 | #define NVM_VERSION_PATCH 0 | 227 | #define NVM_VERSION_PATCH 0 |
230 | 228 | ||
229 | #define NVM_MAX_VLBA (64) /* max logical blocks in a vector command */ | ||
230 | |||
231 | struct nvm_rq; | 231 | struct nvm_rq; |
232 | typedef void (nvm_end_io_fn)(struct nvm_rq *); | 232 | typedef void (nvm_end_io_fn)(struct nvm_rq *); |
233 | 233 | ||
@@ -436,7 +436,6 @@ extern void nvm_unregister(struct nvm_dev *); | |||
436 | 436 | ||
437 | extern int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *, struct ppa_addr *, | 437 | extern int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *, struct ppa_addr *, |
438 | int, int); | 438 | int, int); |
439 | extern int nvm_max_phys_sects(struct nvm_tgt_dev *); | ||
440 | extern int nvm_submit_io(struct nvm_tgt_dev *, struct nvm_rq *); | 439 | extern int nvm_submit_io(struct nvm_tgt_dev *, struct nvm_rq *); |
441 | extern int nvm_submit_io_sync(struct nvm_tgt_dev *, struct nvm_rq *); | 440 | extern int nvm_submit_io_sync(struct nvm_tgt_dev *, struct nvm_rq *); |
442 | extern void nvm_end_io(struct nvm_rq *); | 441 | extern void nvm_end_io(struct nvm_rq *); |