From: Brian Norris <computersforpeace@gmail.com>
To: Zhou Wang <wangzhou.bry@gmail.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
pawel.moll@arm.com, ijc+devicetree@hellion.org.uk,
linux-kernel@vger.kernel.org, haojian.zhuang@gmail.com,
wangzhou1@hisilicon.com, robh+dt@kernel.org,
linux-mtd@lists.infradead.org, xuwei5@hisilicon.com,
galak@codeaurora.org, caizhiyong@huawei.com,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v4 1/2] mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc
Date: Mon, 1 Dec 2014 10:14:49 -0800 [thread overview]
Message-ID: <20141201181449.GG21347@ld-irv-0074> (raw)
In-Reply-To: <547C685A.3090804@gmail.com>
On Mon, Dec 01, 2014 at 09:08:42PM +0800, Zhou Wang wrote:
> On 2014年11月30日 17:35, Brian Norris wrote:
> >On Tue, Nov 04, 2014 at 08:47:00PM +0800, Zhou Wang wrote:
> >>Signed-off-by: Zhou Wang <wangzhou.bry@gmail.com>
[...]
> >>+static void hisi_nfc_dma_transfer(struct hinfc_host *host, int todev)
> >>+{
> >>+ struct mtd_info *mtd = &host->mtd;
> >>+ struct nand_chip *chip = mtd->priv;
> >>+ unsigned long val;
> >>+ int ret;
> >>+
> >>+ hinfc_write(host, host->dma_buffer, HINFC504_DMA_ADDR_DATA);
> >>+ hinfc_write(host, host->dma_oob, HINFC504_DMA_ADDR_OOB);
> >>+
> >>+ if (chip->ecc.mode == NAND_ECC_NONE) {
> >>+ hinfc_write(host, ((mtd->oobsize & HINFC504_DMA_LEN_OOB_MASK)
> >>+ << HINFC504_DMA_LEN_OOB_SHIFT), HINFC504_DMA_LEN);
> >>+
> >>+ hinfc_write(host, HINFC504_DMA_PARA_DATA_RW_EN
> >>+ | HINFC504_DMA_PARA_OOB_RW_EN, HINFC504_DMA_PARA);
> >>+ } else {
> >>+ hinfc_write(host, HINFC504_DMA_PARA_DATA_RW_EN
> >>+ | HINFC504_DMA_PARA_OOB_RW_EN | HINFC504_DMA_PARA_DATA_EDC_EN
> >>+ | HINFC504_DMA_PARA_OOB_EDC_EN | HINFC504_DMA_PARA_DATA_ECC_EN
> >>+ | HINFC504_DMA_PARA_OOB_ECC_EN, HINFC504_DMA_PARA);
> >>+ }
> >>+
> >>+ val = (HINFC504_DMA_CTRL_DMA_START | HINFC504_DMA_CTRL_BURST4_EN
> >>+ | HINFC504_DMA_CTRL_BURST8_EN | HINFC504_DMA_CTRL_BURST16_EN
> >>+ | HINFC504_DMA_CTRL_DATA_AREA_EN | HINFC504_DMA_CTRL_OOB_AREA_EN
> >>+ | ((host->addr_cycle == 4 ? 1 : 0)
> >>+ << HINFC504_DMA_CTRL_ADDR_NUM_SHIFT)
> >>+ | ((host->chipselect & HINFC504_DMA_CTRL_CS_MASK)
> >>+ << HINFC504_DMA_CTRL_CS_SHIFT));
> >>+
> >>+ if (todev)
> >>+ val |= HINFC504_DMA_CTRL_WE;
> >>+
> >>+ hinfc_write(host, val, HINFC504_DMA_CTRL);
> >>+
> >>+ init_completion(&host->cmd_complete);
> >
> >You need to run init_completion() *before* you kick off your I/O.
> >Otherwise, your interrupt handler is racing with this function.
> >
>
> Do you mean that it needs put init_completion() before hinfc_write()?
> If not so, interrupt handler maybe execute before init_completion()
> which will cause something wrong.
Yes.
init_completion(&host->cmd_complete);
should come sometime before
hinfc_write(host, val, HINFC504_DMA_CTRL);
> >>+ ret = wait_for_completion_timeout(&host->cmd_complete,
> >>+ HINFC504_NFC_DMA_TIMEOUT);
[...]
> >>+static void set_addr(struct mtd_info *mtd, int column, int page_addr)
> >>+{
> >>+ struct nand_chip *chip = mtd->priv;
> >>+ struct hinfc_host *host = chip->priv;
> >>+
> >>+ host->addr_cycle = 0;
> >>+ host->addr_value[0] = 0;
> >>+ host->addr_value[1] = 0;
> >>+
> >>+ /* Serially input address */
> >>+ if (column != -1) {
> >>+ /* Adjust columns for 16 bit buswidth */
> >>+ if (chip->options & NAND_BUSWIDTH_16)
> >>+ column >>= 1;
> >
> >It doesn't look like you're supporting ONFI parameter pages yet, but you
> >might consider checking for !nand_opcode_8bits(opcode) before adjusting the
> >address. We had to fix some other drivers for this recently.
> >
>
> sorry, could you give me more clue about this? Do you mean that we
> should first make sure it is not 8 bits bus width?
Look for use of nand_opcode_8bits() in nand_base.c.
I'm suggesting that you don't necessarily want to "adjust the column"
for all commands; there are some opcodes that take their address only on
the lower x8 bits, even if the flash has an x16 buswidth.
> >>+
> >>+ host->addr_value[0] = column & 0xffff;
> >>+ host->addr_cycle = 2;
> >>+ }
[...]
> >>+ switch (mtd->writesize) {
> >>+ case 2048:
> >>+ flag |= (0x001 << HINFC504_CON_PAGEISZE_SHIFT);
> >>+ /* add more pagesize support
> >>+ * default pagesize has been set in hisi_nfc_host_init
> >>+ */
> >
> >Does this mean you can't handle any other page size? You might want to
> >put the words 'TODO' or 'FIXME' in the comment, and you might want to
> >print an error and exit if you see some other value for mtd->writesize.
> >
>
> Yes, this NAND controller can handle not only 2048 page size. But
> the NAND controller on hip04-d01 board which I used to test this
> driver connects with a NAND flash chip which is just 2048 page size.
> So here I
> just listed 'case 2048', Maybe I need indicate this by 'TODO:...'?
Not just a TODO; make sure to also error out, so that users don't get
unexplained failures if they find themselves with a non-2KB page size
NAND.
Brian
next prev parent reply other threads:[~2014-12-01 18:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 12:46 [PATCH v4 0/2] mtd: hisilicon: add a new driver for NAND controller of hisilicon hip04 Soc Zhou Wang
2014-11-04 12:47 ` [PATCH v4 1/2] mtd: hisilicon: add a new NAND controller driver for " Zhou Wang
2014-11-30 9:35 ` Brian Norris
2014-12-01 13:08 ` Zhou Wang
2014-12-01 18:14 ` Brian Norris [this message]
2014-12-01 9:25 ` Brian Norris
2014-12-01 13:08 ` Zhou Wang
2014-11-04 12:47 ` [PATCH v4 2/2] mtd: hisilicon: add device tree binding documentation Zhou Wang
2014-11-30 8:56 ` Brian Norris
2014-12-01 13:08 ` Zhou Wang
2014-11-30 9:01 ` Brian Norris
2014-12-01 13:07 ` Zhou Wang
2014-11-06 3:05 ` [PATCH v4 0/2] mtd: hisilicon: add a new driver for NAND controller of hisilicon hip04 Soc Haojian Zhuang
2014-11-26 6:35 ` Haojian Zhuang
2014-11-30 9:08 ` Brian Norris
2014-12-01 13:06 ` Zhou Wang
2014-12-11 12:02 ` Zhou Wang
2014-12-17 1:03 ` Brian Norris
2014-12-17 5:06 ` Zhou Wang
2014-12-17 6:23 ` Brian Norris
2014-12-17 11:05 ` Zhou Wang
2015-01-13 4:17 ` Brian Norris
2015-01-22 3:27 ` Zhou Wang
2015-01-22 8:45 ` Brian Norris
2015-01-25 8:19 ` Zhou Wang
2015-02-06 1:33 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141201181449.GG21347@ld-irv-0074 \
--to=computersforpeace@gmail.com \
--cc=caizhiyong@huawei.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=galak@codeaurora.org \
--cc=haojian.zhuang@gmail.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=wangzhou.bry@gmail.com \
--cc=wangzhou1@hisilicon.com \
--cc=xuwei5@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).