From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Stefan Wahren <stefan.wahren@i2se.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Scott Branden <sbranden@broadcom.com>,
Kamal Dasu <kdasu.kdev@gmail.com>, Ray Jui <rjui@broadcom.com>,
Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>,
bcm-kernel-feedback-list@broadcom.com,
linux-rpi-kernel@lists.infradead.org,
Tudor Ambarus <tudor.ambarus@microchip.com>,
Richard Weinberger <richard@nod.at>,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/3] mtd: rawnand: bcrmnand: Add exec_op() support
Date: Mon, 11 May 2020 18:57:39 +0200 [thread overview]
Message-ID: <20200511185739.51c94fd5@xps13> (raw)
In-Reply-To: <20200502163432.1543243-3-boris.brezillon@collabora.com>
Hi Boris,
Boris Brezillon <boris.brezillon@collabora.com> wrote on Sat, 2 May
2020 18:34:31 +0200:
> This implementation of exec_op() relies on low-level operations only. We
> could add support for high-level operations too through an op parser,
> but the gain is likely to be negligible since read/write page operations
> already have a fast path ({readwrite}_page[raw]() implementations).
Agreed.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> drivers/mtd/nand/raw/brcmnand/brcmnand.c | 72 ++++++++++++++++++++++++
> 1 file changed, 72 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index e4e3ceeac38f..e70117146755 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -1599,6 +1599,77 @@ static int brcmnand_low_level_op(struct brcmnand_host *host,
> return brcmnand_waitfunc(chip);
> }
>
> +static void brcmnand_exec_instr(struct brcmnand_host *host,
> + const struct nand_op_instr *instr,
> + bool last_op)
> +{
> + unsigned int i;
> + const u8 *out;
> + u8 *in;
> +
> + switch (instr->type) {
> + case NAND_OP_CMD_INSTR:
> + brcmnand_low_level_op(host, LL_OP_CMD,
> + instr->ctx.cmd.opcode, last_op);
> + break;
> +
> + case NAND_OP_ADDR_INSTR:
> + for (i = 0; i < instr->ctx.addr.naddrs; i++)
> + brcmnand_low_level_op(host, LL_OP_ADDR,
> + instr->ctx.addr.addrs[i],
> + last_op);
> + break;
> +
> + case NAND_OP_DATA_IN_INSTR:
> + in = instr->ctx.data.buf.in;
> + for (i = 0; i < instr->ctx.data.len; i++) {
> + brcmnand_low_level_op(host, LL_OP_RD, 0, last_op);
> + in[i] = brcmnand_read_reg(host->ctrl,
> + BRCMNAND_LL_RDATA);
> + }
> + break;
> +
> + case NAND_OP_DATA_OUT_INSTR:
> + out = instr->ctx.data.buf.out;
> + for (i = 0; i < instr->ctx.data.len; i++)
> + brcmnand_low_level_op(host, LL_OP_WR, out[i], last_op);
> + break;
> +
> + case NAND_OP_WAITRDY_INSTR:
> + /*
> + * Nothing to do here, brcmnand_low_level_op() already waits on
> + * FLASH_READY every time it's called.
> + */
> + break;
> +
> + default:
> + break;
> + }
> +}
> +
> +static int brcmnand_exec_op(struct nand_chip *chip,
> + const struct nand_operation *op,
> + bool check_only)
> +{
> + struct brcmnand_host *host = nand_get_controller_data(chip);
> + struct mtd_info *mtd = nand_to_mtd(chip);
> + unsigned int i;
> +
> + if (check_only)
> + return 0;
> +
> + if (op->deassert_wp)
> + brcmnand_wp(mtd, 0);
> +
> + for (i = 0; i < op->ninstrs; i++)
> + brcmnand_exec_instr(host, &op->instrs[i], i == op->ninstrs - 1);
Maybe ( )
to improve readability?
Or even maybe using an intermediate boolean?
> +
> + if (op->deassert_wp)
> + brcmnand_wp(mtd, 1);
> +
> + return 0;
> +}
> +
> static void brcmnand_cmdfunc(struct nand_chip *chip, unsigned command,
> int column, int page_addr)
> {
> @@ -2597,6 +2668,7 @@ static int brcmnand_attach_chip(struct nand_chip *chip)
>
> static const struct nand_controller_ops brcmnand_controller_ops = {
> .attach_chip = brcmnand_attach_chip,
> + .exec_op = brcmnand_exec_op,
> };
>
> static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
With this tiny change (don't resend if unneeded):
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-05-11 16:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-02 16:34 [PATCH 0/3] mtd: rawnand: brcmnand: Convert to exec_op() Boris Brezillon
2020-05-02 16:34 ` [PATCH 1/3] mtd: rawnand: Add the concept of destructive operation Boris Brezillon
2020-05-03 8:00 ` Boris Brezillon
2020-05-11 16:49 ` Miquel Raynal
2020-05-02 16:34 ` [PATCH 2/3] mtd: rawnand: bcrmnand: Add exec_op() support Boris Brezillon
2020-05-11 16:57 ` Miquel Raynal [this message]
2020-05-02 16:34 ` [PATCH 3/3] mtd: rawnand: brcmnand: Get rid of the legacy interface implementation Boris Brezillon
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=20200511185739.51c94fd5@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=boris.brezillon@collabora.com \
--cc=eric@anholt.net \
--cc=f.fainelli@gmail.com \
--cc=kdasu.kdev@gmail.com \
--cc=lee@kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=richard@nod.at \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=stefan.wahren@i2se.com \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.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