aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index ad9f014a086b..52c85f4f672d 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -76,6 +76,28 @@ static blk_qc_t pblk_make_rq(struct request_queue *q, struct bio *bio)
76 return BLK_QC_T_NONE; 76 return BLK_QC_T_NONE;
77} 77}
78 78
79static size_t pblk_trans_map_size(struct pblk *pblk)
80{
81 int entry_size = 8;
82
83 if (pblk->ppaf_bitsize < 32)
84 entry_size = 4;
85
86 return entry_size * pblk->rl.nr_secs;
87}
88
89#ifdef CONFIG_NVM_DEBUG
90static u32 pblk_l2p_crc(struct pblk *pblk)
91{
92 size_t map_size;
93 u32 crc = ~(u32)0;
94
95 map_size = pblk_trans_map_size(pblk);
96 crc = crc32_le(crc, pblk->trans_map, map_size);
97 return crc;
98}
99#endif
100
79static void pblk_l2p_free(struct pblk *pblk) 101static void pblk_l2p_free(struct pblk *pblk)
80{ 102{
81 vfree(pblk->trans_map); 103 vfree(pblk->trans_map);
@@ -85,12 +107,10 @@ static int pblk_l2p_init(struct pblk *pblk)
85{ 107{
86 sector_t i; 108 sector_t i;
87 struct ppa_addr ppa; 109 struct ppa_addr ppa;
88 int entry_size = 8; 110 size_t map_size;
89
90 if (pblk->ppaf_bitsize < 32)
91 entry_size = 4;
92 111
93 pblk->trans_map = vmalloc(entry_size * pblk->rl.nr_secs); 112 map_size = pblk_trans_map_size(pblk);
113 pblk->trans_map = vmalloc(map_size);
94 if (!pblk->trans_map) 114 if (!pblk->trans_map)
95 return -ENOMEM; 115 return -ENOMEM;
96 116
@@ -508,6 +528,10 @@ static int pblk_lines_configure(struct pblk *pblk, int flags)
508 } 528 }
509 } 529 }
510 530
531#ifdef CONFIG_NVM_DEBUG
532 pr_info("pblk init: L2P CRC: %x\n", pblk_l2p_crc(pblk));
533#endif
534
511 /* Free full lines directly as GC has not been started yet */ 535 /* Free full lines directly as GC has not been started yet */
512 pblk_gc_free_full_lines(pblk); 536 pblk_gc_free_full_lines(pblk);
513 537
@@ -901,6 +925,11 @@ static void pblk_exit(void *private)
901 down_write(&pblk_lock); 925 down_write(&pblk_lock);
902 pblk_gc_exit(pblk); 926 pblk_gc_exit(pblk);
903 pblk_tear_down(pblk); 927 pblk_tear_down(pblk);
928
929#ifdef CONFIG_NVM_DEBUG
930 pr_info("pblk exit: L2P CRC: %x\n", pblk_l2p_crc(pblk));
931#endif
932
904 pblk_free(pblk); 933 pblk_free(pblk);
905 up_write(&pblk_lock); 934 up_write(&pblk_lock);
906} 935}