* [PATCH v5 0/8] mtd: spi-nor: read while write support
@ 2023-03-28 15:40 Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 1/8] mtd: spi-nor: Introduce the concept of bank Miquel Raynal
` (8 more replies)
0 siblings, 9 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:40 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
Hello folks,
Here is a new version of this series 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 crossing bank
boundaries are allowed.
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 -c1 -d /dev/mtd0
[...]
testing read while write latency
read while write took 7ms, read ended after 7ms
// Testing the two accesses within different banks
$ flash_speed -b0 -k4096 -c1 -d /dev/mtd0
[...]
testing read while write latency
testing read while write latency
read while write took 7ms, read ended after 5ms
Parallel accesses have been validated with io_paral. A slight increase
of the time spent on this test has however been noticed. With my
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.
ubiformat /dev/mtd1 -y && ubiattach -p /dev/mtd1 && io_paral /dev/ubi0
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
Finally, here are two speed tests with and without the RWW bit set.
* Speed test with RWW enabled:
# flash_speed -d -c 100 /dev/mtd1
not NAND flash, assume page size is 512 bytes.
scanning for bad eraseblocks
scanned 100 eraseblocks, 0 are bad
testing eraseblock write speed
eraseblock write speed is 251 KiB/s
testing eraseblock read speed
eraseblock read speed is 1869 KiB/s
testing page write speed
page write speed is 247 KiB/s
testing page read speed
page read speed is 902 KiB/s
testing 2 page write speed
2 page write speed is 250 KiB/s
testing 2 page read speed
2 page read speed is 1282 KiB/s
Testing erase speed
erase speed is 157 KiB/s
Testing 2x multi-block erase speed
2x multi-block erase speed is 160 KiB/s
Testing 4x multi-block erase speed
4x multi-block erase speed is 161 KiB/s
Testing 8x multi-block erase speed
8x multi-block erase speed is 161 KiB/s
Testing 16x multi-block erase speed
16x multi-block erase speed is 161 KiB/s
Testing 32x multi-block erase speed
32x multi-block erase speed is 161 KiB/s
Testing 64x multi-block erase speed
64x multi-block erase speed is 161 KiB/s
finished
* Speedtest without the RWW bit:
# flash_speed -d -c100 /dev/mtd1
not NAND flash, assume page size is 512 bytes.
scanning for bad eraseblocks
scanned 100 eraseblocks, 0 are bad
testing eraseblock write speed
eraseblock write speed is 249 KiB/s
testing eraseblock read speed
eraseblock read speed is 1869 KiB/s
testing page write speed
page write speed is 246 KiB/s
testing page read speed
page read speed is 907 KiB/s
testing 2 page write speed
2 page write speed is 248 KiB/s
testing 2 page read speed
2 page read speed is 1286 KiB/s
Testing erase speed
erase speed is 158 KiB/s
Testing 2x multi-block erase speed
2x multi-block erase speed is 160 KiB/s
Testing 4x multi-block erase speed
4x multi-block erase speed is 161 KiB/s
Testing 8x multi-block erase speed
8x multi-block erase speed is 161 KiB/s
Testing 16x multi-block erase speed
16x multi-block erase speed is 160 KiB/s
Testing 32x multi-block erase speed
32x multi-block erase speed is 161 KiB/s
Testing 64x multi-block erase speed
64x multi-block erase speed is 160 KiB/s
finished
The differences are well within the imprecision of the measure, so no
performance impact are to be expected on chips without RWW support.
Cheers,
Miquèl
Changes in v5:
* Made the bank calculations independent from the number of sectors and
their size.
* Reordered the preparation vs. locking step in a few drivers which I
missed in my first attempt to do the conversion.
* Converted the definition on the Macronix NOR chip to use SFDP tables.
* Move the RWW SPI-NOR flag to the regular flag list, as it is not
specific to the "no_sfdp" situation.
* Created a SPI_NOR_F_* flag and set it in the core when relevant.
* Really improved the logic when enabling the RWW SPI NOR core flag so
we don't have to make any further checks beside looking at a single
bit.
* Improved commit messages and adapted them to the latest changes.
* Changed numerous function parameters and added inermediate local
variables as requested by Tudor.
* Changed variable types.
* Added information about the spi-nor chip being introduced as well as
additional benchmarks.
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 | 413 +++++++++++++++++++++++++++++++--
drivers/mtd/spi-nor/core.h | 25 +-
drivers/mtd/spi-nor/debugfs.c | 1 +
drivers/mtd/spi-nor/macronix.c | 4 +
drivers/mtd/spi-nor/otp.c | 8 +-
drivers/mtd/spi-nor/sst.c | 2 +-
drivers/mtd/spi-nor/swp.c | 6 +-
drivers/mtd/spi-nor/xilinx.c | 1 +
include/linux/mtd/spi-nor.h | 13 ++
9 files changed, 437 insertions(+), 36 deletions(-)
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v5 1/8] mtd: spi-nor: Introduce the concept of bank
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
@ 2023-03-28 15:40 ` Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 2/8] mtd: spi-nor: Add a macro to define more banks Miquel Raynal
` (7 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:40 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
SPI NOR chips are made of pages, which gathered in small groups make
(erase) sectors. Sectors, gathered together, make banks inside the
chip. Until now, there was only one bank per device supported, but we
are about to introduce support for new chips featuring several banks (up
to 4 so far) where different operations may happen in parallel.
Let's allow describing these additional bank parameters, and let's do
this independently of any other value (like the number of sectors) with
an absolute value.
By default we consider that all chips have a single bank.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
---
drivers/mtd/spi-nor/core.c | 1 +
drivers/mtd/spi-nor/core.h | 16 +++++++++++-----
drivers/mtd/spi-nor/xilinx.c | 1 +
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0a78045ca1d9..7d9ca799f767 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2583,6 +2583,7 @@ static void spi_nor_init_default_params(struct spi_nor *nor)
/* Set SPI NOR sizes. */
params->writesize = 1;
params->size = (u64)info->sector_size * info->n_sectors;
+ params->bank_size = div64_u64(params->size, info->n_banks);
params->page_size = info->page_size;
if (!(info->flags & SPI_NOR_NO_FR)) {
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 25423225c29d..db0e458810c7 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -336,7 +336,8 @@ struct spi_nor_otp {
* by the spi_nor_fixups hooks, or dynamically when parsing the JESD216
* Serial Flash Discoverable Parameters (SFDP) tables.
*
- * @size: the flash memory density in bytes.
+ * @bank_size: the flash memory bank density in bytes.
+ * @size: the total flash memory density in bytes.
* @writesize Minimal writable flash unit size. Defaults to 1. Set to
* ECC unit size for ECC-ed flashes.
* @page_size: the page size of the SPI NOR flash memory.
@@ -374,6 +375,7 @@ struct spi_nor_otp {
* @locking_ops: SPI NOR locking methods.
*/
struct spi_nor_flash_parameter {
+ u64 bank_size;
u64 size;
u32 writesize;
u32 page_size;
@@ -435,6 +437,7 @@ struct spi_nor_fixups {
* @sector_size: the size listed here is what works with SPINOR_OP_SE, which
* isn't necessarily called a "sector" by the vendor.
* @n_sectors: the number of sectors.
+ * @n_banks: the number of banks.
* @page_size: the flash's page size.
* @addr_nbytes: number of address bytes to send.
*
@@ -495,6 +498,7 @@ struct flash_info {
unsigned sector_size;
u16 n_sectors;
u16 page_size;
+ u8 n_banks;
u8 addr_nbytes;
bool parse_sfdp;
@@ -540,24 +544,26 @@ struct flash_info {
.id = { SPI_NOR_ID_3ITEMS(_jedec_id), SPI_NOR_ID_3ITEMS(_ext_id) }, \
.id_len = 6
-#define SPI_NOR_GEOMETRY(_sector_size, _n_sectors) \
+#define SPI_NOR_GEOMETRY(_sector_size, _n_sectors, _n_banks) \
.sector_size = (_sector_size), \
.n_sectors = (_n_sectors), \
- .page_size = 256
+ .page_size = 256, \
+ .n_banks = (_n_banks)
/* Used when the "_ext_id" is two bytes at most */
#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors) \
SPI_NOR_ID((_jedec_id), (_ext_id)), \
- SPI_NOR_GEOMETRY((_sector_size), (_n_sectors)),
+ SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 1),
#define INFO6(_jedec_id, _ext_id, _sector_size, _n_sectors) \
SPI_NOR_ID6((_jedec_id), (_ext_id)), \
- SPI_NOR_GEOMETRY((_sector_size), (_n_sectors)),
+ SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 1),
#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_nbytes) \
.sector_size = (_sector_size), \
.n_sectors = (_n_sectors), \
.page_size = (_page_size), \
+ .n_banks = 1, \
.addr_nbytes = (_addr_nbytes), \
.flags = SPI_NOR_NO_ERASE | SPI_NOR_NO_FR, \
diff --git a/drivers/mtd/spi-nor/xilinx.c b/drivers/mtd/spi-nor/xilinx.c
index 5723157739fc..7175de8aa336 100644
--- a/drivers/mtd/spi-nor/xilinx.c
+++ b/drivers/mtd/spi-nor/xilinx.c
@@ -31,6 +31,7 @@
.sector_size = (8 * (_page_size)), \
.n_sectors = (_n_sectors), \
.page_size = (_page_size), \
+ .n_banks = 1, \
.addr_nbytes = 3, \
.flags = SPI_NOR_NO_FR
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 2/8] mtd: spi-nor: Add a macro to define more banks
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 1/8] mtd: spi-nor: Introduce the concept of bank Miquel Raynal
@ 2023-03-28 15:40 ` Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 3/8] mtd: spi-nor: Reorder the preparation vs. locking steps Miquel Raynal
` (6 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:40 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
Most of the chips on the market only feature a single bank. However, new
chips may support more than a single bank, with the possibility to
parallelize some operations. Let's introduce an INFOB() macro which also
takes a n_bank parameter.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
---
drivers/mtd/spi-nor/core.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index db0e458810c7..bf2e64671856 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -555,6 +555,10 @@ struct flash_info {
SPI_NOR_ID((_jedec_id), (_ext_id)), \
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 1),
+#define INFOB(_jedec_id, _ext_id, _sector_size, _n_sectors, _n_banks) \
+ SPI_NOR_ID((_jedec_id), (_ext_id)), \
+ SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), (_n_banks)),
+
#define INFO6(_jedec_id, _ext_id, _sector_size, _n_sectors) \
SPI_NOR_ID6((_jedec_id), (_ext_id)), \
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 1),
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 3/8] mtd: spi-nor: Reorder the preparation vs. locking steps
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 1/8] mtd: spi-nor: Introduce the concept of bank Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 2/8] mtd: spi-nor: Add a macro to define more banks Miquel Raynal
@ 2023-03-28 15:41 ` Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 4/8] mtd: spi-nor: Separate preparation and locking Miquel Raynal
` (5 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:41 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
The ->prepare()/->unprepare() hooks are now legacy, we no longer accept
new drivers supporting them. The only remaining controllers using them
acquires a per-chip mutex, which should not interfere with the rest of
the operation done in the core. As a result, we should be safe to
reorganize these helpers to first perform the preparation, before
acquiring the core locks. This is necessary in order to be able to
improve the locking mechanism in the core (coming next). No side effects
are expected.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/spi-nor/core.c | 23 ++++++++++-------------
drivers/mtd/spi-nor/core.h | 2 +-
drivers/mtd/spi-nor/otp.c | 8 ++++----
drivers/mtd/spi-nor/sst.c | 2 +-
drivers/mtd/spi-nor/swp.c | 6 +++---
5 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 7d9ca799f767..3a7a407919e7 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1070,27 +1070,24 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor)
}
}
-int spi_nor_lock_and_prep(struct spi_nor *nor)
+int spi_nor_prep_and_lock(struct spi_nor *nor)
{
int ret = 0;
- mutex_lock(&nor->lock);
-
- if (nor->controller_ops && nor->controller_ops->prepare) {
+ if (nor->controller_ops && nor->controller_ops->prepare)
ret = nor->controller_ops->prepare(nor);
- if (ret) {
- mutex_unlock(&nor->lock);
- return ret;
- }
- }
+
+ mutex_lock(&nor->lock);
+
return ret;
}
void spi_nor_unlock_and_unprep(struct spi_nor *nor)
{
+ mutex_unlock(&nor->lock);
+
if (nor->controller_ops && nor->controller_ops->unprepare)
nor->controller_ops->unprepare(nor);
- mutex_unlock(&nor->lock);
}
static u32 spi_nor_convert_addr(struct spi_nor *nor, loff_t addr)
@@ -1446,7 +1443,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
addr = instr->addr;
len = instr->len;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -1706,7 +1703,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len);
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -1752,7 +1749,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index bf2e64671856..c4c78729ccea 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -647,7 +647,7 @@ int spi_nor_write_disable(struct spi_nor *nor);
int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
int spi_nor_wait_till_ready(struct spi_nor *nor);
int spi_nor_global_block_unlock(struct spi_nor *nor);
-int spi_nor_lock_and_prep(struct spi_nor *nor);
+int spi_nor_prep_and_lock(struct spi_nor *nor);
void spi_nor_unlock_and_unprep(struct spi_nor *nor);
int spi_nor_sr1_bit6_quad_enable(struct spi_nor *nor);
int spi_nor_sr2_bit1_quad_enable(struct spi_nor *nor);
diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c
index 00ab0d2d6d2f..9a729aa3452d 100644
--- a/drivers/mtd/spi-nor/otp.c
+++ b/drivers/mtd/spi-nor/otp.c
@@ -255,7 +255,7 @@ static int spi_nor_mtd_otp_info(struct mtd_info *mtd, size_t len,
if (len < n_regions * sizeof(*buf))
return -ENOSPC;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -325,7 +325,7 @@ static int spi_nor_mtd_otp_read_write(struct mtd_info *mtd, loff_t ofs,
if (!total_len)
return 0;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -415,7 +415,7 @@ static int spi_nor_mtd_otp_erase(struct mtd_info *mtd, loff_t from, size_t len)
if (!IS_ALIGNED(len, rlen) || !IS_ALIGNED(from, rlen))
return -EINVAL;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -460,7 +460,7 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t len)
if (!IS_ALIGNED(len, rlen) || !IS_ALIGNED(from, rlen))
return -EINVAL;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c
index 63bcc97bf978..688eb20c763e 100644
--- a/drivers/mtd/spi-nor/sst.c
+++ b/drivers/mtd/spi-nor/sst.c
@@ -126,7 +126,7 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c
index 1f178313ba8f..0ba716e84377 100644
--- a/drivers/mtd/spi-nor/swp.c
+++ b/drivers/mtd/spi-nor/swp.c
@@ -348,7 +348,7 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -363,7 +363,7 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
@@ -378,7 +378,7 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;
- ret = spi_nor_lock_and_prep(nor);
+ ret = spi_nor_prep_and_lock(nor);
if (ret)
return ret;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 4/8] mtd: spi-nor: Separate preparation and locking
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
` (2 preceding siblings ...)
2023-03-28 15:41 ` [PATCH v5 3/8] mtd: spi-nor: Reorder the preparation vs. locking steps Miquel Raynal
@ 2023-03-28 15:41 ` Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 5/8] mtd: spi-nor: Prepare the introduction of a new locking mechanism Miquel Raynal
` (4 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:41 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
While this operation will remain a single function call in the end,
let's extract the logic of the [un]prepare calls within their own static
helper. We will soon add new flavors of the *_[un]prepare_and_[un]lock()
helpers, having the preparation logic outside will save us from duplicating
code over and over again.
There is no functional change.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/spi-nor/core.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 3a7a407919e7..e80677d36a8c 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1070,24 +1070,40 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor)
}
}
-int spi_nor_prep_and_lock(struct spi_nor *nor)
+static int spi_nor_prep(struct spi_nor *nor)
{
int ret = 0;
if (nor->controller_ops && nor->controller_ops->prepare)
ret = nor->controller_ops->prepare(nor);
+ return ret;
+}
+
+static void spi_nor_unprep(struct spi_nor *nor)
+{
+ if (nor->controller_ops && nor->controller_ops->unprepare)
+ nor->controller_ops->unprepare(nor);
+}
+
+int spi_nor_prep_and_lock(struct spi_nor *nor)
+{
+ int ret;
+
+ ret = spi_nor_prep(nor);
+ if (ret)
+ return ret;
+
mutex_lock(&nor->lock);
- return ret;
+ return 0;
}
void spi_nor_unlock_and_unprep(struct spi_nor *nor)
{
mutex_unlock(&nor->lock);
- if (nor->controller_ops && nor->controller_ops->unprepare)
- nor->controller_ops->unprepare(nor);
+ spi_nor_unprep(nor);
}
static u32 spi_nor_convert_addr(struct spi_nor *nor, loff_t addr)
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 5/8] mtd: spi-nor: Prepare the introduction of a new locking mechanism
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
` (3 preceding siblings ...)
2023-03-28 15:41 ` [PATCH v5 4/8] mtd: spi-nor: Separate preparation and locking Miquel Raynal
@ 2023-03-28 15:41 ` Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 6/8] mtd: spi-nor: Add a RWW flag Miquel Raynal
` (3 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:41 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
This commit alone just introduces two new "prepare and lock" pairs of
helpers which do the exact same thing as before. They will soon be
improved in a followup commit which actually brings the logic, but I
figured out it was more readable to do it this way.
One new pair is suffixed _pe which stands for "program and erase" and
hence is being called by spi_nor_write() and spi_nor_erase().
The other pair is suffixed _rd which stands for "read" and hence is
being called by spi_nor_read().
One note however, these extra helpers will need to know the operation
range, so they come with two new parameters to define it. Otherwise
there is no functional change.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/spi-nor/core.c | 59 ++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index e80677d36a8c..daed09950ee1 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1086,6 +1086,7 @@ static void spi_nor_unprep(struct spi_nor *nor)
nor->controller_ops->unprepare(nor);
}
+/* Generic helpers for internal locking and serialization */
int spi_nor_prep_and_lock(struct spi_nor *nor)
{
int ret;
@@ -1106,6 +1107,48 @@ void spi_nor_unlock_and_unprep(struct spi_nor *nor)
spi_nor_unprep(nor);
}
+/* Internal locking helpers for program and erase operations */
+static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, size_t len)
+{
+ int ret;
+
+ ret = spi_nor_prep(nor);
+ if (ret)
+ return ret;
+
+ mutex_lock(&nor->lock);
+
+ return 0;
+}
+
+static void spi_nor_unlock_and_unprep_pe(struct spi_nor *nor, loff_t start, size_t len)
+{
+ mutex_unlock(&nor->lock);
+
+ spi_nor_unprep(nor);
+}
+
+/* Internal locking helpers for read operations */
+static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, size_t len)
+{
+ int ret;
+
+ ret = spi_nor_prep(nor);
+ if (ret)
+ return ret;
+
+ mutex_lock(&nor->lock);
+
+ return 0;
+}
+
+static void spi_nor_unlock_and_unprep_rd(struct spi_nor *nor, loff_t start, size_t len)
+{
+ mutex_unlock(&nor->lock);
+
+ spi_nor_unprep(nor);
+}
+
static u32 spi_nor_convert_addr(struct spi_nor *nor, loff_t addr)
{
if (!nor->params->convert_addr)
@@ -1459,7 +1502,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
addr = instr->addr;
len = instr->len;
- ret = spi_nor_prep_and_lock(nor);
+ ret = spi_nor_prep_and_lock_pe(nor, instr->addr, instr->len);
if (ret)
return ret;
@@ -1522,7 +1565,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
ret = spi_nor_write_disable(nor);
erase_err:
- spi_nor_unlock_and_unprep(nor);
+ spi_nor_unlock_and_unprep_pe(nor, instr->addr, instr->len);
return ret;
}
@@ -1715,11 +1758,13 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
struct spi_nor *nor = mtd_to_spi_nor(mtd);
+ loff_t from_lock = from;
+ size_t len_lock = len;
ssize_t ret;
dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len);
- ret = spi_nor_prep_and_lock(nor);
+ ret = spi_nor_prep_and_lock_rd(nor, from_lock, len_lock);
if (ret)
return ret;
@@ -1746,7 +1791,8 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
ret = 0;
read_err:
- spi_nor_unlock_and_unprep(nor);
+ spi_nor_unlock_and_unprep_rd(nor, from_lock, len_lock);
+
return ret;
}
@@ -1765,7 +1811,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
- ret = spi_nor_prep_and_lock(nor);
+ ret = spi_nor_prep_and_lock_pe(nor, to, len);
if (ret)
return ret;
@@ -1807,7 +1853,8 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
}
write_err:
- spi_nor_unlock_and_unprep(nor);
+ spi_nor_unlock_and_unprep_pe(nor, to, len);
+
return ret;
}
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 6/8] mtd: spi-nor: Add a RWW flag
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
` (4 preceding siblings ...)
2023-03-28 15:41 ` [PATCH v5 5/8] mtd: spi-nor: Prepare the introduction of a new locking mechanism Miquel Raynal
@ 2023-03-28 15:41 ` Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 7/8] mtd: spi-nor: Enhance locking to support reads while writes Miquel Raynal
` (2 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:41 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
Introduce a new (no SFDP) flag for the feature that we are about to
support: Read While Write. This means, if the chip has several banks and
supports RWW, once a page of data to write has been transferred into the
chip's internal SRAM, another read operation happening on a different
bank can be performed during the tPROG delay.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/spi-nor/core.c | 3 +++
drivers/mtd/spi-nor/core.h | 3 +++
drivers/mtd/spi-nor/debugfs.c | 1 +
3 files changed, 7 insertions(+)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index daed09950ee1..75ec7a3d0b43 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2530,6 +2530,9 @@ static void spi_nor_init_flags(struct spi_nor *nor)
if (flags & NO_CHIP_ERASE)
nor->flags |= SNOR_F_NO_OP_CHIP_ERASE;
+
+ if (flags & SPI_NOR_RWW)
+ nor->flags |= SNOR_F_RWW;
}
/**
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index c4c78729ccea..de31e430f77e 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -130,6 +130,7 @@ enum spi_nor_option_flags {
SNOR_F_IO_MODE_EN_VOLATILE = BIT(11),
SNOR_F_SOFT_RESET = BIT(12),
SNOR_F_SWP_IS_VOLATILE = BIT(13),
+ SNOR_F_RWW = BIT(14),
};
struct spi_nor_read_command {
@@ -462,6 +463,7 @@ struct spi_nor_fixups {
* NO_CHIP_ERASE: chip does not support chip erase.
* SPI_NOR_NO_FR: can't do fastread.
* SPI_NOR_QUAD_PP: flash supports Quad Input Page Program.
+ * SPI_NOR_RWW: flash supports reads while write.
*
* @no_sfdp_flags: flags that indicate support that can be discovered via SFDP.
* Used when SFDP tables are not defined in the flash. These
@@ -513,6 +515,7 @@ struct flash_info {
#define NO_CHIP_ERASE BIT(7)
#define SPI_NOR_NO_FR BIT(8)
#define SPI_NOR_QUAD_PP BIT(9)
+#define SPI_NOR_RWW BIT(10)
u8 no_sfdp_flags;
#define SPI_NOR_SKIP_SFDP BIT(0)
diff --git a/drivers/mtd/spi-nor/debugfs.c b/drivers/mtd/spi-nor/debugfs.c
index 845b78c7ecc7..e200f5b9234c 100644
--- a/drivers/mtd/spi-nor/debugfs.c
+++ b/drivers/mtd/spi-nor/debugfs.c
@@ -25,6 +25,7 @@ static const char *const snor_f_names[] = {
SNOR_F_NAME(IO_MODE_EN_VOLATILE),
SNOR_F_NAME(SOFT_RESET),
SNOR_F_NAME(SWP_IS_VOLATILE),
+ SNOR_F_NAME(RWW),
};
#undef SNOR_F_NAME
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 7/8] mtd: spi-nor: Enhance locking to support reads while writes
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
` (5 preceding siblings ...)
2023-03-28 15:41 ` [PATCH v5 6/8] mtd: spi-nor: Add a RWW flag Miquel Raynal
@ 2023-03-28 15:41 ` Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW Miquel Raynal
2023-03-29 10:49 ` Re (subset): [PATCH v5 0/8] mtd: spi-nor: read while write support Tudor Ambarus
8 siblings, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:41 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
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 crossing bank
boundaries are allowed.
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.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/spi-nor/core.c | 337 ++++++++++++++++++++++++++++++++++--
include/linux/mtd/spi-nor.h | 13 ++
2 files changed, 334 insertions(+), 16 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 75ec7a3d0b43..9e6a0730cdb8 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -588,6 +588,65 @@ int spi_nor_sr_ready(struct spi_nor *nor)
return !(nor->bouncebuf[0] & SR_WIP);
}
+/**
+ * spi_nor_use_parallel_locking() - Checks if RWW locking scheme shall be used
+ * @nor: pointer to 'struct spi_nor'.
+ *
+ * Return: true if parallel locking is enabled, false otherwise.
+ */
+static bool spi_nor_use_parallel_locking(struct spi_nor *nor)
+{
+ return nor->flags & SNOR_F_RWW;
+}
+
+/* Locking helpers for status read operations */
+static int spi_nor_rww_start_rdst(struct spi_nor *nor)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ int ret = -EAGAIN;
+
+ mutex_lock(&nor->lock);
+
+ if (rww->ongoing_io || rww->ongoing_rd)
+ goto busy;
+
+ rww->ongoing_io = true;
+ rww->ongoing_rd = true;
+ ret = 0;
+
+busy:
+ mutex_unlock(&nor->lock);
+ return ret;
+}
+
+static void spi_nor_rww_end_rdst(struct spi_nor *nor)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+
+ mutex_lock(&nor->lock);
+
+ rww->ongoing_io = false;
+ rww->ongoing_rd = false;
+
+ mutex_unlock(&nor->lock);
+}
+
+static int spi_nor_lock_rdst(struct spi_nor *nor)
+{
+ if (spi_nor_use_parallel_locking(nor))
+ return spi_nor_rww_start_rdst(nor);
+
+ return 0;
+}
+
+static void spi_nor_unlock_rdst(struct spi_nor *nor)
+{
+ if (spi_nor_use_parallel_locking(nor)) {
+ spi_nor_rww_end_rdst(nor);
+ wake_up(&nor->rww.wait);
+ }
+}
+
/**
* spi_nor_ready() - Query the flash to see if it is ready for new commands.
* @nor: pointer to 'struct spi_nor'.
@@ -596,11 +655,21 @@ int spi_nor_sr_ready(struct spi_nor *nor)
*/
static int spi_nor_ready(struct spi_nor *nor)
{
+ int ret;
+
+ ret = spi_nor_lock_rdst(nor);
+ if (ret)
+ return 0;
+
/* Flashes might override the standard routine. */
if (nor->params->ready)
- return nor->params->ready(nor);
+ ret = nor->params->ready(nor);
+ else
+ ret = spi_nor_sr_ready(nor);
- return spi_nor_sr_ready(nor);
+ spi_nor_unlock_rdst(nor);
+
+ return ret;
}
/**
@@ -1086,7 +1155,88 @@ static void spi_nor_unprep(struct spi_nor *nor)
nor->controller_ops->unprepare(nor);
}
+static void spi_nor_offset_to_banks(u64 bank_size, loff_t start, size_t len,
+ u8 *first, u8 *last)
+{
+ /* This is currently safe, the number of banks being very small */
+ *first = DIV_ROUND_DOWN_ULL(start, bank_size);
+ *last = DIV_ROUND_DOWN_ULL(start + len - 1, bank_size);
+}
+
/* Generic helpers for internal locking and serialization */
+static bool spi_nor_rww_start_io(struct spi_nor *nor)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ bool start = false;
+
+ mutex_lock(&nor->lock);
+
+ if (rww->ongoing_io)
+ goto busy;
+
+ rww->ongoing_io = true;
+ start = true;
+
+busy:
+ mutex_unlock(&nor->lock);
+ return start;
+}
+
+static void spi_nor_rww_end_io(struct spi_nor *nor)
+{
+ mutex_lock(&nor->lock);
+ nor->rww.ongoing_io = false;
+ mutex_unlock(&nor->lock);
+}
+
+static int spi_nor_lock_device(struct spi_nor *nor)
+{
+ if (!spi_nor_use_parallel_locking(nor))
+ return 0;
+
+ return wait_event_killable(nor->rww.wait, spi_nor_rww_start_io(nor));
+}
+
+static void spi_nor_unlock_device(struct spi_nor *nor)
+{
+ if (spi_nor_use_parallel_locking(nor)) {
+ spi_nor_rww_end_io(nor);
+ wake_up(&nor->rww.wait);
+ }
+}
+
+/* Generic helpers for internal locking and serialization */
+static bool spi_nor_rww_start_exclusive(struct spi_nor *nor)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ bool start = false;
+
+ mutex_lock(&nor->lock);
+
+ if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe)
+ goto busy;
+
+ rww->ongoing_io = true;
+ rww->ongoing_rd = true;
+ rww->ongoing_pe = true;
+ start = true;
+
+busy:
+ mutex_unlock(&nor->lock);
+ return start;
+}
+
+static void spi_nor_rww_end_exclusive(struct spi_nor *nor)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+
+ mutex_lock(&nor->lock);
+ rww->ongoing_io = false;
+ rww->ongoing_rd = false;
+ rww->ongoing_pe = false;
+ mutex_unlock(&nor->lock);
+}
+
int spi_nor_prep_and_lock(struct spi_nor *nor)
{
int ret;
@@ -1095,19 +1245,75 @@ int spi_nor_prep_and_lock(struct spi_nor *nor)
if (ret)
return ret;
- mutex_lock(&nor->lock);
+ if (!spi_nor_use_parallel_locking(nor))
+ mutex_lock(&nor->lock);
+ else
+ ret = wait_event_killable(nor->rww.wait,
+ spi_nor_rww_start_exclusive(nor));
- return 0;
+ return ret;
}
void spi_nor_unlock_and_unprep(struct spi_nor *nor)
{
- mutex_unlock(&nor->lock);
+ if (!spi_nor_use_parallel_locking(nor)) {
+ mutex_unlock(&nor->lock);
+ } else {
+ spi_nor_rww_end_exclusive(nor);
+ wake_up(&nor->rww.wait);
+ }
spi_nor_unprep(nor);
}
/* Internal locking helpers for program and erase operations */
+static bool spi_nor_rww_start_pe(struct spi_nor *nor, loff_t start, size_t len)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ unsigned int used_banks = 0;
+ bool started = false;
+ u8 first, last;
+ int bank;
+
+ mutex_lock(&nor->lock);
+
+ if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe)
+ goto busy;
+
+ spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last);
+ for (bank = first; bank <= last; bank++) {
+ if (rww->used_banks & BIT(bank))
+ goto busy;
+
+ used_banks |= BIT(bank);
+ }
+
+ rww->used_banks |= used_banks;
+ rww->ongoing_pe = true;
+ started = true;
+
+busy:
+ mutex_unlock(&nor->lock);
+ return started;
+}
+
+static void spi_nor_rww_end_pe(struct spi_nor *nor, loff_t start, size_t len)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ u8 first, last;
+ int bank;
+
+ mutex_lock(&nor->lock);
+
+ spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last);
+ for (bank = first; bank <= last; bank++)
+ rww->used_banks &= ~BIT(bank);
+
+ rww->ongoing_pe = false;
+
+ mutex_unlock(&nor->lock);
+}
+
static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, size_t len)
{
int ret;
@@ -1116,19 +1322,77 @@ static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, size_t le
if (ret)
return ret;
- mutex_lock(&nor->lock);
+ if (!spi_nor_use_parallel_locking(nor))
+ mutex_lock(&nor->lock);
+ else
+ ret = wait_event_killable(nor->rww.wait,
+ spi_nor_rww_start_pe(nor, start, len));
- return 0;
+ return ret;
}
static void spi_nor_unlock_and_unprep_pe(struct spi_nor *nor, loff_t start, size_t len)
{
- mutex_unlock(&nor->lock);
+ if (!spi_nor_use_parallel_locking(nor)) {
+ mutex_unlock(&nor->lock);
+ } else {
+ spi_nor_rww_end_pe(nor, start, len);
+ wake_up(&nor->rww.wait);
+ }
spi_nor_unprep(nor);
}
/* Internal locking helpers for read operations */
+static bool spi_nor_rww_start_rd(struct spi_nor *nor, loff_t start, size_t len)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ unsigned int used_banks = 0;
+ bool started = false;
+ u8 first, last;
+ int bank;
+
+ mutex_lock(&nor->lock);
+
+ if (rww->ongoing_io || rww->ongoing_rd)
+ goto busy;
+
+ spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last);
+ for (bank = first; bank <= last; bank++) {
+ if (rww->used_banks & BIT(bank))
+ goto busy;
+
+ used_banks |= BIT(bank);
+ }
+
+ rww->used_banks |= used_banks;
+ rww->ongoing_io = true;
+ rww->ongoing_rd = true;
+ started = true;
+
+busy:
+ mutex_unlock(&nor->lock);
+ return started;
+}
+
+static void spi_nor_rww_end_rd(struct spi_nor *nor, loff_t start, size_t len)
+{
+ struct spi_nor_rww *rww = &nor->rww;
+ u8 first, last;
+ int bank;
+
+ mutex_lock(&nor->lock);
+
+ spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last);
+ for (bank = first; bank <= last; bank++)
+ nor->rww.used_banks &= ~BIT(bank);
+
+ rww->ongoing_io = false;
+ rww->ongoing_rd = false;
+
+ mutex_unlock(&nor->lock);
+}
+
static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, size_t len)
{
int ret;
@@ -1137,14 +1401,23 @@ static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, size_t le
if (ret)
return ret;
- mutex_lock(&nor->lock);
+ if (!spi_nor_use_parallel_locking(nor))
+ mutex_lock(&nor->lock);
+ else
+ ret = wait_event_killable(nor->rww.wait,
+ spi_nor_rww_start_rd(nor, start, len));
- return 0;
+ return ret;
}
static void spi_nor_unlock_and_unprep_rd(struct spi_nor *nor, loff_t start, size_t len)
{
- mutex_unlock(&nor->lock);
+ if (!spi_nor_use_parallel_locking(nor)) {
+ mutex_unlock(&nor->lock);
+ } else {
+ spi_nor_rww_end_rd(nor, start, len);
+ wake_up(&nor->rww.wait);
+ }
spi_nor_unprep(nor);
}
@@ -1453,11 +1726,18 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)
dev_vdbg(nor->dev, "erase_cmd->size = 0x%08x, erase_cmd->opcode = 0x%02x, erase_cmd->count = %u\n",
cmd->size, cmd->opcode, cmd->count);
- ret = spi_nor_write_enable(nor);
+ ret = spi_nor_lock_device(nor);
if (ret)
goto destroy_erase_cmd_list;
+ ret = spi_nor_write_enable(nor);
+ if (ret) {
+ spi_nor_unlock_device(nor);
+ goto destroy_erase_cmd_list;
+ }
+
ret = spi_nor_erase_sector(nor, addr);
+ spi_nor_unlock_device(nor);
if (ret)
goto destroy_erase_cmd_list;
@@ -1510,11 +1790,18 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
if (len == mtd->size && !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) {
unsigned long timeout;
- ret = spi_nor_write_enable(nor);
+ ret = spi_nor_lock_device(nor);
if (ret)
goto erase_err;
+ ret = spi_nor_write_enable(nor);
+ if (ret) {
+ spi_nor_unlock_device(nor);
+ goto erase_err;
+ }
+
ret = spi_nor_erase_chip(nor);
+ spi_nor_unlock_device(nor);
if (ret)
goto erase_err;
@@ -1539,11 +1826,18 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
/* "sector"-at-a-time erase */
} else if (spi_nor_has_uniform_erase(nor)) {
while (len) {
- ret = spi_nor_write_enable(nor);
+ ret = spi_nor_lock_device(nor);
if (ret)
goto erase_err;
+ ret = spi_nor_write_enable(nor);
+ if (ret) {
+ spi_nor_unlock_device(nor);
+ goto erase_err;
+ }
+
ret = spi_nor_erase_sector(nor, addr);
+ spi_nor_unlock_device(nor);
if (ret)
goto erase_err;
@@ -1836,11 +2130,18 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
addr = spi_nor_convert_addr(nor, addr);
- ret = spi_nor_write_enable(nor);
+ ret = spi_nor_lock_device(nor);
if (ret)
goto write_err;
+ ret = spi_nor_write_enable(nor);
+ if (ret) {
+ spi_nor_unlock_device(nor);
+ goto write_err;
+ }
+
ret = spi_nor_write_data(nor, addr, page_remain, buf + i);
+ spi_nor_unlock_device(nor);
if (ret < 0)
goto write_err;
written = ret;
@@ -2531,7 +2832,8 @@ static void spi_nor_init_flags(struct spi_nor *nor)
if (flags & NO_CHIP_ERASE)
nor->flags |= SNOR_F_NO_OP_CHIP_ERASE;
- if (flags & SPI_NOR_RWW)
+ if (flags & SPI_NOR_RWW && nor->info->n_banks > 1 &&
+ !nor->controller_ops)
nor->flags |= SNOR_F_RWW;
}
@@ -3128,6 +3430,9 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
if (ret)
return ret;
+ if (spi_nor_use_parallel_locking(nor))
+ init_waitqueue_head(&nor->rww.wait);
+
/*
* Configure the SPI memory:
* - select op codes for (Fast) Read, Page Program and Sector Erase.
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index a3f8cdca90c8..82547b4b3708 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -343,6 +343,12 @@ struct spi_nor_flash_parameter;
* struct spi_nor - Structure for defining the SPI NOR layer
* @mtd: an mtd_info structure
* @lock: the lock for the read/write/erase/lock/unlock operations
+ * @rww: Read-While-Write (RWW) sync lock
+ * @rww.wait: wait queue for the RWW sync
+ * @rww.ongoing_io: the bus is busy
+ * @rww.ongoing_rd: a read is ongoing on the chip
+ * @rww.ongoing_pe: a program/erase is ongoing on the chip
+ * @rww.used_banks: bitmap of the banks in use
* @dev: pointer to an SPI device or an SPI NOR controller device
* @spimem: pointer to the SPI memory device
* @bouncebuf: bounce buffer used when the buffer passed by the MTD
@@ -376,6 +382,13 @@ struct spi_nor_flash_parameter;
struct spi_nor {
struct mtd_info mtd;
struct mutex lock;
+ struct spi_nor_rww {
+ wait_queue_head_t wait;
+ bool ongoing_io;
+ bool ongoing_rd;
+ bool ongoing_pe;
+ unsigned int used_banks;
+ } rww;
struct device *dev;
struct spi_mem *spimem;
u8 *bouncebuf;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
` (6 preceding siblings ...)
2023-03-28 15:41 ` [PATCH v5 7/8] mtd: spi-nor: Enhance locking to support reads while writes Miquel Raynal
@ 2023-03-28 15:41 ` Miquel Raynal
2023-03-28 16:31 ` Tudor Ambarus
2023-03-29 10:49 ` Re (subset): [PATCH v5 0/8] mtd: spi-nor: read while write support Tudor Ambarus
8 siblings, 1 reply; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 15:41 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel, Miquel Raynal
Describe this new part and provide the RWW flag for it.
There is no public datasheet, but here are the sfdp tables plus base
testing to show it works.
mx25uw51245g
c2813a
macronix
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
000000ff101000200000000000007ca14800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
6+0 records in
6+0 records out
Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
Erased 6291456 bytes from address 0x00000000 in flash
Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
*
0600000
Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/spi-nor/macronix.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index 6853ec9ae65d..b65d41e5f749 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
{ "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+ { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
+ PARSE_SFDP
+ FLAGS(SPI_NOR_RWW)
+ FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
{ "mx25v8035f", INFO(0xc22314, 0, 64 * 1024, 16)
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
SPI_NOR_QUAD_READ) },
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-28 15:41 ` [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW Miquel Raynal
@ 2023-03-28 16:31 ` Tudor Ambarus
2023-03-28 16:45 ` Miquel Raynal
0 siblings, 1 reply; 17+ messages in thread
From: Tudor Ambarus @ 2023-03-28 16:31 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
Pratyush Yadav, Michael Walle, linux-mtd
Cc: Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou, Thomas Petazzoni,
Michal Simek, linux-arm-kernel
On 3/28/23 16:41, Miquel Raynal wrote:
> Describe this new part and provide the RWW flag for it.
>
> There is no public datasheet, but here are the sfdp tables plus base
> testing to show it works.
>
> mx25uw51245g
> c2813a
> macronix
> 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
> 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
> ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
> 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
> 000000ff101000200000000000007ca14800000000008888000000000000
> 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
> 727103b80000000090a3188200c069960000000000000000727100987271
> 00b8727100990000000072710098727100f872710099727100f900000000
> 00000000011501d0727106d8000086500000060100000000020001030002
> 00000000060100000000000072060002000000eec0697272717100d8f7f6
> 000a00001445988043060f0021dcffff
> 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
which hash alg was used, was it sha1? No need to resubmnit just for this.
>
> 6+0 records in
> 6+0 records out
> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> Erased 6291456 bytes from address 0x00000000 in flash
> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
> *
> 0600000
> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> drivers/mtd/spi-nor/macronix.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> index 6853ec9ae65d..b65d41e5f749 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c
> @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
> { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
> NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
> FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
Sector size and nsectors shall be discovered at parse SFDP time.
Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
> + PARSE_SFDP
Yaay
> + FLAGS(SPI_NOR_RWW)
> + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
Is SPI_NOR_4B_OPCODES flag really needed?
> { "mx25v8035f", INFO(0xc22314, 0, 64 * 1024, 16)
> NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
> SPI_NOR_QUAD_READ) },
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-28 16:31 ` Tudor Ambarus
@ 2023-03-28 16:45 ` Miquel Raynal
2023-03-29 5:48 ` liao jaime
0 siblings, 1 reply; 17+ messages in thread
From: Miquel Raynal @ 2023-03-28 16:45 UTC (permalink / raw)
To: Tudor Ambarus
Cc: Richard Weinberger, Vignesh Raghavendra, Pratyush Yadav,
Michael Walle, linux-mtd, Julien Su, Jaime Liao, Jaime Liao,
Alvin Zhou, Thomas Petazzoni, Michal Simek, linux-arm-kernel
Hi Tudor,
tudor.ambarus@linaro.org wrote on Tue, 28 Mar 2023 17:31:46 +0100:
> On 3/28/23 16:41, Miquel Raynal wrote:
> > Describe this new part and provide the RWW flag for it.
> >
> > There is no public datasheet, but here are the sfdp tables plus base
> > testing to show it works.
> >
> > mx25uw51245g
> > c2813a
> > macronix
> > 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
> > 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
> > ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
> > 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
> > 000000ff101000200000000000007ca14800000000008888000000000000
> > 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
> > 727103b80000000090a3188200c069960000000000000000727100987271
> > 00b8727100990000000072710098727100f872710099727100f900000000
> > 00000000011501d0727106d8000086500000060100000000020001030002
> > 00000000060100000000000072060002000000eec0697272717100d8f7f6
> > 000a00001445988043060f0021dcffff
> > 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
>
> which hash alg was used, was it sha1? No need to resubmnit just for this.
Actually git just ignored all the lines starting with '#'
like if they were comments and I did not notice...
I will amend my commit logs and resend.
> >
> > 6+0 records in
> > 6+0 records out
> > Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> > Erased 6291456 bytes from address 0x00000000 in flash
> > Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> > 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
> > *
> > 0600000
> > Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> > Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> > d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
> > d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
> >
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > drivers/mtd/spi-nor/macronix.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> > index 6853ec9ae65d..b65d41e5f749 100644
> > --- a/drivers/mtd/spi-nor/macronix.c
> > +++ b/drivers/mtd/spi-nor/macronix.c
> > @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
> > { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
> > NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
> > FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> > + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
>
> Sector size and nsectors shall be discovered at parse SFDP time.
> Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
I'll check.
>
> > + PARSE_SFDP
>
> Yaay
>
> > + FLAGS(SPI_NOR_RWW)
> > + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
>
> Is SPI_NOR_4B_OPCODES flag really needed?
I have no idea, I took that from older code.
Jaime, what do you think?
Thanks,
Miquèl
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-28 16:45 ` Miquel Raynal
@ 2023-03-29 5:48 ` liao jaime
2023-03-29 11:12 ` Tudor Ambarus
0 siblings, 1 reply; 17+ messages in thread
From: liao jaime @ 2023-03-29 5:48 UTC (permalink / raw)
To: Miquel Raynal
Cc: Tudor Ambarus, Richard Weinberger, Vignesh Raghavendra,
Pratyush Yadav, Michael Walle, linux-mtd, Julien Su, Jaime Liao,
Alvin Zhou, Thomas Petazzoni, Michal Simek, linux-arm-kernel
Hi Miquel
>
> Hi Tudor,
>
> tudor.ambarus@linaro.org wrote on Tue, 28 Mar 2023 17:31:46 +0100:
>
> > On 3/28/23 16:41, Miquel Raynal wrote:
> > > Describe this new part and provide the RWW flag for it.
> > >
> > > There is no public datasheet, but here are the sfdp tables plus base
> > > testing to show it works.
> > >
> > > mx25uw51245g
> > > c2813a
> > > macronix
> > > 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
> > > 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
> > > ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
> > > 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
> > > 000000ff101000200000000000007ca14800000000008888000000000000
> > > 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
> > > 727103b80000000090a3188200c069960000000000000000727100987271
> > > 00b8727100990000000072710098727100f872710099727100f900000000
> > > 00000000011501d0727106d8000086500000060100000000020001030002
> > > 00000000060100000000000072060002000000eec0697272717100d8f7f6
> > > 000a00001445988043060f0021dcffff
> > > 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> >
> > which hash alg was used, was it sha1? No need to resubmnit just for this.
>
> Actually git just ignored all the lines starting with '#'
> like if they were comments and I did not notice...
>
> I will amend my commit logs and resend.
>
> > >
> > > 6+0 records in
> > > 6+0 records out
> > > Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> > > Erased 6291456 bytes from address 0x00000000 in flash
> > > Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> > > 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
> > > *
> > > 0600000
> > > Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> > > Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> > > d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
> > > d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
> > >
> > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > > ---
> > > drivers/mtd/spi-nor/macronix.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> > > index 6853ec9ae65d..b65d41e5f749 100644
> > > --- a/drivers/mtd/spi-nor/macronix.c
> > > +++ b/drivers/mtd/spi-nor/macronix.c
> > > @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
> > > { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
> > > NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
> > > FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> > > + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
> >
> > Sector size and nsectors shall be discovered at parse SFDP time.
> > Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
>
> I'll check.
>
> >
> > > + PARSE_SFDP
> >
> > Yaay
> >
> > > + FLAGS(SPI_NOR_RWW)
> > > + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> >
> > Is SPI_NOR_4B_OPCODES flag really needed?
>
> I have no idea, I took that from older code.
>
> Jaime, what do you think?
I think Tudor hopes that SFDP table could determine how many address bytes.
In sfdp.c, "spi_nor_parse_bfpt" will check number of address bytes if
flash with SFDP table support.
Thanks
Jaime
>
> Thanks,
> Miquèl
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re (subset): [PATCH v5 0/8] mtd: spi-nor: read while write support
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
` (7 preceding siblings ...)
2023-03-28 15:41 ` [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW Miquel Raynal
@ 2023-03-29 10:49 ` Tudor Ambarus
8 siblings, 0 replies; 17+ messages in thread
From: Tudor Ambarus @ 2023-03-29 10:49 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Pratyush Yadav,
Michael Walle, linux-mtd, Miquel Raynal
Cc: Tudor Ambarus, Julien Su, Jaime Liao, Jaime Liao, Alvin Zhou,
Thomas Petazzoni, Michal Simek, linux-arm-kernel
On Tue, 28 Mar 2023 17:40:57 +0200, Miquel Raynal wrote:
> Here is a new version of this series 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.
>
> [...]
Applied to git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git,
spi-nor/next branch. Thanks!
[1/8] mtd: spi-nor: Introduce the concept of bank
https://git.kernel.org/mtd/c/9d6c5d64f028
[2/8] mtd: spi-nor: Add a macro to define more banks
https://git.kernel.org/mtd/c/ccff2cfa1ac3
[3/8] mtd: spi-nor: Reorder the preparation vs. locking steps
https://git.kernel.org/mtd/c/320463477235
[4/8] mtd: spi-nor: Separate preparation and locking
https://git.kernel.org/mtd/c/c154dbd28003
[5/8] mtd: spi-nor: Prepare the introduction of a new locking mechanism
https://git.kernel.org/mtd/c/e96d4605b024
[6/8] mtd: spi-nor: Add a RWW flag
https://git.kernel.org/mtd/c/4eddee70140b
[7/8] mtd: spi-nor: Enhance locking to support reads while writes
https://git.kernel.org/mtd/c/74df43b3f626
Cheers,
--
Tudor Ambarus <tudor.ambarus@linaro.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-29 5:48 ` liao jaime
@ 2023-03-29 11:12 ` Tudor Ambarus
2023-03-29 11:54 ` Miquel Raynal
2023-03-31 19:37 ` Miquel Raynal
0 siblings, 2 replies; 17+ messages in thread
From: Tudor Ambarus @ 2023-03-29 11:12 UTC (permalink / raw)
To: liao jaime, Miquel Raynal
Cc: Richard Weinberger, Vignesh Raghavendra, Pratyush Yadav,
Michael Walle, linux-mtd, Julien Su, Jaime Liao, Alvin Zhou,
Thomas Petazzoni, Michal Simek, linux-arm-kernel
On 3/29/23 06:48, liao jaime wrote:
> Hi Miquel
>
>>
>> Hi Tudor,
>>
>> tudor.ambarus@linaro.org wrote on Tue, 28 Mar 2023 17:31:46 +0100:
>>
>>> On 3/28/23 16:41, Miquel Raynal wrote:
>>>> Describe this new part and provide the RWW flag for it.
>>>>
>>>> There is no public datasheet, but here are the sfdp tables plus base
>>>> testing to show it works.
>>>>
>>>> mx25uw51245g
>>>> c2813a
>>>> macronix
>>>> 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
>>>> 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
>>>> ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
>>>> 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
>>>> 000000ff101000200000000000007ca14800000000008888000000000000
>>>> 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
>>>> 727103b80000000090a3188200c069960000000000000000727100987271
>>>> 00b8727100990000000072710098727100f872710099727100f900000000
>>>> 00000000011501d0727106d8000086500000060100000000020001030002
>>>> 00000000060100000000000072060002000000eec0697272717100d8f7f6
>>>> 000a00001445988043060f0021dcffff
>>>> 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
>>>
>>> which hash alg was used, was it sha1? No need to resubmnit just for this.
>>
>> Actually git just ignored all the lines starting with '#'
>> like if they were comments and I did not notice...
>>
>> I will amend my commit logs and resend.
>>
>>>>
>>>> 6+0 records in
>>>> 6+0 records out
>>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
>>>> Erased 6291456 bytes from address 0x00000000 in flash
>>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
>>>> 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
>>>> *
>>>> 0600000
>>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
>>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
>>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
>>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
>>>>
>>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>>>> ---
>>>> drivers/mtd/spi-nor/macronix.c | 4 ++++
>>>> 1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
>>>> index 6853ec9ae65d..b65d41e5f749 100644
>>>> --- a/drivers/mtd/spi-nor/macronix.c
>>>> +++ b/drivers/mtd/spi-nor/macronix.c
>>>> @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
>>>> { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
>>>> NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
>>>> FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
>>>> + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
>>>
>>> Sector size and nsectors shall be discovered at parse SFDP time.
>>> Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
>>
>> I'll check.
>>
>>>
>>>> + PARSE_SFDP
>>>
>>> Yaay
>>>
>>>> + FLAGS(SPI_NOR_RWW)
>>>> + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
>>>
>>> Is SPI_NOR_4B_OPCODES flag really needed?
>>
>> I have no idea, I took that from older code.
>>
>> Jaime, what do you think?
> I think Tudor hopes that SFDP table could determine how many address bytes.
No, no.
:) and hope and programming don't get along.
Does this flash define the 4bait table? Can you add a print in
parse_4bait table and check if SNOR_F_4B_OPCODES is set? If yes, the
fixup flag is not needed.
SNOR_F_4B_OPCODES is an indication that the flash supports dedicated
opcodes for 4byte address, without the need to change the address mode
to 4 byte. When 4B_OPCODES are supported, we prefer not changing the
address mode, because when changing to 4 byte address mode, the state is
kept at reset (or power loss) and flashes might not be able to boot at
lower layers (u-boot for example).
So I'd try:
{ "mx25uw51245g", INFOB(0xc2813a, 0, 0, 0, 4)
PARSE_SFDP
FLAGS(SPI_NOR_RWW) },
In the future we'd like to add a sfdp-decoder in mtd-utils to decode the
sfdp dump and ease the review and avoid such questions, but we couldn't
allocate the time to implement it up to now. Meh, we're doing it at best
effort, in our spare time. Volunteers?
Cheers,
ta
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-29 11:12 ` Tudor Ambarus
@ 2023-03-29 11:54 ` Miquel Raynal
2023-03-31 19:37 ` Miquel Raynal
1 sibling, 0 replies; 17+ messages in thread
From: Miquel Raynal @ 2023-03-29 11:54 UTC (permalink / raw)
To: Tudor Ambarus
Cc: liao jaime, Richard Weinberger, Vignesh Raghavendra,
Pratyush Yadav, Michael Walle, linux-mtd, Julien Su, Jaime Liao,
Alvin Zhou, Thomas Petazzoni, Michal Simek, linux-arm-kernel
Hi Tudor,
tudor.ambarus@linaro.org wrote on Wed, 29 Mar 2023 12:12:29 +0100:
> On 3/29/23 06:48, liao jaime wrote:
> > Hi Miquel
> >
> >>
> >> Hi Tudor,
> >>
> >> tudor.ambarus@linaro.org wrote on Tue, 28 Mar 2023 17:31:46 +0100:
> >>
> >>> On 3/28/23 16:41, Miquel Raynal wrote:
> >>>> Describe this new part and provide the RWW flag for it.
> >>>>
> >>>> There is no public datasheet, but here are the sfdp tables plus base
> >>>> testing to show it works.
> >>>>
> >>>> mx25uw51245g
> >>>> c2813a
> >>>> macronix
> >>>> 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
> >>>> 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
> >>>> ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
> >>>> 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
> >>>> 000000ff101000200000000000007ca14800000000008888000000000000
> >>>> 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
> >>>> 727103b80000000090a3188200c069960000000000000000727100987271
> >>>> 00b8727100990000000072710098727100f872710099727100f900000000
> >>>> 00000000011501d0727106d8000086500000060100000000020001030002
> >>>> 00000000060100000000000072060002000000eec0697272717100d8f7f6
> >>>> 000a00001445988043060f0021dcffff
> >>>> 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> >>>
> >>> which hash alg was used, was it sha1? No need to resubmnit just for this.
> >>
> >> Actually git just ignored all the lines starting with '#'
> >> like if they were comments and I did not notice...
> >>
> >> I will amend my commit logs and resend.
> >>
> >>>>
> >>>> 6+0 records in
> >>>> 6+0 records out
> >>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> >>>> Erased 6291456 bytes from address 0x00000000 in flash
> >>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> >>>> 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
> >>>> *
> >>>> 0600000
> >>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> >>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> >>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
> >>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
> >>>>
> >>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> >>>> ---
> >>>> drivers/mtd/spi-nor/macronix.c | 4 ++++
> >>>> 1 file changed, 4 insertions(+)
> >>>>
> >>>> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> >>>> index 6853ec9ae65d..b65d41e5f749 100644
> >>>> --- a/drivers/mtd/spi-nor/macronix.c
> >>>> +++ b/drivers/mtd/spi-nor/macronix.c
> >>>> @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
> >>>> { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
> >>>> NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
> >>>> FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> >>>> + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
> >>>
> >>> Sector size and nsectors shall be discovered at parse SFDP time.
> >>> Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
> >>
> >> I'll check.
> >>
> >>>
> >>>> + PARSE_SFDP
> >>>
> >>> Yaay
> >>>
> >>>> + FLAGS(SPI_NOR_RWW)
> >>>> + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> >>>
> >>> Is SPI_NOR_4B_OPCODES flag really needed?
> >>
> >> I have no idea, I took that from older code.
> >>
> >> Jaime, what do you think?
> > I think Tudor hopes that SFDP table could determine how many address bytes.
>
> No, no.
>
> :) and hope and programming don't get along.
>
> Does this flash define the 4bait table? Can you add a print in
> parse_4bait table and check if SNOR_F_4B_OPCODES is set? If yes, the
> fixup flag is not needed.
Alright, will check.
>
> SNOR_F_4B_OPCODES is an indication that the flash supports dedicated
> opcodes for 4byte address, without the need to change the address mode
> to 4 byte. When 4B_OPCODES are supported, we prefer not changing the
> address mode, because when changing to 4 byte address mode, the state is
> kept at reset (or power loss) and flashes might not be able to boot at
> lower layers (u-boot for example).
Oh yeah I remember.
>
> So I'd try:
> { "mx25uw51245g", INFOB(0xc2813a, 0, 0, 0, 4)
> PARSE_SFDP
> FLAGS(SPI_NOR_RWW) },
Clear!
>
> In the future we'd like to add a sfdp-decoder in mtd-utils to decode the
> sfdp dump and ease the review and avoid such questions, but we couldn't
> allocate the time to implement it up to now. Meh, we're doing it at best
> effort, in our spare time. Volunteers?
I really like the idea! Would be excellent.
Thanks,
Miquèl
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-29 11:12 ` Tudor Ambarus
2023-03-29 11:54 ` Miquel Raynal
@ 2023-03-31 19:37 ` Miquel Raynal
2023-04-03 8:08 ` Tudor Ambarus
1 sibling, 1 reply; 17+ messages in thread
From: Miquel Raynal @ 2023-03-31 19:37 UTC (permalink / raw)
To: Tudor Ambarus
Cc: liao jaime, Richard Weinberger, Vignesh Raghavendra,
Pratyush Yadav, Michael Walle, linux-mtd, Julien Su, Jaime Liao,
Alvin Zhou, Thomas Petazzoni, Michal Simek, linux-arm-kernel
Hi Tudor,
tudor.ambarus@linaro.org wrote on Wed, 29 Mar 2023 12:12:29 +0100:
> On 3/29/23 06:48, liao jaime wrote:
> > Hi Miquel
> >
> >>
> >> Hi Tudor,
> >>
> >> tudor.ambarus@linaro.org wrote on Tue, 28 Mar 2023 17:31:46 +0100:
> >>
> >>> On 3/28/23 16:41, Miquel Raynal wrote:
> >>>> Describe this new part and provide the RWW flag for it.
> >>>>
> >>>> There is no public datasheet, but here are the sfdp tables plus base
> >>>> testing to show it works.
> >>>>
> >>>> mx25uw51245g
> >>>> c2813a
> >>>> macronix
> >>>> 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
> >>>> 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
> >>>> ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
> >>>> 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
> >>>> 000000ff101000200000000000007ca14800000000008888000000000000
> >>>> 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
> >>>> 727103b80000000090a3188200c069960000000000000000727100987271
> >>>> 00b8727100990000000072710098727100f872710099727100f900000000
> >>>> 00000000011501d0727106d8000086500000060100000000020001030002
> >>>> 00000000060100000000000072060002000000eec0697272717100d8f7f6
> >>>> 000a00001445988043060f0021dcffff
> >>>> 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> >>>
> >>> which hash alg was used, was it sha1? No need to resubmnit just for this.
> >>
> >> Actually git just ignored all the lines starting with '#'
> >> like if they were comments and I did not notice...
> >>
> >> I will amend my commit logs and resend.
> >>
> >>>>
> >>>> 6+0 records in
> >>>> 6+0 records out
> >>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> >>>> Erased 6291456 bytes from address 0x00000000 in flash
> >>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> >>>> 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
> >>>> *
> >>>> 0600000
> >>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
> >>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
> >>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
> >>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
> >>>>
> >>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> >>>> ---
> >>>> drivers/mtd/spi-nor/macronix.c | 4 ++++
> >>>> 1 file changed, 4 insertions(+)
> >>>>
> >>>> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> >>>> index 6853ec9ae65d..b65d41e5f749 100644
> >>>> --- a/drivers/mtd/spi-nor/macronix.c
> >>>> +++ b/drivers/mtd/spi-nor/macronix.c
> >>>> @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
> >>>> { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
> >>>> NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
> >>>> FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> >>>> + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
> >>>
> >>> Sector size and nsectors shall be discovered at parse SFDP time.
> >>> Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
> >>
> >> I'll check.
> >>
> >>>
> >>>> + PARSE_SFDP
> >>>
> >>> Yaay
> >>>
> >>>> + FLAGS(SPI_NOR_RWW)
> >>>> + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
> >>>
> >>> Is SPI_NOR_4B_OPCODES flag really needed?
> >>
> >> I have no idea, I took that from older code.
> >>
> >> Jaime, what do you think?
> > I think Tudor hopes that SFDP table could determine how many address bytes.
>
> No, no.
>
> :) and hope and programming don't get along.
>
> Does this flash define the 4bait table? Can you add a print in
> parse_4bait table and check if SNOR_F_4B_OPCODES is set? If yes, the
> fixup flag is not needed.
>
> SNOR_F_4B_OPCODES is an indication that the flash supports dedicated
> opcodes for 4byte address, without the need to change the address mode
> to 4 byte. When 4B_OPCODES are supported, we prefer not changing the
> address mode, because when changing to 4 byte address mode, the state is
> kept at reset (or power loss) and flashes might not be able to boot at
> lower layers (u-boot for example).
The flag is set, no need for hardcoding it.
Excellent, I'll prepare the patch.
While I was testing I figured out: the bank size calculation happens
too early, so if we discover the size with the SFDP table, that won't
work. I'll fix it, feel free to squash the patch if you prefer.
>
> So I'd try:
> { "mx25uw51245g", INFOB(0xc2813a, 0, 0, 0, 4)
> PARSE_SFDP
> FLAGS(SPI_NOR_RWW) },
>
> In the future we'd like to add a sfdp-decoder in mtd-utils to decode the
> sfdp dump and ease the review and avoid such questions, but we couldn't
> allocate the time to implement it up to now. Meh, we're doing it at best
> effort, in our spare time. Volunteers?
>
> Cheers,
> ta
Thanks,
Miquèl
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW
2023-03-31 19:37 ` Miquel Raynal
@ 2023-04-03 8:08 ` Tudor Ambarus
0 siblings, 0 replies; 17+ messages in thread
From: Tudor Ambarus @ 2023-04-03 8:08 UTC (permalink / raw)
To: Miquel Raynal
Cc: liao jaime, Richard Weinberger, Vignesh Raghavendra,
Pratyush Yadav, Michael Walle, linux-mtd, Julien Su, Jaime Liao,
Alvin Zhou, Thomas Petazzoni, Michal Simek, linux-arm-kernel
On 3/31/23 20:37, Miquel Raynal wrote:
> Hi Tudor,
>
Hi!
> tudor.ambarus@linaro.org wrote on Wed, 29 Mar 2023 12:12:29 +0100:
>
>> On 3/29/23 06:48, liao jaime wrote:
>>> Hi Miquel
>>>
>>>>
>>>> Hi Tudor,
>>>>
>>>> tudor.ambarus@linaro.org wrote on Tue, 28 Mar 2023 17:31:46 +0100:
>>>>
>>>>> On 3/28/23 16:41, Miquel Raynal wrote:
>>>>>> Describe this new part and provide the RWW flag for it.
>>>>>>
>>>>>> There is no public datasheet, but here are the sfdp tables plus base
>>>>>> testing to show it works.
>>>>>>
>>>>>> mx25uw51245g
>>>>>> c2813a
>>>>>> macronix
>>>>>> 53464450080104fd00070114400000ff8701011c900000ff0a0001080001
>>>>>> 00ff05000105200100ff84000102340100ff0000000000000000ffffffff
>>>>>> ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
>>>>>> 00ff0c2010d800ff00ff87790100821200e27704674630b030b0f4bdd55c
>>>>>> 000000ff101000200000000000007ca14800000000008888000000000000
>>>>>> 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
>>>>>> 727103b80000000090a3188200c069960000000000000000727100987271
>>>>>> 00b8727100990000000072710098727100f872710099727100f900000000
>>>>>> 00000000011501d0727106d8000086500000060100000000020001030002
>>>>>> 00000000060100000000000072060002000000eec0697272717100d8f7f6
>>>>>> 000a00001445988043060f0021dcffff
>>>>>> 047a884cf44d9ffc2a94d3ab37b48c63 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
>>>>>
>>>>> which hash alg was used, was it sha1? No need to resubmnit just for this.
>>>>
>>>> Actually git just ignored all the lines starting with '#'
>>>> like if they were comments and I did not notice...
>>>>
>>>> I will amend my commit logs and resend.
>>>>
>>>>>>
>>>>>> 6+0 records in
>>>>>> 6+0 records out
>>>>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
>>>>>> Erased 6291456 bytes from address 0x00000000 in flash
>>>>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
>>>>>> 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
>>>>>> *
>>>>>> 0600000
>>>>>> Copied 6291456 bytes from qspi_test to address 0x00000000 in flash
>>>>>> Copied 6291456 bytes from address 0x00000000 in flash to qspi_read
>>>>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_test
>>>>>> d24a9523db829a0df688f34b8dc76a1383b74024 qspi_read
>>>>>>
>>>>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>>>>>> ---
>>>>>> drivers/mtd/spi-nor/macronix.c | 4 ++++
>>>>>> 1 file changed, 4 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
>>>>>> index 6853ec9ae65d..b65d41e5f749 100644
>>>>>> --- a/drivers/mtd/spi-nor/macronix.c
>>>>>> +++ b/drivers/mtd/spi-nor/macronix.c
>>>>>> @@ -82,6 +82,10 @@ static const struct flash_info macronix_nor_parts[] = {
>>>>>> { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024)
>>>>>> NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
>>>>>> FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
>>>>>> + { "mx25uw51245g", INFOB(0xc2813a, 0, 16 * 1024, 1024, 4)
>>>>>
>>>>> Sector size and nsectors shall be discovered at parse SFDP time.
>>>>> Does INFOB(0xc2813a, 0, 0, 0, 4) work for you?
>>>>
>>>> I'll check.
>>>>
>>>>>
>>>>>> + PARSE_SFDP
>>>>>
>>>>> Yaay
>>>>>
>>>>>> + FLAGS(SPI_NOR_RWW)
>>>>>> + FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
>>>>>
>>>>> Is SPI_NOR_4B_OPCODES flag really needed?
>>>>
>>>> I have no idea, I took that from older code.
>>>>
>>>> Jaime, what do you think?
>>> I think Tudor hopes that SFDP table could determine how many address bytes.
>>
>> No, no.
>>
>> :) and hope and programming don't get along.
>>
>> Does this flash define the 4bait table? Can you add a print in
>> parse_4bait table and check if SNOR_F_4B_OPCODES is set? If yes, the
>> fixup flag is not needed.
>>
>> SNOR_F_4B_OPCODES is an indication that the flash supports dedicated
>> opcodes for 4byte address, without the need to change the address mode
>> to 4 byte. When 4B_OPCODES are supported, we prefer not changing the
>> address mode, because when changing to 4 byte address mode, the state is
>> kept at reset (or power loss) and flashes might not be able to boot at
>> lower layers (u-boot for example).
>
> The flag is set, no need for hardcoding it.
>
> Excellent, I'll prepare the patch.
>
> While I was testing I figured out: the bank size calculation happens
> too early, so if we discover the size with the SFDP table, that won't
> work. I'll fix it, feel free to squash the patch if you prefer.
>
Indeed. Michael or me are going to fix the n_sectors and sector_size
handling soon. Separate patch is fine, I don't change git history unless
really needed.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2023-04-03 8:09 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-28 15:40 [PATCH v5 0/8] mtd: spi-nor: read while write support Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 1/8] mtd: spi-nor: Introduce the concept of bank Miquel Raynal
2023-03-28 15:40 ` [PATCH v5 2/8] mtd: spi-nor: Add a macro to define more banks Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 3/8] mtd: spi-nor: Reorder the preparation vs. locking steps Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 4/8] mtd: spi-nor: Separate preparation and locking Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 5/8] mtd: spi-nor: Prepare the introduction of a new locking mechanism Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 6/8] mtd: spi-nor: Add a RWW flag Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 7/8] mtd: spi-nor: Enhance locking to support reads while writes Miquel Raynal
2023-03-28 15:41 ` [PATCH v5 8/8] mtd: spi-nor: macronix: Add support for mx25uw51245g with RWW Miquel Raynal
2023-03-28 16:31 ` Tudor Ambarus
2023-03-28 16:45 ` Miquel Raynal
2023-03-29 5:48 ` liao jaime
2023-03-29 11:12 ` Tudor Ambarus
2023-03-29 11:54 ` Miquel Raynal
2023-03-31 19:37 ` Miquel Raynal
2023-04-03 8:08 ` Tudor Ambarus
2023-03-29 10:49 ` Re (subset): [PATCH v5 0/8] mtd: spi-nor: read while write support Tudor Ambarus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).