From: Miquel RAYNAL <miquel.raynal@free-electrons.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Marek Vasut <marek.vasut@gmail.com>,
Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: nand: fix interpretation of NAND_CMD_NONE in core ->cmdfunc()
Date: Wed, 8 Nov 2017 16:55:23 +0100 [thread overview]
Message-ID: <20171108165523.48b02be4@xps13> (raw)
In-Reply-To: <20171108111536.7266af29@bbrezillon>
Hi Boris,
> How about rewording it like that:
>
> "
> Some drivers (like nand_hynix.c) call ->cmdfunc() with NAND_CMD_NONE
> and a column address and expect the controller to only send address
> cycles. Right now, the default ->cmdfunc() implementations provided by
> the core do not filter out the command cycle in this case and forwards
> the request to the controller driver through the ->cmd_ctrl() method.
> The thing is, NAND controller drivers can get is wrong and send a
> command cycle with a NAND_CMD_NONE opcode and since NAND_CMD_NONE is
> -1, and the command field is usually casted to an u8, we end up
> sending the 0xFF command which is actually a RESET operation.
>
>
> Add conditions in nand_command[_lp]() functions to sending the initial
> command cycle when command == NAND_CMD_NONE.
> "
This is better explained. I put yours, with
s/drivers can get is wrong/drivers can get this wrong/
>
> >
> > Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
> > ---
> > drivers/mtd/nand/nand_base.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/nand_base.c
> > b/drivers/mtd/nand/nand_base.c index c63e4a88a653..851f25383622
> > 100644 --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -710,7 +710,8 @@ static void nand_command(struct mtd_info *mtd,
> > unsigned int command, chip->cmd_ctrl(mtd, readcmd, ctrl);
> > ctrl &= ~NAND_CTRL_CHANGE;
> > }
> > - chip->cmd_ctrl(mtd, command, ctrl);
> > + if (command != NAND_CMD_NONE)
> > + chip->cmd_ctrl(mtd, command, ctrl);
> >
> > /* Address cycle, when necessary */
> > ctrl = NAND_CTRL_ALE | NAND_CTRL_CHANGE;
>
> You should probably also add a new case in the switch-case block to
> bail-out when command == NAND_CMD_NONE.
Oh that is right, there is nothing to wait for in that case.
Thank you,
Miquèl
prev parent reply other threads:[~2017-11-08 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 22:07 [PATCH] mtd: nand: fix interpretation of NAND_CMD_NONE in core ->cmdfunc() Miquel Raynal
2017-11-08 10:15 ` Boris Brezillon
2017-11-08 15:55 ` Miquel RAYNAL [this message]
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=20171108165523.48b02be4@xps13 \
--to=miquel.raynal@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.