From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Pratyush Yadav <pratyush@kernel.org>,
Michael Walle <michael@walle.cc>,
linux-mtd@lists.infradead.org, Julien Su <juliensu@mxic.com.tw>,
Jaime Liao <jaimeliao@mxic.com.tw>,
Jaime Liao <jaimeliao.tw@gmail.com>,
Alvin Zhou <alvinzhou@mxic.com.tw>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Michal Simek <monstr@monstr.eu>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 0/8] mtd: spi-nor: read while write support
Date: Fri, 24 Mar 2023 14:51:40 +0100 [thread overview]
Message-ID: <20230324145140.58509d50@xps-13> (raw)
In-Reply-To: <f904e8dc-6585-c90e-7226-3854613216ce@linaro.org>
Hi Tudor,
tudor.ambarus@linaro.org wrote on Fri, 17 Mar 2023 04:13:27 +0000:
> On 2/1/23 11:35, Miquel Raynal wrote:
> > Hello folks,
> >
> > Here is the follow-up of the RFC trying to bring a little bit of
> > parallelism to support SPI-NOR Read While Write feature on parts
> > supporting it and featuring several banks.
> >
> > I have received some hardware to make it work, so since the RFC, the
> > series has been updated to fix my mistakes, but the overall idea is the
> > same.
> >
> > There is nothing Macronix specific in the implementation, the operations
> > and opcodes are exactly the same as before. The only difference being:
> > we may consider the chip usable when it is in the busy state during a
> > write or an erase. Any chip with an internal split allowing to perform
> > parallel operations might possibly leverage the benefits of this
> > implementation.
> >
> > The first patches are just refactoring and preparation work, there is
> > almost no functional change, it's just a way to prepare the introduction
> > of the new locking mechanism and hopefully provide the cleanest and
> > simplest diff possible for this new feature. The actual change is all
> > contained in "mtd: spi-nor: Enhance locking to support reads while
> > writes". The logic is described in the commit log and copy/pasted here
> > for clarity:
> >
> > "
> > On devices featuring several banks, the Read While Write (RWW) feature
> > is here to improve the overall performance when performing parallel
> > reads and writes at different locations (different banks). The
> > following constraints have to be taken into account:
> > 1#: A single operation can be performed in a given bank.
> > 2#: Only a single program or erase operation can happen on the entire
> > chip (common hardware limitation to limit costs)
> > 3#: Reads must remain serialized even though reads on different banks
> > might occur at the same time.
> > 4#: The I/O bus is unique and thus is the most constrained resource,
> > all spi-nor operations requiring access to the spi bus (through
> > the spi controller) must be serialized until the bus exchanges
> > are over. So we must ensure a single operation can be "sent" at
> > a time.
> > 5#: Any other operation that would not be either a read or a write or an
> > erase is considered requiring access to the full chip and cannot be
> > parallelized, we then need to ensure the full chip is in the idle
> > state when this occurs.
> >
> > All these constraints can easily be managed with a proper locking model:
> > 1#: Is enforced by a bitfield of the in-use banks, so that only a single
> > operation can happen in a specific bank at any time.
> > 2#: Is handled by the ongoing_pe boolean which is set before any write
> > or erase, and is released only at the very end of the
> > operation. This way, no other destructive operation on the chip can
> > start during this time frame.
> > 3#: An ongoing_rd boolean allows to track the ongoing reads, so that
> > only one can be performed at a time.
> > 4#: An ongoing_io boolean is introduced in order to capture and
> > serialize bus accessed. This is the one being released "sooner"
> > than before, because we only need to protect the chip against
> > other SPI accesses during the I/O phase, which for the
> > destructive operations is the beginning of the operation (when
> > we send the command cycles and possibly the data), while the
> > second part of the operation (the erase delay or the
> > programmation delay) is when we can do something else in another
> > bank.
> > 5#: Is handled by the three booleans presented above, if any of them is
> > set, the chip is not yet ready for the operation and must wait.
> >
> > All these internal variables are protected by the existing lock, so that
> > changes in this structure are atomic. The serialization is handled with
> > a wait queue."
> >
> > Here is now a benchmark with a Macronix MX25UW51245G with 4 banks and RWW
> > support:
> >
> > // Testing the two accesses in the same bank
> > $ flash_speed -b0 -k0 -c10 -d /dev/mtd0
> > [...]
> > testing read while write latency
> > read while write took 51ms, read ended after 51ms
> >
> > // Testing the two accesses within different banks
> > $ flash_speed -b0 -k4096 -c10 -d /dev/mtd0
> > [...]
> > testing read while write latency
> > read while write took 51ms, read ended after 20ms
> >
> > Parallel accesses have been validated with io_paral. A slight increase
> > of the time spent on this test has however been noticed. With my
>
> how do the other tests look? Is there any change in performance for
> flashes that do not support RWW?
The current implementation takes care of not changing anything with the
existing flashes, when I resend I'll provide all the logs you asked
for, plus another quick test without the RWW feature bit set.
>
> > configuration, over a limited number of blocks, the overall operation
> > took 22 min without any RWW changes up to 27 min with these changes,
> > maybe due to the number of additional scheduling situations involved).
> >
> > Here is a branch with the mtd-utils patch bringing support for this
> > additional "-k" parameter in flash_speed (for the second block to use
> > during RWW testing), used to get the above results:
> > https://github.com/miquelraynal/mtd-utils/compare/master...rww
> >
> > Cheers,
> > Miquèl
> >
> > Changes in v4:
> > * Dropped patch 1/9 which got applied.
> > * s/SPI-NOR/SPI NOR/
> > * Turned n_banks into an u8 and moved it below in the struct to avoid
> > padding.
> > * Updated the S3AN_INFO macro to set n_banks to 1 by default.
> > * Renamed the lock and prep helper to follow the order of each
> > operation.
> > * Reworded a commit log to fit the recent changes upstream.
> >
> > Changes in v3:
> > * Fix the bank offsets calculations by providing the same values when
> > locking and when unlocking (might be changed by the functions themselves
> > without use noticing).
> > * I completely changed the way the locking works because there was a new
> > constraint: reads cannot be interrupted and status reads cannot happen
> > during a read. Hence, as the multi-locks design was starting to be too
> > messy, I changed the implementation to use a bunch of variables to
> > track the read while write state, protected by the main spi-nor
> > lock. If the internal state does not allow the operation, a sleep
> > starts in a queue, until the threads are woken up after a state
> > update. I know it is very verbose, I am open to suggestions.
> >
> >
> > Miquel Raynal (8):
> > mtd: spi-nor: Introduce the concept of bank
> > mtd: spi-nor: Add a macro to define more banks
> > mtd: spi-nor: Reorder the preparation vs locking steps
> > mtd: spi-nor: Separate preparation and locking
> > mtd: spi-nor: Prepare the introduction of a new locking mechanism
> > mtd: spi-nor: Add a RWW flag
> > mtd: spi-nor: Enhance locking to support reads while writes
> > mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
> >
> > drivers/mtd/spi-nor/core.c | 396 +++++++++++++++++++++++++++++++--
> > drivers/mtd/spi-nor/core.h | 26 ++-
> > drivers/mtd/spi-nor/macronix.c | 3 +
> > drivers/mtd/spi-nor/xilinx.c | 1 +
> > include/linux/mtd/spi-nor.h | 13 ++
> > 5 files changed, 409 insertions(+), 30 deletions(-)
> >
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Pratyush Yadav <pratyush@kernel.org>,
Michael Walle <michael@walle.cc>,
linux-mtd@lists.infradead.org, Julien Su <juliensu@mxic.com.tw>,
Jaime Liao <jaimeliao@mxic.com.tw>,
Jaime Liao <jaimeliao.tw@gmail.com>,
Alvin Zhou <alvinzhou@mxic.com.tw>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Michal Simek <monstr@monstr.eu>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 0/8] mtd: spi-nor: read while write support
Date: Fri, 24 Mar 2023 14:51:40 +0100 [thread overview]
Message-ID: <20230324145140.58509d50@xps-13> (raw)
In-Reply-To: <f904e8dc-6585-c90e-7226-3854613216ce@linaro.org>
Hi Tudor,
tudor.ambarus@linaro.org wrote on Fri, 17 Mar 2023 04:13:27 +0000:
> On 2/1/23 11:35, Miquel Raynal wrote:
> > Hello folks,
> >
> > Here is the follow-up of the RFC trying to bring a little bit of
> > parallelism to support SPI-NOR Read While Write feature on parts
> > supporting it and featuring several banks.
> >
> > I have received some hardware to make it work, so since the RFC, the
> > series has been updated to fix my mistakes, but the overall idea is the
> > same.
> >
> > There is nothing Macronix specific in the implementation, the operations
> > and opcodes are exactly the same as before. The only difference being:
> > we may consider the chip usable when it is in the busy state during a
> > write or an erase. Any chip with an internal split allowing to perform
> > parallel operations might possibly leverage the benefits of this
> > implementation.
> >
> > The first patches are just refactoring and preparation work, there is
> > almost no functional change, it's just a way to prepare the introduction
> > of the new locking mechanism and hopefully provide the cleanest and
> > simplest diff possible for this new feature. The actual change is all
> > contained in "mtd: spi-nor: Enhance locking to support reads while
> > writes". The logic is described in the commit log and copy/pasted here
> > for clarity:
> >
> > "
> > On devices featuring several banks, the Read While Write (RWW) feature
> > is here to improve the overall performance when performing parallel
> > reads and writes at different locations (different banks). The
> > following constraints have to be taken into account:
> > 1#: A single operation can be performed in a given bank.
> > 2#: Only a single program or erase operation can happen on the entire
> > chip (common hardware limitation to limit costs)
> > 3#: Reads must remain serialized even though reads on different banks
> > might occur at the same time.
> > 4#: The I/O bus is unique and thus is the most constrained resource,
> > all spi-nor operations requiring access to the spi bus (through
> > the spi controller) must be serialized until the bus exchanges
> > are over. So we must ensure a single operation can be "sent" at
> > a time.
> > 5#: Any other operation that would not be either a read or a write or an
> > erase is considered requiring access to the full chip and cannot be
> > parallelized, we then need to ensure the full chip is in the idle
> > state when this occurs.
> >
> > All these constraints can easily be managed with a proper locking model:
> > 1#: Is enforced by a bitfield of the in-use banks, so that only a single
> > operation can happen in a specific bank at any time.
> > 2#: Is handled by the ongoing_pe boolean which is set before any write
> > or erase, and is released only at the very end of the
> > operation. This way, no other destructive operation on the chip can
> > start during this time frame.
> > 3#: An ongoing_rd boolean allows to track the ongoing reads, so that
> > only one can be performed at a time.
> > 4#: An ongoing_io boolean is introduced in order to capture and
> > serialize bus accessed. This is the one being released "sooner"
> > than before, because we only need to protect the chip against
> > other SPI accesses during the I/O phase, which for the
> > destructive operations is the beginning of the operation (when
> > we send the command cycles and possibly the data), while the
> > second part of the operation (the erase delay or the
> > programmation delay) is when we can do something else in another
> > bank.
> > 5#: Is handled by the three booleans presented above, if any of them is
> > set, the chip is not yet ready for the operation and must wait.
> >
> > All these internal variables are protected by the existing lock, so that
> > changes in this structure are atomic. The serialization is handled with
> > a wait queue."
> >
> > Here is now a benchmark with a Macronix MX25UW51245G with 4 banks and RWW
> > support:
> >
> > // Testing the two accesses in the same bank
> > $ flash_speed -b0 -k0 -c10 -d /dev/mtd0
> > [...]
> > testing read while write latency
> > read while write took 51ms, read ended after 51ms
> >
> > // Testing the two accesses within different banks
> > $ flash_speed -b0 -k4096 -c10 -d /dev/mtd0
> > [...]
> > testing read while write latency
> > read while write took 51ms, read ended after 20ms
> >
> > Parallel accesses have been validated with io_paral. A slight increase
> > of the time spent on this test has however been noticed. With my
>
> how do the other tests look? Is there any change in performance for
> flashes that do not support RWW?
The current implementation takes care of not changing anything with the
existing flashes, when I resend I'll provide all the logs you asked
for, plus another quick test without the RWW feature bit set.
>
> > configuration, over a limited number of blocks, the overall operation
> > took 22 min without any RWW changes up to 27 min with these changes,
> > maybe due to the number of additional scheduling situations involved).
> >
> > Here is a branch with the mtd-utils patch bringing support for this
> > additional "-k" parameter in flash_speed (for the second block to use
> > during RWW testing), used to get the above results:
> > https://github.com/miquelraynal/mtd-utils/compare/master...rww
> >
> > Cheers,
> > Miquèl
> >
> > Changes in v4:
> > * Dropped patch 1/9 which got applied.
> > * s/SPI-NOR/SPI NOR/
> > * Turned n_banks into an u8 and moved it below in the struct to avoid
> > padding.
> > * Updated the S3AN_INFO macro to set n_banks to 1 by default.
> > * Renamed the lock and prep helper to follow the order of each
> > operation.
> > * Reworded a commit log to fit the recent changes upstream.
> >
> > Changes in v3:
> > * Fix the bank offsets calculations by providing the same values when
> > locking and when unlocking (might be changed by the functions themselves
> > without use noticing).
> > * I completely changed the way the locking works because there was a new
> > constraint: reads cannot be interrupted and status reads cannot happen
> > during a read. Hence, as the multi-locks design was starting to be too
> > messy, I changed the implementation to use a bunch of variables to
> > track the read while write state, protected by the main spi-nor
> > lock. If the internal state does not allow the operation, a sleep
> > starts in a queue, until the threads are woken up after a state
> > update. I know it is very verbose, I am open to suggestions.
> >
> >
> > Miquel Raynal (8):
> > mtd: spi-nor: Introduce the concept of bank
> > mtd: spi-nor: Add a macro to define more banks
> > mtd: spi-nor: Reorder the preparation vs locking steps
> > mtd: spi-nor: Separate preparation and locking
> > mtd: spi-nor: Prepare the introduction of a new locking mechanism
> > mtd: spi-nor: Add a RWW flag
> > mtd: spi-nor: Enhance locking to support reads while writes
> > mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
> >
> > drivers/mtd/spi-nor/core.c | 396 +++++++++++++++++++++++++++++++--
> > drivers/mtd/spi-nor/core.h | 26 ++-
> > drivers/mtd/spi-nor/macronix.c | 3 +
> > drivers/mtd/spi-nor/xilinx.c | 1 +
> > include/linux/mtd/spi-nor.h | 13 ++
> > 5 files changed, 409 insertions(+), 30 deletions(-)
> >
Thanks,
Miquèl
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-03-24 13:52 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 11:35 [PATCH v4 0/8] mtd: spi-nor: read while write support Miquel Raynal
2023-02-01 11:35 ` Miquel Raynal
2023-02-01 11:35 ` [PATCH v4 1/8] mtd: spi-nor: Introduce the concept of bank Miquel Raynal
2023-02-01 11:35 ` Miquel Raynal
2023-03-17 3:36 ` Tudor Ambarus
2023-03-17 3:36 ` Tudor Ambarus
2023-02-01 11:35 ` [PATCH v4 2/8] mtd: spi-nor: Add a macro to define more banks Miquel Raynal
2023-02-01 11:35 ` Miquel Raynal
2023-02-01 11:35 ` [PATCH v4 3/8] mtd: spi-nor: Reorder the preparation vs locking steps Miquel Raynal
2023-02-01 11:35 ` Miquel Raynal
2023-03-17 3:39 ` Tudor Ambarus
2023-03-17 3:39 ` Tudor Ambarus
2023-03-17 3:51 ` Tudor Ambarus
2023-03-17 3:51 ` Tudor Ambarus
2023-03-24 15:28 ` Miquel Raynal
2023-03-24 15:28 ` Miquel Raynal
2023-02-01 11:35 ` [PATCH v4 4/8] mtd: spi-nor: Separate preparation and locking Miquel Raynal
2023-02-01 11:35 ` Miquel Raynal
2023-02-01 11:36 ` [PATCH v4 5/8] mtd: spi-nor: Prepare the introduction of a new locking mechanism Miquel Raynal
2023-02-01 11:36 ` Miquel Raynal
2023-02-01 11:36 ` [PATCH v4 6/8] mtd: spi-nor: Add a RWW flag Miquel Raynal
2023-02-01 11:36 ` Miquel Raynal
2023-03-17 3:20 ` Tudor Ambarus
2023-03-17 3:20 ` Tudor Ambarus
2023-02-01 11:36 ` [PATCH v4 7/8] mtd: spi-nor: Enhance locking to support reads while writes Miquel Raynal
2023-02-01 11:36 ` Miquel Raynal
2023-03-17 5:59 ` Tudor Ambarus
2023-03-17 5:59 ` Tudor Ambarus
2023-03-24 17:41 ` Miquel Raynal
2023-03-24 17:41 ` Miquel Raynal
2023-03-27 9:29 ` Tudor Ambarus
2023-03-27 9:29 ` Tudor Ambarus
2023-03-28 8:22 ` Miquel Raynal
2023-03-28 8:22 ` Miquel Raynal
2023-02-01 11:36 ` [PATCH v4 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW Miquel Raynal
2023-02-01 11:36 ` Miquel Raynal
2023-03-17 6:09 ` Tudor Ambarus
2023-03-17 6:09 ` Tudor Ambarus
2023-03-17 7:43 ` liao jaime
2023-03-17 7:43 ` liao jaime
2023-03-17 8:22 ` Tudor Ambarus
2023-03-17 8:22 ` Tudor Ambarus
2023-03-17 4:13 ` [PATCH v4 0/8] mtd: spi-nor: read while write support Tudor Ambarus
2023-03-17 4:13 ` Tudor Ambarus
2023-03-24 13:51 ` Miquel Raynal [this message]
2023-03-24 13:51 ` Miquel Raynal
2023-03-27 9:34 ` Tudor Ambarus
2023-03-27 9:34 ` Tudor Ambarus
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=20230324145140.58509d50@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=alvinzhou@mxic.com.tw \
--cc=jaimeliao.tw@gmail.com \
--cc=jaimeliao@mxic.com.tw \
--cc=juliensu@mxic.com.tw \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michael@walle.cc \
--cc=monstr@monstr.eu \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=thomas.petazzoni@bootlin.com \
--cc=tudor.ambarus@linaro.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.