Re: [PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
On 23 April 2015 at 02:30, Peter Pan 潘栋 (peterpandong) wrote: > On Thu, Apr 23, 2015 at 01:51:27PM +, Brian Norris wrote: >> >> On Thu, Apr 16, 2015 at 02:11:24AM +, Peter Pan 潘栋 (peterpandong) >> wrote: >> > The diskonchip driver almost uses the default nand_base hooks as-is, >> > except that it provides custom on-flash BBT descriptors and avoids >> using >> > factory-marked bad blockers. >> > >> > So let's refactor the BBT initialization code into a private >> 'late_init' >> > hook which handles all the private details. Note the usage of >> > NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've >> > prepared everything. >> > >> > Signed-off-by: Brian Norris >> > Signed-off-by: Peter Pan >> >> Why are you just resending my patch? You could Ack/Review/Test it >> instead. (Did you test it?) > > My work is in the 6th patch. > I already tested the patch with micron own nand controller. I don't have > platform with docg4 or diskonchip controller. So the BBT and nand_base.c > part is covered while docg4.c and diskonchip.c not. You can use patch format's comment place to post sth like "Depends on 5 XXX patches from Brian" -- Rafał -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
On 23 April 2015 at 02:30, Peter Pan 潘栋 (peterpandong) peterpand...@micron.com wrote: On Thu, Apr 23, 2015 at 01:51:27PM +, Brian Norris wrote: On Thu, Apr 16, 2015 at 02:11:24AM +, Peter Pan 潘栋 (peterpandong) wrote: The diskonchip driver almost uses the default nand_base hooks as-is, except that it provides custom on-flash BBT descriptors and avoids using factory-marked bad blockers. So let's refactor the BBT initialization code into a private 'late_init' hook which handles all the private details. Note the usage of NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've prepared everything. Signed-off-by: Brian Norris computersforpe...@gmail.com Signed-off-by: Peter Pan peterpand...@micron.com Why are you just resending my patch? You could Ack/Review/Test it instead. (Did you test it?) My work is in the 6th patch. I already tested the patch with micron own nand controller. I don't have platform with docg4 or diskonchip controller. So the BBT and nand_base.c part is covered while docg4.c and diskonchip.c not. You can use patch format's comment place to post sth like Depends on 5 XXX patches from Brian -- Rafał -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
On Thu, Apr 23, 2015 at 01:51:27PM +, Brian Norris wrote: > > On Thu, Apr 16, 2015 at 02:11:24AM +, Peter Pan 潘栋 (peterpandong) > wrote: > > The diskonchip driver almost uses the default nand_base hooks as-is, > > except that it provides custom on-flash BBT descriptors and avoids > using > > factory-marked bad blockers. > > > > So let's refactor the BBT initialization code into a private > 'late_init' > > hook which handles all the private details. Note the usage of > > NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've > > prepared everything. > > > > Signed-off-by: Brian Norris > > Signed-off-by: Peter Pan > > Why are you just resending my patch? You could Ack/Review/Test it > instead. (Did you test it?) My work is in the 6th patch. I already tested the patch with micron own nand controller. I don't have platform with docg4 or diskonchip controller. So the BBT and nand_base.c part is covered while docg4.c and diskonchip.c not. > http://patchwork.ozlabs.org/patch/444605/ > > > --- > > drivers/mtd/nand/diskonchip.c | 27 --- > > 1 file changed, 16 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/mtd/nand/diskonchip.c > b/drivers/mtd/nand/diskonchip.c > > index f68a7bc..e580014 100644 > > --- a/drivers/mtd/nand/diskonchip.c > > +++ b/drivers/mtd/nand/diskonchip.c > > @@ -69,6 +69,9 @@ struct doc_priv { > > int mh0_page; > > int mh1_page; > > struct mtd_info *nextdoc; > > + > > + /* Handle the last stage of initialization (BBT scan, > partitioning) */ > > + int (*late_init)(struct mtd_info *mtd); > > }; > > > > /* This is the syndrome computed by the HW ecc generator upon > reading an empty > > @@ -1294,10 +1297,10 @@ static int __init nftl_scan_bbt(struct > mtd_info *mtd) > > this->bbt_md = NULL; > > } > > > > - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not > set. > > - At least as nand_bbt.c is currently written. */ > > - if ((ret = nand_scan_bbt(mtd, NULL))) > > + ret = this->scan_bbt(mtd); > > + if (ret) > > return ret; > > + > > mtd_device_register(mtd, NULL, 0); > > if (!no_autopart) > > mtd_device_register(mtd, parts, numparts); > > @@ -1344,10 +1347,10 @@ static int __init inftl_scan_bbt(struct > mtd_info *mtd) > > this->bbt_md->pattern = "TBB_SYSM"; > > } > > > > - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not > set. > > - At least as nand_bbt.c is currently written. */ > > - if ((ret = nand_scan_bbt(mtd, NULL))) > > + ret = this->scan_bbt(mtd); > > + if (ret) > > return ret; > > + > > memset((char *)parts, 0, sizeof(parts)); > > numparts = inftl_partscan(mtd, parts); > > /* At least for now, require the INFTL Media Header. We could > probably > > @@ -1369,7 +1372,7 @@ static inline int __init doc2000_init(struct > mtd_info *mtd) > > this->read_byte = doc2000_read_byte; > > this->write_buf = doc2000_writebuf; > > this->read_buf = doc2000_readbuf; > > - this->scan_bbt = nftl_scan_bbt; > > + doc->late_init = nftl_scan_bbt; > > > > doc->CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO; > > doc2000_count_chips(mtd); > > @@ -1396,13 +1399,13 @@ static inline int __init doc2001_init(struct > mtd_info *mtd) > >can have multiple chips. */ > > doc2000_count_chips(mtd); > > mtd->name = "DiskOnChip 2000 (INFTL Model)"; > > - this->scan_bbt = inftl_scan_bbt; > > + doc->late_init = inftl_scan_bbt; > > return (4 * doc->chips_per_floor); > > } else { > > /* Bog-standard Millennium */ > > doc->chips_per_floor = 1; > > mtd->name = "DiskOnChip Millennium"; > > - this->scan_bbt = nftl_scan_bbt; > > + doc->late_init = nftl_scan_bbt; > > return 1; > > } > > } > > @@ -1415,7 +1418,7 @@ static inline int __init > doc2001plus_init(struct mtd_info *mtd) > > this->read_byte = doc2001plus_read_byte; > > this->write_buf = doc2001plus_writebuf; > > this->read_buf = doc2001plus_readbuf; > > - this->scan_bbt = inftl_scan_bbt; > > + doc->late_init = inftl_scan_bbt; > > this->cmd_ctrl = NULL; > > this->select_chip = doc2001plus_select_chip; > > this->cmdfunc = doc2001plus_command; > > @@ -1591,6 +1594,8 @@ static int __init doc_probe(unsigned long > physadr) > > nand->ecc.bytes = 6; > > nand->ecc.strength = 2; > > nand->bbt_options = NAND_BBT_USE_FLASH; > > + /* Skip the automatic BBT scan so we can run it manually */ > > + nand->options |= NAND_SKIP_BBTSCAN; > > > > doc->physadr= physadr; > > doc->virtadr= virtadr; > > @@ -1608,7 +1613,7 @@ static int __init doc_probe(unsigned long > physadr) > > else > > numchips = doc2001_init(mtd); > > > > - if ((ret = nand_scan(mtd, numchips))) { > > + if ((ret
Re: [PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
On Thu, Apr 16, 2015 at 02:11:24AM +, Peter Pan 潘栋 (peterpandong) wrote: > The diskonchip driver almost uses the default nand_base hooks as-is, > except that it provides custom on-flash BBT descriptors and avoids using > factory-marked bad blockers. > > So let's refactor the BBT initialization code into a private 'late_init' > hook which handles all the private details. Note the usage of > NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've > prepared everything. > > Signed-off-by: Brian Norris > Signed-off-by: Peter Pan Why are you just resending my patch? You could Ack/Review/Test it instead. (Did you test it?) http://patchwork.ozlabs.org/patch/444605/ > --- > drivers/mtd/nand/diskonchip.c | 27 --- > 1 file changed, 16 insertions(+), 11 deletions(-) > > diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c > index f68a7bc..e580014 100644 > --- a/drivers/mtd/nand/diskonchip.c > +++ b/drivers/mtd/nand/diskonchip.c > @@ -69,6 +69,9 @@ struct doc_priv { > int mh0_page; > int mh1_page; > struct mtd_info *nextdoc; > + > + /* Handle the last stage of initialization (BBT scan, partitioning) */ > + int (*late_init)(struct mtd_info *mtd); > }; > > /* This is the syndrome computed by the HW ecc generator upon reading an > empty > @@ -1294,10 +1297,10 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) > this->bbt_md = NULL; > } > > - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. > -At least as nand_bbt.c is currently written. */ > - if ((ret = nand_scan_bbt(mtd, NULL))) > + ret = this->scan_bbt(mtd); > + if (ret) > return ret; > + > mtd_device_register(mtd, NULL, 0); > if (!no_autopart) > mtd_device_register(mtd, parts, numparts); > @@ -1344,10 +1347,10 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) > this->bbt_md->pattern = "TBB_SYSM"; > } > > - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. > -At least as nand_bbt.c is currently written. */ > - if ((ret = nand_scan_bbt(mtd, NULL))) > + ret = this->scan_bbt(mtd); > + if (ret) > return ret; > + > memset((char *)parts, 0, sizeof(parts)); > numparts = inftl_partscan(mtd, parts); > /* At least for now, require the INFTL Media Header. We could probably > @@ -1369,7 +1372,7 @@ static inline int __init doc2000_init(struct mtd_info > *mtd) > this->read_byte = doc2000_read_byte; > this->write_buf = doc2000_writebuf; > this->read_buf = doc2000_readbuf; > - this->scan_bbt = nftl_scan_bbt; > + doc->late_init = nftl_scan_bbt; > > doc->CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO; > doc2000_count_chips(mtd); > @@ -1396,13 +1399,13 @@ static inline int __init doc2001_init(struct mtd_info > *mtd) > can have multiple chips. */ > doc2000_count_chips(mtd); > mtd->name = "DiskOnChip 2000 (INFTL Model)"; > - this->scan_bbt = inftl_scan_bbt; > + doc->late_init = inftl_scan_bbt; > return (4 * doc->chips_per_floor); > } else { > /* Bog-standard Millennium */ > doc->chips_per_floor = 1; > mtd->name = "DiskOnChip Millennium"; > - this->scan_bbt = nftl_scan_bbt; > + doc->late_init = nftl_scan_bbt; > return 1; > } > } > @@ -1415,7 +1418,7 @@ static inline int __init doc2001plus_init(struct > mtd_info *mtd) > this->read_byte = doc2001plus_read_byte; > this->write_buf = doc2001plus_writebuf; > this->read_buf = doc2001plus_readbuf; > - this->scan_bbt = inftl_scan_bbt; > + doc->late_init = inftl_scan_bbt; > this->cmd_ctrl = NULL; > this->select_chip = doc2001plus_select_chip; > this->cmdfunc = doc2001plus_command; > @@ -1591,6 +1594,8 @@ static int __init doc_probe(unsigned long physadr) > nand->ecc.bytes = 6; > nand->ecc.strength = 2; > nand->bbt_options = NAND_BBT_USE_FLASH; > + /* Skip the automatic BBT scan so we can run it manually */ > + nand->options |= NAND_SKIP_BBTSCAN; > > doc->physadr= physadr; > doc->virtadr= virtadr; > @@ -1608,7 +1613,7 @@ static int __init doc_probe(unsigned long physadr) > else > numchips = doc2001_init(mtd); > > - if ((ret = nand_scan(mtd, numchips))) { > + if ((ret = nand_scan(mtd, numchips)) || (ret = doc->late_init(mtd))) { > /* DBB note: i believe nand_release is necessary here, as > buffers may have been allocated in nand_base. Check with > Thomas. FIX ME! */ > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
Re: [PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
On Thu, Apr 16, 2015 at 02:11:24AM +, Peter Pan 潘栋 (peterpandong) wrote: The diskonchip driver almost uses the default nand_base hooks as-is, except that it provides custom on-flash BBT descriptors and avoids using factory-marked bad blockers. So let's refactor the BBT initialization code into a private 'late_init' hook which handles all the private details. Note the usage of NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've prepared everything. Signed-off-by: Brian Norris computersforpe...@gmail.com Signed-off-by: Peter Pan peterpand...@micron.com Why are you just resending my patch? You could Ack/Review/Test it instead. (Did you test it?) http://patchwork.ozlabs.org/patch/444605/ --- drivers/mtd/nand/diskonchip.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index f68a7bc..e580014 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -69,6 +69,9 @@ struct doc_priv { int mh0_page; int mh1_page; struct mtd_info *nextdoc; + + /* Handle the last stage of initialization (BBT scan, partitioning) */ + int (*late_init)(struct mtd_info *mtd); }; /* This is the syndrome computed by the HW ecc generator upon reading an empty @@ -1294,10 +1297,10 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) this-bbt_md = NULL; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. -At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this-scan_bbt(mtd); + if (ret) return ret; + mtd_device_register(mtd, NULL, 0); if (!no_autopart) mtd_device_register(mtd, parts, numparts); @@ -1344,10 +1347,10 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) this-bbt_md-pattern = TBB_SYSM; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. -At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this-scan_bbt(mtd); + if (ret) return ret; + memset((char *)parts, 0, sizeof(parts)); numparts = inftl_partscan(mtd, parts); /* At least for now, require the INFTL Media Header. We could probably @@ -1369,7 +1372,7 @@ static inline int __init doc2000_init(struct mtd_info *mtd) this-read_byte = doc2000_read_byte; this-write_buf = doc2000_writebuf; this-read_buf = doc2000_readbuf; - this-scan_bbt = nftl_scan_bbt; + doc-late_init = nftl_scan_bbt; doc-CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO; doc2000_count_chips(mtd); @@ -1396,13 +1399,13 @@ static inline int __init doc2001_init(struct mtd_info *mtd) can have multiple chips. */ doc2000_count_chips(mtd); mtd-name = DiskOnChip 2000 (INFTL Model); - this-scan_bbt = inftl_scan_bbt; + doc-late_init = inftl_scan_bbt; return (4 * doc-chips_per_floor); } else { /* Bog-standard Millennium */ doc-chips_per_floor = 1; mtd-name = DiskOnChip Millennium; - this-scan_bbt = nftl_scan_bbt; + doc-late_init = nftl_scan_bbt; return 1; } } @@ -1415,7 +1418,7 @@ static inline int __init doc2001plus_init(struct mtd_info *mtd) this-read_byte = doc2001plus_read_byte; this-write_buf = doc2001plus_writebuf; this-read_buf = doc2001plus_readbuf; - this-scan_bbt = inftl_scan_bbt; + doc-late_init = inftl_scan_bbt; this-cmd_ctrl = NULL; this-select_chip = doc2001plus_select_chip; this-cmdfunc = doc2001plus_command; @@ -1591,6 +1594,8 @@ static int __init doc_probe(unsigned long physadr) nand-ecc.bytes = 6; nand-ecc.strength = 2; nand-bbt_options = NAND_BBT_USE_FLASH; + /* Skip the automatic BBT scan so we can run it manually */ + nand-options |= NAND_SKIP_BBTSCAN; doc-physadr= physadr; doc-virtadr= virtadr; @@ -1608,7 +1613,7 @@ static int __init doc_probe(unsigned long physadr) else numchips = doc2001_init(mtd); - if ((ret = nand_scan(mtd, numchips))) { + if ((ret = nand_scan(mtd, numchips)) || (ret = doc-late_init(mtd))) { /* DBB note: i believe nand_release is necessary here, as buffers may have been allocated in nand_base. Check with Thomas. FIX ME! */ -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at
RE: [PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
On Thu, Apr 23, 2015 at 01:51:27PM +, Brian Norris wrote: On Thu, Apr 16, 2015 at 02:11:24AM +, Peter Pan 潘栋 (peterpandong) wrote: The diskonchip driver almost uses the default nand_base hooks as-is, except that it provides custom on-flash BBT descriptors and avoids using factory-marked bad blockers. So let's refactor the BBT initialization code into a private 'late_init' hook which handles all the private details. Note the usage of NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've prepared everything. Signed-off-by: Brian Norris computersforpe...@gmail.com Signed-off-by: Peter Pan peterpand...@micron.com Why are you just resending my patch? You could Ack/Review/Test it instead. (Did you test it?) My work is in the 6th patch. I already tested the patch with micron own nand controller. I don't have platform with docg4 or diskonchip controller. So the BBT and nand_base.c part is covered while docg4.c and diskonchip.c not. http://patchwork.ozlabs.org/patch/444605/ --- drivers/mtd/nand/diskonchip.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index f68a7bc..e580014 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -69,6 +69,9 @@ struct doc_priv { int mh0_page; int mh1_page; struct mtd_info *nextdoc; + + /* Handle the last stage of initialization (BBT scan, partitioning) */ + int (*late_init)(struct mtd_info *mtd); }; /* This is the syndrome computed by the HW ecc generator upon reading an empty @@ -1294,10 +1297,10 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) this-bbt_md = NULL; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. - At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this-scan_bbt(mtd); + if (ret) return ret; + mtd_device_register(mtd, NULL, 0); if (!no_autopart) mtd_device_register(mtd, parts, numparts); @@ -1344,10 +1347,10 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) this-bbt_md-pattern = TBB_SYSM; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. - At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this-scan_bbt(mtd); + if (ret) return ret; + memset((char *)parts, 0, sizeof(parts)); numparts = inftl_partscan(mtd, parts); /* At least for now, require the INFTL Media Header. We could probably @@ -1369,7 +1372,7 @@ static inline int __init doc2000_init(struct mtd_info *mtd) this-read_byte = doc2000_read_byte; this-write_buf = doc2000_writebuf; this-read_buf = doc2000_readbuf; - this-scan_bbt = nftl_scan_bbt; + doc-late_init = nftl_scan_bbt; doc-CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO; doc2000_count_chips(mtd); @@ -1396,13 +1399,13 @@ static inline int __init doc2001_init(struct mtd_info *mtd) can have multiple chips. */ doc2000_count_chips(mtd); mtd-name = DiskOnChip 2000 (INFTL Model); - this-scan_bbt = inftl_scan_bbt; + doc-late_init = inftl_scan_bbt; return (4 * doc-chips_per_floor); } else { /* Bog-standard Millennium */ doc-chips_per_floor = 1; mtd-name = DiskOnChip Millennium; - this-scan_bbt = nftl_scan_bbt; + doc-late_init = nftl_scan_bbt; return 1; } } @@ -1415,7 +1418,7 @@ static inline int __init doc2001plus_init(struct mtd_info *mtd) this-read_byte = doc2001plus_read_byte; this-write_buf = doc2001plus_writebuf; this-read_buf = doc2001plus_readbuf; - this-scan_bbt = inftl_scan_bbt; + doc-late_init = inftl_scan_bbt; this-cmd_ctrl = NULL; this-select_chip = doc2001plus_select_chip; this-cmdfunc = doc2001plus_command; @@ -1591,6 +1594,8 @@ static int __init doc_probe(unsigned long physadr) nand-ecc.bytes = 6; nand-ecc.strength = 2; nand-bbt_options = NAND_BBT_USE_FLASH; + /* Skip the automatic BBT scan so we can run it manually */ + nand-options |= NAND_SKIP_BBTSCAN; doc-physadr= physadr; doc-virtadr= virtadr; @@ -1608,7 +1613,7 @@ static int __init doc_probe(unsigned long physadr) else numchips = doc2001_init(mtd); - if ((ret = nand_scan(mtd, numchips))) { + if ((ret = nand_scan(mtd, numchips)) || (ret = doc- late_init(mtd))) { /* DBB note: i believe nand_release is necessary here, as buffers may have been allocated in nand_base. Check with
[PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
The diskonchip driver almost uses the default nand_base hooks as-is, except that it provides custom on-flash BBT descriptors and avoids using factory-marked bad blockers. So let's refactor the BBT initialization code into a private 'late_init' hook which handles all the private details. Note the usage of NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've prepared everything. Signed-off-by: Brian Norris Signed-off-by: Peter Pan --- drivers/mtd/nand/diskonchip.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index f68a7bc..e580014 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -69,6 +69,9 @@ struct doc_priv { int mh0_page; int mh1_page; struct mtd_info *nextdoc; + + /* Handle the last stage of initialization (BBT scan, partitioning) */ + int (*late_init)(struct mtd_info *mtd); }; /* This is the syndrome computed by the HW ecc generator upon reading an empty @@ -1294,10 +1297,10 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) this->bbt_md = NULL; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. - At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this->scan_bbt(mtd); + if (ret) return ret; + mtd_device_register(mtd, NULL, 0); if (!no_autopart) mtd_device_register(mtd, parts, numparts); @@ -1344,10 +1347,10 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) this->bbt_md->pattern = "TBB_SYSM"; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. - At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this->scan_bbt(mtd); + if (ret) return ret; + memset((char *)parts, 0, sizeof(parts)); numparts = inftl_partscan(mtd, parts); /* At least for now, require the INFTL Media Header. We could probably @@ -1369,7 +1372,7 @@ static inline int __init doc2000_init(struct mtd_info *mtd) this->read_byte = doc2000_read_byte; this->write_buf = doc2000_writebuf; this->read_buf = doc2000_readbuf; - this->scan_bbt = nftl_scan_bbt; + doc->late_init = nftl_scan_bbt; doc->CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO; doc2000_count_chips(mtd); @@ -1396,13 +1399,13 @@ static inline int __init doc2001_init(struct mtd_info *mtd) can have multiple chips. */ doc2000_count_chips(mtd); mtd->name = "DiskOnChip 2000 (INFTL Model)"; - this->scan_bbt = inftl_scan_bbt; + doc->late_init = inftl_scan_bbt; return (4 * doc->chips_per_floor); } else { /* Bog-standard Millennium */ doc->chips_per_floor = 1; mtd->name = "DiskOnChip Millennium"; - this->scan_bbt = nftl_scan_bbt; + doc->late_init = nftl_scan_bbt; return 1; } } @@ -1415,7 +1418,7 @@ static inline int __init doc2001plus_init(struct mtd_info *mtd) this->read_byte = doc2001plus_read_byte; this->write_buf = doc2001plus_writebuf; this->read_buf = doc2001plus_readbuf; - this->scan_bbt = inftl_scan_bbt; + doc->late_init = inftl_scan_bbt; this->cmd_ctrl = NULL; this->select_chip = doc2001plus_select_chip; this->cmdfunc = doc2001plus_command; @@ -1591,6 +1594,8 @@ static int __init doc_probe(unsigned long physadr) nand->ecc.bytes = 6; nand->ecc.strength = 2; nand->bbt_options = NAND_BBT_USE_FLASH; + /* Skip the automatic BBT scan so we can run it manually */ + nand->options |= NAND_SKIP_BBTSCAN; doc->physadr= physadr; doc->virtadr= virtadr; @@ -1608,7 +1613,7 @@ static int __init doc_probe(unsigned long physadr) else numchips = doc2001_init(mtd); - if ((ret = nand_scan(mtd, numchips))) { + if ((ret = nand_scan(mtd, numchips)) || (ret = doc->late_init(mtd))) { /* DBB note: i believe nand_release is necessary here, as buffers may have been allocated in nand_base. Check with Thomas. FIX ME! */ -- 1.9.1
[PATCH 2/6] mtd: diskonchip: don't call nand_scan_bbt() directly
The diskonchip driver almost uses the default nand_base hooks as-is, except that it provides custom on-flash BBT descriptors and avoids using factory-marked bad blockers. So let's refactor the BBT initialization code into a private 'late_init' hook which handles all the private details. Note the usage of NAND_SKIP_BBTSCAN, which allows us to defer the BBT scan until we've prepared everything. Signed-off-by: Brian Norris computersforpe...@gmail.com Signed-off-by: Peter Pan peterpand...@micron.com --- drivers/mtd/nand/diskonchip.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index f68a7bc..e580014 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -69,6 +69,9 @@ struct doc_priv { int mh0_page; int mh1_page; struct mtd_info *nextdoc; + + /* Handle the last stage of initialization (BBT scan, partitioning) */ + int (*late_init)(struct mtd_info *mtd); }; /* This is the syndrome computed by the HW ecc generator upon reading an empty @@ -1294,10 +1297,10 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) this-bbt_md = NULL; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. - At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this-scan_bbt(mtd); + if (ret) return ret; + mtd_device_register(mtd, NULL, 0); if (!no_autopart) mtd_device_register(mtd, parts, numparts); @@ -1344,10 +1347,10 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) this-bbt_md-pattern = TBB_SYSM; } - /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set. - At least as nand_bbt.c is currently written. */ - if ((ret = nand_scan_bbt(mtd, NULL))) + ret = this-scan_bbt(mtd); + if (ret) return ret; + memset((char *)parts, 0, sizeof(parts)); numparts = inftl_partscan(mtd, parts); /* At least for now, require the INFTL Media Header. We could probably @@ -1369,7 +1372,7 @@ static inline int __init doc2000_init(struct mtd_info *mtd) this-read_byte = doc2000_read_byte; this-write_buf = doc2000_writebuf; this-read_buf = doc2000_readbuf; - this-scan_bbt = nftl_scan_bbt; + doc-late_init = nftl_scan_bbt; doc-CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO; doc2000_count_chips(mtd); @@ -1396,13 +1399,13 @@ static inline int __init doc2001_init(struct mtd_info *mtd) can have multiple chips. */ doc2000_count_chips(mtd); mtd-name = DiskOnChip 2000 (INFTL Model); - this-scan_bbt = inftl_scan_bbt; + doc-late_init = inftl_scan_bbt; return (4 * doc-chips_per_floor); } else { /* Bog-standard Millennium */ doc-chips_per_floor = 1; mtd-name = DiskOnChip Millennium; - this-scan_bbt = nftl_scan_bbt; + doc-late_init = nftl_scan_bbt; return 1; } } @@ -1415,7 +1418,7 @@ static inline int __init doc2001plus_init(struct mtd_info *mtd) this-read_byte = doc2001plus_read_byte; this-write_buf = doc2001plus_writebuf; this-read_buf = doc2001plus_readbuf; - this-scan_bbt = inftl_scan_bbt; + doc-late_init = inftl_scan_bbt; this-cmd_ctrl = NULL; this-select_chip = doc2001plus_select_chip; this-cmdfunc = doc2001plus_command; @@ -1591,6 +1594,8 @@ static int __init doc_probe(unsigned long physadr) nand-ecc.bytes = 6; nand-ecc.strength = 2; nand-bbt_options = NAND_BBT_USE_FLASH; + /* Skip the automatic BBT scan so we can run it manually */ + nand-options |= NAND_SKIP_BBTSCAN; doc-physadr= physadr; doc-virtadr= virtadr; @@ -1608,7 +1613,7 @@ static int __init doc_probe(unsigned long physadr) else numchips = doc2001_init(mtd); - if ((ret = nand_scan(mtd, numchips))) { + if ((ret = nand_scan(mtd, numchips)) || (ret = doc-late_init(mtd))) { /* DBB note: i believe nand_release is necessary here, as buffers may have been allocated in nand_base. Check with Thomas. FIX ME! */ -- 1.9.1