From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Keguang Zhang <keguang.zhang@gmail.com>
Cc: Keguang Zhang via B4 Relay
<devnull+keguang.zhang.gmail.com@kernel.org>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-mips@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v7 3/3] mtd: rawnand: Add Loongson-1 NAND Controller driver
Date: Mon, 12 Aug 2024 09:46:21 +0200 [thread overview]
Message-ID: <20240812094621.1f4954d4@xps-13> (raw)
In-Reply-To: <CAJhJPsUfRpkK6sNuHR0tNfr24bnv8HhJc6FQ0W+_=WeRouhzJQ@mail.gmail.com>
Hi Keguang,
> > > +
> > > + nfc->data->parse_address(chip, addrs, naddrs, cmd);
> > > + /* set NAND address */
> > > + nand_writel(nfc, NAND_ADDR1, nfc->addr1_reg);
> > > + nand_writel(nfc, NAND_ADDR2, nfc->addr2_reg);
> > > + break;
> > > + case NAND_OP_DATA_IN_INSTR:
> > > + case NAND_OP_DATA_OUT_INSTR:
> > > + offset = nand_subop_get_data_start_off(subop, op_id);
> > > + nfc->len = nand_subop_get_data_len(subop, op_id);
> > > + if (instr->type == NAND_OP_DATA_IN_INSTR)
> > > + nfc->buf =
> > > + (void *)instr->ctx.data.buf.in + offset;
> > > + else if (instr->type == NAND_OP_DATA_OUT_INSTR)
> > > + nfc->buf =
> > > + (void *)instr->ctx.data.buf.out + offset;
> >
> > The buf pointer feels clunky. You don't know for how long the buffer
> > you point to will be valid, please don't do that.
> >
> The buf pointer is used for DMA transfer afterwards.
> I referred to other drivers, and they used the same approach.
> https://elixir.bootlin.com/linux/v6.8.9/source/drivers/mtd/nand/raw/arasan-nand-controller.c#L647
nfc_op is a local variable, it doesn't live past the function call.
> https://elixir.bootlin.com/linux/v6.8.9/source/drivers/mtd/nand/raw/rockchip-nand-controller.c#L366
Thanks,
Miquèl
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Keguang Zhang <keguang.zhang@gmail.com>
Cc: Keguang Zhang via B4 Relay
<devnull+keguang.zhang.gmail.com@kernel.org>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-mips@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v7 3/3] mtd: rawnand: Add Loongson-1 NAND Controller driver
Date: Mon, 12 Aug 2024 09:46:21 +0200 [thread overview]
Message-ID: <20240812094621.1f4954d4@xps-13> (raw)
In-Reply-To: <CAJhJPsUfRpkK6sNuHR0tNfr24bnv8HhJc6FQ0W+_=WeRouhzJQ@mail.gmail.com>
Hi Keguang,
> > > +
> > > + nfc->data->parse_address(chip, addrs, naddrs, cmd);
> > > + /* set NAND address */
> > > + nand_writel(nfc, NAND_ADDR1, nfc->addr1_reg);
> > > + nand_writel(nfc, NAND_ADDR2, nfc->addr2_reg);
> > > + break;
> > > + case NAND_OP_DATA_IN_INSTR:
> > > + case NAND_OP_DATA_OUT_INSTR:
> > > + offset = nand_subop_get_data_start_off(subop, op_id);
> > > + nfc->len = nand_subop_get_data_len(subop, op_id);
> > > + if (instr->type == NAND_OP_DATA_IN_INSTR)
> > > + nfc->buf =
> > > + (void *)instr->ctx.data.buf.in + offset;
> > > + else if (instr->type == NAND_OP_DATA_OUT_INSTR)
> > > + nfc->buf =
> > > + (void *)instr->ctx.data.buf.out + offset;
> >
> > The buf pointer feels clunky. You don't know for how long the buffer
> > you point to will be valid, please don't do that.
> >
> The buf pointer is used for DMA transfer afterwards.
> I referred to other drivers, and they used the same approach.
> https://elixir.bootlin.com/linux/v6.8.9/source/drivers/mtd/nand/raw/arasan-nand-controller.c#L647
nfc_op is a local variable, it doesn't live past the function call.
> https://elixir.bootlin.com/linux/v6.8.9/source/drivers/mtd/nand/raw/rockchip-nand-controller.c#L366
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2024-08-12 7:46 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 11:11 [PATCH v7 0/3] Add support for Loongson-1 NAND Keguang Zhang
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-04-30 11:11 ` [PATCH v7 1/3] dt-bindings: mtd: Add Loongson-1 NAND Controller Keguang Zhang
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-05-06 7:14 ` Miquel Raynal
2024-05-06 7:14 ` Miquel Raynal
2024-05-18 8:01 ` Keguang Zhang
2024-05-18 8:01 ` Keguang Zhang
2024-05-18 10:47 ` Miquel Raynal
2024-05-18 10:47 ` Miquel Raynal
2024-06-06 10:53 ` Keguang Zhang
2024-06-06 10:53 ` Keguang Zhang
2024-06-06 21:33 ` Miquel Raynal
2024-06-06 21:33 ` Miquel Raynal
2024-06-07 2:36 ` Keguang Zhang
2024-06-07 2:36 ` Keguang Zhang
2024-04-30 11:11 ` [PATCH v7 2/3] mtd: rawnand: Enable monolithic read when reading subpages Keguang Zhang
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-05-06 7:17 ` Miquel Raynal
2024-05-06 7:17 ` Miquel Raynal
2024-05-20 10:42 ` Keguang Zhang
2024-05-20 10:42 ` Keguang Zhang
2024-05-20 15:33 ` Miquel Raynal
2024-05-20 15:33 ` Miquel Raynal
2024-08-01 10:06 ` Keguang Zhang
2024-08-01 10:06 ` Keguang Zhang
2024-04-30 11:11 ` [PATCH v7 3/3] mtd: rawnand: Add Loongson-1 NAND Controller driver Keguang Zhang
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-04-30 11:11 ` Keguang Zhang via B4 Relay
2024-05-06 7:59 ` Miquel Raynal
2024-05-06 7:59 ` Miquel Raynal
2024-08-01 10:53 ` Keguang Zhang
2024-08-01 10:53 ` Keguang Zhang
2024-08-12 7:46 ` Miquel Raynal [this message]
2024-08-12 7:46 ` Miquel Raynal
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=20240812094621.1f4954d4@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+keguang.zhang.gmail.com@kernel.org \
--cc=keguang.zhang@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--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 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.