From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Christophe Kerello <christophe.kerello@st.com>, <richard@nod.at>,
<dwmw2@infradead.org>, <computersforpeace@gmail.com>,
<marek.vasut@gmail.com>, <robh+dt@kernel.org>,
<mark.rutland@arm.com>, <linux-mtd@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH v2 2/3] mtd: rawnand: stm32_fmc2: add STM32 FMC2 NAND flash controller driver
Date: Wed, 7 Nov 2018 13:26:45 +0100 [thread overview]
Message-ID: <20181107132645.7271e705@xps13> (raw)
In-Reply-To: <20181107132342.33790247@bbrezillon>
Hi Christophe,
Boris Brezillon <boris.brezillon@bootlin.com> wrote on Wed, 7 Nov 2018
13:23:42 +0100:
> On Wed, 7 Nov 2018 12:08:58 +0100
> Christophe Kerello <christophe.kerello@st.com> wrote:
>
> > >> +
> > >> +write_8bit:
> > >> + for (i = 0; i < len; i++)
> > >> + writeb_relaxed(p[i], io_addr_w);
> > >
> > > Is 8bit access really enforced by the byte accessor? In this case, how
> > > can you be sure 32-bit accesses are doing the right thing? Isn't there
> > > a bit somewhere in the config reg to configure the bus width?
> > >
> >
> > I have checked the framework after Miquèl comment sent on v1 => "If you
> > selected BOUNCE_BUFFER in the options, buf is supposedly
> > aligned, or am I missing something?".
> >
> > After checking the framework, my understanding was:
> > - In case of 8-bit access is requested, the framework provides no
> > guarantee on buf. To avoid any issue, I write byte per byte.
> > - In case of 8-bit access is not requested, it means that the
> > framework will try to write data in the page or in the oob. When writing
> > to oob, chip->oob_poi will be used and this buffer is aligned. When
> > writing to the page, as the driver enables NAND_USE_BOUNCE_BUFFER
> > option, buf is guarantee aligned.
>
> It's probably what happens right now, but there's no guarantee that all
> non-8-bit accesses will be provided a 32-bit aligned buffer. The only
> guarantee we provide is on buffer passed to the
> chip->ecc.read/write_xxx() hooks, and ->exec_op() can be used outside
> of the "page access" path.
>
> >
> > But, I agree that it would be safe to reconfigure the bus width in 8-bit
> > before writing byte per byte in case of a 16-bit NAND is used.
>
> Yes, and I also think you should not base your is-aligned check on the
> force_8bit value. Use IS_ALIGNED() instead.
Maybe the "configure the bus in 8/16-bit" blocks could deserve a
helper. There is probably other locations within this driver with the
same logic?
Thanks,
Miquèl
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Christophe Kerello <christophe.kerello@st.com>,
richard@nod.at, dwmw2@infradead.org, computersforpeace@gmail.com,
marek.vasut@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v2 2/3] mtd: rawnand: stm32_fmc2: add STM32 FMC2 NAND flash controller driver
Date: Wed, 7 Nov 2018 13:26:45 +0100 [thread overview]
Message-ID: <20181107132645.7271e705@xps13> (raw)
In-Reply-To: <20181107132342.33790247@bbrezillon>
Hi Christophe,
Boris Brezillon <boris.brezillon@bootlin.com> wrote on Wed, 7 Nov 2018
13:23:42 +0100:
> On Wed, 7 Nov 2018 12:08:58 +0100
> Christophe Kerello <christophe.kerello@st.com> wrote:
>
> > >> +
> > >> +write_8bit:
> > >> + for (i = 0; i < len; i++)
> > >> + writeb_relaxed(p[i], io_addr_w);
> > >
> > > Is 8bit access really enforced by the byte accessor? In this case, how
> > > can you be sure 32-bit accesses are doing the right thing? Isn't there
> > > a bit somewhere in the config reg to configure the bus width?
> > >
> >
> > I have checked the framework after Miquèl comment sent on v1 => "If you
> > selected BOUNCE_BUFFER in the options, buf is supposedly
> > aligned, or am I missing something?".
> >
> > After checking the framework, my understanding was:
> > - In case of 8-bit access is requested, the framework provides no
> > guarantee on buf. To avoid any issue, I write byte per byte.
> > - In case of 8-bit access is not requested, it means that the
> > framework will try to write data in the page or in the oob. When writing
> > to oob, chip->oob_poi will be used and this buffer is aligned. When
> > writing to the page, as the driver enables NAND_USE_BOUNCE_BUFFER
> > option, buf is guarantee aligned.
>
> It's probably what happens right now, but there's no guarantee that all
> non-8-bit accesses will be provided a 32-bit aligned buffer. The only
> guarantee we provide is on buffer passed to the
> chip->ecc.read/write_xxx() hooks, and ->exec_op() can be used outside
> of the "page access" path.
>
> >
> > But, I agree that it would be safe to reconfigure the bus width in 8-bit
> > before writing byte per byte in case of a 16-bit NAND is used.
>
> Yes, and I also think you should not base your is-aligned check on the
> force_8bit value. Use IS_ALIGNED() instead.
Maybe the "configure the bus in 8/16-bit" blocks could deserve a
helper. There is probably other locations within this driver with the
same logic?
Thanks,
Miquèl
next prev parent reply other threads:[~2018-11-07 12:26 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-05 9:41 [PATCH v2 0/3] mtd: rawnand: add STM32 FMC2 NAND flash controller driver christophe.kerello
2018-10-05 9:41 ` christophe.kerello
2018-10-05 9:41 ` [PATCH v2 1/3] dt-bindings: mtd: stm32_fmc2: add STM32 FMC2 NAND controller documentation christophe.kerello
2018-10-05 9:41 ` christophe.kerello
2018-10-05 9:53 ` Boris Brezillon
2018-10-05 9:53 ` Boris Brezillon
2018-10-12 20:32 ` Rob Herring
2018-10-15 7:39 ` Christophe Kerello
2018-10-15 7:39 ` Christophe Kerello
2018-10-05 9:41 ` [PATCH v2 2/3] mtd: rawnand: stm32_fmc2: add STM32 FMC2 NAND flash controller driver christophe.kerello
2018-10-05 9:41 ` christophe.kerello
2018-10-05 9:58 ` Boris Brezillon
2018-10-05 9:58 ` Boris Brezillon
2018-10-15 8:09 ` Christophe Kerello
2018-10-15 8:09 ` Christophe Kerello
2018-11-05 16:39 ` Boris Brezillon
2018-11-05 16:39 ` Boris Brezillon
2018-11-07 11:08 ` Christophe Kerello
2018-11-07 11:08 ` Christophe Kerello
2018-11-07 12:23 ` Boris Brezillon
2018-11-07 12:23 ` Boris Brezillon
2018-11-07 12:26 ` Miquel Raynal [this message]
2018-11-07 12:26 ` Miquel Raynal
2018-10-05 9:42 ` [PATCH v2 3/3] mtd: rawnand: stm32_fmc2: add manual mode christophe.kerello
2018-10-05 9:42 ` christophe.kerello
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=20181107132645.7271e705@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=boris.brezillon@bootlin.com \
--cc=christophe.kerello@st.com \
--cc=computersforpeace@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=marek.vasut@gmail.com \
--cc=mark.rutland@arm.com \
--cc=richard@nod.at \
--cc=robh+dt@kernel.org \
/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.