linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/27] spi-nand/spi-mem DTR support
@ 2024-12-24 17:05 Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 01/27] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency Miquel Raynal
                   ` (27 more replies)
  0 siblings, 28 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, Pratyush Yadav,
	Tudor Ambarus, stable+noautosel

Hello Mark, hello MTD folks,

Here is a (big) series supposed to bring DTR support in SPI-NAND.

I could have split this into two but I eventually preferred showing the
big picture. Once v1 will be over, I can make it two. However when we'll
discuss merging, we'll have to share an immutable tag among the two
subsystems.

Here is the logic:
* patches 1 & 2 add support for spi-mem operations with a specific
  frequency limitation. This is not only related to DTR support, because
  as you can see I could use this to support basic features in the
  Winbond driver.
* patches 3-17 are going through all the easy controller drivers, where
  effectively supporting these per-operation limitation was easy to
  do. In practice, I believe all controllers can, but software is
  sometimes the limiting factor. All controllers without spi-mem support
  will gracefully handle the request (provided that they already care
  about the maximum speed of course), and all the updated controllers in
  this series will also handle the situation correctly. For the others,
  it's an opt-in parameter, so they will simply refuse the operation
  during the checks_op/supports_op() phase.
* patches 18-20 add DTR support in spi-mem.
* patches 21-24 add DTR support in SPI-NAND.
* patches 25-27 add DTR support to Winbon chips.

---
Changes in v2:
- Fixed breakage reported by Mark.
- Created an "adjust_op_freq" helper in the core and used it from
  spi_mem_exec_op(). This way it is called only once. The main parameter
  must still be casted otherwise we would need to do the call outside of
  spi_mem_exec_op() which would imply about 40 different changes in the
  core and drivers and also the assurance that we would get it wrong
  again later.
- Reworked the logic for picking the best variant to include all
  subtleties due to maximum/supported frequencies. The choice takes
  slightly longer now but should return the truly fastest variant for
  each case.
- Removed unique parenthesis in some kdoc comment.
- Fixed the inconsistency when handling the maximum per operation
  frequencies between spi-mem and non spi-mem controllers.
- Fixed many typos.
- Added a core check to validate the per op frequency against the minimum
  supported frequencies by controller drivers.
- Removed a useless check from the amd driver and turned a function
  void. Also used the controller parameters in this driver rather than
  the top-level definitions.
- Clarified some of the commit logs.
- Collected tags.
- Prevented a patch from being picked-up automatically by the stable
  team.
- Reordered some terms in macros in the spi-mem core.
- Rebased on top of v6.13-rc1.
- Link to v1: https://lore.kernel.org/r/20241025161501.485684-1-miquel.raynal@bootlin.com

---
Miquel Raynal (27):
      spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency
      spi: spi-mem: Add a new controller capability
      spi: amd: Support per spi-mem operation frequency switches
      spi: amd: Drop redundant check
      spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches
      spi: cadence-qspi: Support per spi-mem operation frequency switches
      spi: dw: Support per spi-mem operation frequency switches
      spi: fsl-qspi: Support per spi-mem operation frequency switches
      spi: microchip-core-qspi: Support per spi-mem operation frequency switches
      spi: mt65xx: Support per spi-mem operation frequency switches
      spi: mxic: Support per spi-mem operation frequency switches
      spi: nxp-fspi: Support per spi-mem operation frequency switches
      spi: rockchip-sfc: Support per spi-mem operation frequency switches
      spi: spi-sn-f-ospi: Support per spi-mem operation frequency switches
      spi: spi-ti-qspi: Support per spi-mem operation frequency switches
      spi: zynq-qspi: Support per spi-mem operation frequency switches
      spi: zynqmp-gqspi: Support per spi-mem operation frequency switches
      spi: spi-mem: Reorder spi-mem macro assignments
      spi: spi-mem: Create macros for DTR operation
      spi: spi-mem: Estimate the time taken by operations
      mtd: spinand: Create distinct fast and slow read from cache variants
      mtd: spinand: Add an optional frequency to read from cache macros
      mtd: spinand: Enhance the logic when picking a variant
      mtd: spinand: Add support for read DTR operations
      mtd: spinand: winbond: Update the *JW chip definitions
      mtd: spinand: winbond: Add comment about naming
      mtd: spinand: winbond: Add support for DTR operations

 drivers/mtd/nand/spi/alliancememory.c |  4 +--
 drivers/mtd/nand/spi/ato.c            |  4 +--
 drivers/mtd/nand/spi/core.c           | 15 ++++++--
 drivers/mtd/nand/spi/esmt.c           |  4 +--
 drivers/mtd/nand/spi/foresee.c        |  4 +--
 drivers/mtd/nand/spi/gigadevice.c     | 16 ++++-----
 drivers/mtd/nand/spi/macronix.c       |  4 +--
 drivers/mtd/nand/spi/micron.c         |  8 ++---
 drivers/mtd/nand/spi/paragon.c        |  4 +--
 drivers/mtd/nand/spi/toshiba.c        |  4 +--
 drivers/mtd/nand/spi/winbond.c        | 27 ++++++++++++---
 drivers/mtd/nand/spi/xtx.c            |  4 +--
 drivers/spi/spi-amd.c                 | 21 ++++++------
 drivers/spi/spi-amlogic-spifc-a1.c    |  7 +++-
 drivers/spi/spi-cadence-quadspi.c     |  3 +-
 drivers/spi/spi-dw-core.c             | 10 ++++--
 drivers/spi/spi-fsl-qspi.c            | 12 +++++--
 drivers/spi/spi-mem.c                 | 64 +++++++++++++++++++++++++++++++++++
 drivers/spi/spi-microchip-core-qspi.c | 26 +++++++++++---
 drivers/spi/spi-mt65xx.c              |  7 +++-
 drivers/spi/spi-mxic.c                |  3 +-
 drivers/spi/spi-nxp-fspi.c            | 12 +++++--
 drivers/spi/spi-rockchip-sfc.c        | 11 ++++--
 drivers/spi/spi-sn-f-ospi.c           |  8 +++--
 drivers/spi/spi-ti-qspi.c             |  7 +++-
 drivers/spi/spi-zynq-qspi.c           | 13 +++++--
 drivers/spi/spi-zynqmp-gqspi.c        | 13 ++++---
 include/linux/mtd/spinand.h           | 58 ++++++++++++++++++++++++++++---
 include/linux/spi/spi-mem.h           | 56 +++++++++++++++++++++++++++++-
 29 files changed, 349 insertions(+), 80 deletions(-)
---
base-commit: 9100187b36091e5cc046d1f415f50a04ec31c25f
change-id: 20241210-winbond-6-11-rc1-quad-support-0148205a21a2

Best regards,
-- 
Miquel Raynal <miquel.raynal@bootlin.com>



^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v2 01/27] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 02/27] spi: spi-mem: Add a new controller capability Miquel Raynal
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, Pratyush Yadav

In the spi subsystem, the bus frequency is derived as follows:
- the controller may expose a minimum and maximum operating frequency
- the hardware description, through the spi peripheral properties,
  advise what is the maximum acceptable frequency from a device/wiring
  point of view.
Transfers must be observed at a frequency which fits both (so in
practice, the lowest maximum).

Actually, this second point mixes two information and already takes the
lowest frequency among:
- what the spi device is capable of (what is written in the component
  datasheet)
- what the wiring allows (electromagnetic sensibility, crossovers,
  terminations, antenna effect, etc).

This logic works until spi devices are no longer capable of sustaining
their highest frequency regardless of the operation. Spi memories are
typically subject to such variation. Some devices are capable of
spitting their internally stored data (essentially in read mode) at a
very fast rate, typically up to 166MHz on Winbond SPI-NAND chips, using
"fast" commands. However, some of the low-end operations, such as
regular page read-from-cache commands, are more limited and can only be
executed at 54MHz at most. This is currently a problem in the SPI-NAND
subsystem. Another situation, even if not yet supported, will be with
DTR commands, when the data is latched on both edges of the clock. The
same chips as mentioned previously are in this case limited to
80MHz. Yet another example might be continuous reads, which, under
certain circumstances, can also run at most at 104 or 120MHz.

As a matter of fact, the "one frequency per chip" policy is outdated and
more fine grain configuration is needed: we need to allow per-operation
frequency limitations. So far, all datasheets I encountered advertise a
maximum default frequency, which need to be lowered for certain specific
operations. So based on the current infrastructure, we can still expect
firmware (device trees in general) to continued advertising the same
maximum speed which is a mix between the PCB limitations and the chip
maximum capability, and expect per-operation lower frequencies when this
is relevant.

Add a `struct spi_mem_op` member to carry this information. Not
providing this field explicitly from upper layers means that there is no
further constraint and the default spi device maximum speed will be
carried instead. The SPI_MEM_OP() macro is also expanded with an
optional frequency argument, because virtually all operations can be
subject to such a limitation, and this will allow for a smooth and
discrete transition.

For controller drivers which do not implement the spi-mem interface, the
per-transfer speed is also set acordingly to a lower (than the maximum
default) speed when relevant.

Acked-by: Pratyush Yadav <pratyush@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/spi/core.c |  2 ++
 drivers/spi/spi-mem.c       | 28 ++++++++++++++++++++++++++++
 include/linux/spi/spi-mem.h | 12 +++++++++++-
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index b1df7f6271616ba1e6a9718b7aea2512795505dc..94f33c8be031ac60208e22e4e3fa0d90cfae093c 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1214,6 +1214,8 @@ spinand_select_op_variant(struct spinand_device *spinand,
 			if (ret)
 				break;
 
+			spi_mem_adjust_op_freq(spinand->spimem, &op);
+
 			if (!spi_mem_supports_op(spinand->spimem, &op))
 				break;
 
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index abc6792e738c730166ef9b0aa505ce5225893938..12299ce89a1cc80495858dbbbaa822f2968bb7ab 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -187,6 +187,10 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
 			return false;
 	}
 
+	if (op->max_freq && mem->spi->controller->min_speed_hz &&
+	    op->max_freq < mem->spi->controller->min_speed_hz)
+		return false;
+
 	return spi_mem_check_buswidth(mem, op);
 }
 EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);
@@ -364,6 +368,9 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 	u8 *tmpbuf;
 	int ret;
 
+	/* Make sure the operation frequency is correct before going futher */
+	spi_mem_adjust_op_freq(mem, (struct spi_mem_op *)op);
+
 	ret = spi_mem_check_op(op);
 	if (ret)
 		return ret;
@@ -410,6 +417,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 	xfers[xferpos].tx_buf = tmpbuf;
 	xfers[xferpos].len = op->cmd.nbytes;
 	xfers[xferpos].tx_nbits = op->cmd.buswidth;
+	xfers[xferpos].speed_hz = op->max_freq;
 	spi_message_add_tail(&xfers[xferpos], &msg);
 	xferpos++;
 	totalxferlen++;
@@ -424,6 +432,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 		xfers[xferpos].tx_buf = tmpbuf + 1;
 		xfers[xferpos].len = op->addr.nbytes;
 		xfers[xferpos].tx_nbits = op->addr.buswidth;
+		xfers[xferpos].speed_hz = op->max_freq;
 		spi_message_add_tail(&xfers[xferpos], &msg);
 		xferpos++;
 		totalxferlen += op->addr.nbytes;
@@ -435,6 +444,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 		xfers[xferpos].len = op->dummy.nbytes;
 		xfers[xferpos].tx_nbits = op->dummy.buswidth;
 		xfers[xferpos].dummy_data = 1;
+		xfers[xferpos].speed_hz = op->max_freq;
 		spi_message_add_tail(&xfers[xferpos], &msg);
 		xferpos++;
 		totalxferlen += op->dummy.nbytes;
@@ -450,6 +460,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 		}
 
 		xfers[xferpos].len = op->data.nbytes;
+		xfers[xferpos].speed_hz = op->max_freq;
 		spi_message_add_tail(&xfers[xferpos], &msg);
 		xferpos++;
 		totalxferlen += op->data.nbytes;
@@ -528,6 +539,23 @@ int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
 }
 EXPORT_SYMBOL_GPL(spi_mem_adjust_op_size);
 
+/**
+ * spi_mem_adjust_op_freq() - Adjust the frequency of a SPI mem operation to
+ *			      match controller, PCB and chip limitations
+ * @mem: the SPI memory
+ * @op: the operation to adjust
+ *
+ * Some chips have per-op frequency limitations and must adapt the maximum
+ * speed. This function allows SPI mem drivers to set @op->max_freq to the
+ * maximum supported value.
+ */
+void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op)
+{
+	if (!op->max_freq || op->max_freq > mem->spi->max_speed_hz)
+		op->max_freq = mem->spi->max_speed_hz;
+}
+EXPORT_SYMBOL_GPL(spi_mem_adjust_op_freq);
+
 static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc,
 				      u64 offs, size_t len, void *buf)
 {
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index c46d2b8029be5b3cee1cb6a5dc00e3d1a0e9ced2..84ec524987921a95963235de4b6f728ef2fc5987 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -68,6 +68,9 @@ enum spi_mem_data_dir {
 	SPI_MEM_DATA_OUT,
 };
 
+#define SPI_MEM_OP_MAX_FREQ(__freq)				\
+	.max_freq = __freq
+
 /**
  * struct spi_mem_op - describes a SPI memory operation
  * @cmd.nbytes: number of opcode bytes (only 1 or 2 are valid). The opcode is
@@ -97,6 +100,9 @@ enum spi_mem_data_dir {
  *		 operation does not involve transferring data
  * @data.buf.in: input buffer (must be DMA-able)
  * @data.buf.out: output buffer (must be DMA-able)
+ * @max_freq: frequency limitation wrt this operation. 0 means there is no
+ *	      specific constraint and the highest achievable frequency can be
+ *	      attempted.
  */
 struct spi_mem_op {
 	struct {
@@ -135,14 +141,17 @@ struct spi_mem_op {
 			const void *out;
 		} buf;
 	} data;
+
+	unsigned int max_freq;
 };
 
-#define SPI_MEM_OP(__cmd, __addr, __dummy, __data)		\
+#define SPI_MEM_OP(__cmd, __addr, __dummy, __data, ...)		\
 	{							\
 		.cmd = __cmd,					\
 		.addr = __addr,					\
 		.dummy = __dummy,				\
 		.data = __data,					\
+		__VA_ARGS__					\
 	}
 
 /**
@@ -371,6 +380,7 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
 #endif /* CONFIG_SPI_MEM */
 
 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);
+void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op);
 
 bool spi_mem_supports_op(struct spi_mem *mem,
 			 const struct spi_mem_op *op);

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 02/27] spi: spi-mem: Add a new controller capability
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 01/27] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 03/27] spi: amd: Support per spi-mem operation frequency switches Miquel Raynal
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, Tudor Ambarus

There are spi devices with multiple frequency limitations depending on
the invoked command. We probably do not want to afford running at the
lowest supported frequency all the time, so if we want to get the most
of our hardware, we need to allow per-operation frequency limitations.

Among all the SPI memory controllers, I believe all are capable of
changing the spi frequency on the fly. Some of the drivers do not make
any frequency setup though. And some others will derive a per chip
prescaler value which will be used forever.

Actually changing the frequency on the fly is something new in Linux, so
we need to carefully flag the drivers which do and do not support it. A
controller capability is created for that, and the presence for this
capability will always be checked before accepting such pattern.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
 drivers/spi/spi-mem.c       | 6 ++++++
 include/linux/spi/spi-mem.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 12299ce89a1cc80495858dbbbaa822f2968bb7ab..96374afd0193ca2cf4f50004f66c36dce32894e8 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -191,6 +191,12 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
 	    op->max_freq < mem->spi->controller->min_speed_hz)
 		return false;
 
+	if (op->max_freq &&
+	    op->max_freq < mem->spi->max_speed_hz) {
+		if (!spi_mem_controller_is_capable(ctlr, per_op_freq))
+			return false;
+	}
+
 	return spi_mem_check_buswidth(mem, op);
 }
 EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 84ec524987921a95963235de4b6f728ef2fc5987..c7a7719c264846ad9fce613ba96d9284ad7893e7 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -311,11 +311,13 @@ struct spi_controller_mem_ops {
  * @ecc: Supports operations with error correction
  * @swap16: Supports swapping bytes on a 16 bit boundary when configured in
  *	    Octal DTR
+ * @per_op_freq: Supports per operation frequency switching
  */
 struct spi_controller_mem_caps {
 	bool dtr;
 	bool ecc;
 	bool swap16;
+	bool per_op_freq;
 };
 
 #define spi_mem_controller_is_capable(ctlr, cap)	\

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 03/27] spi: amd: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 01/27] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 02/27] spi: spi-mem: Add a new controller capability Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 04/27] spi: amd: Drop redundant check Miquel Raynal
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

This controller however performed a frequency check, which is also
observed during the ->check_op() phase.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-amd.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c
index d30a21b0b05f96fe5361d16a1fca3467260e0a08..485ae1e382e3eb8f4d72ebb0fb15c51b9a118d3b 100644
--- a/drivers/spi/spi-amd.c
+++ b/drivers/spi/spi-amd.c
@@ -479,6 +479,9 @@ static bool amd_spi_supports_op(struct spi_mem *mem,
 		return false;
 	}
 
+	if (op->max_freq < mem->spi->controller->min_speed_hz)
+		return false;
+
 	return spi_mem_default_supports_op(mem, op);
 }
 
@@ -676,7 +679,7 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,
 
 	amd_spi = spi_controller_get_devdata(mem->spi->controller);
 
-	ret = amd_set_spi_freq(amd_spi, mem->spi->max_speed_hz);
+	ret = amd_set_spi_freq(amd_spi, op->max_freq);
 	if (ret)
 		return ret;
 
@@ -705,6 +708,10 @@ static const struct spi_controller_mem_ops amd_spi_mem_ops = {
 	.supports_op = amd_spi_supports_op,
 };
 
+static const struct spi_controller_mem_caps amd_spi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int amd_spi_host_transfer(struct spi_controller *host,
 				   struct spi_message *msg)
 {
@@ -782,6 +789,7 @@ static int amd_spi_probe(struct platform_device *pdev)
 	host->setup = amd_spi_host_setup;
 	host->transfer_one_message = amd_spi_host_transfer;
 	host->mem_ops = &amd_spi_mem_ops;
+	host->mem_caps = &amd_spi_mem_caps;
 	host->max_transfer_size = amd_spi_max_transfer_size;
 	host->max_message_size = amd_spi_max_transfer_size;
 

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 04/27] spi: amd: Drop redundant check
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (2 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 03/27] spi: amd: Support per spi-mem operation frequency switches Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 05/27] spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches Miquel Raynal
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Both spi and spi-mem cores already take care of checking the minimum and
maximum speed for transfers depending on the controller
capabilities. There is no reason to repeat this check in controller
drivers.

Once this possible error condition removed from the function, it makes
no longer sense to return an int.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-amd.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c
index 485ae1e382e3eb8f4d72ebb0fb15c51b9a118d3b..fbe795bbcf507abcbbd973b226b5db0de1584898 100644
--- a/drivers/spi/spi-amd.c
+++ b/drivers/spi/spi-amd.c
@@ -298,19 +298,16 @@ static const struct amd_spi_freq amd_spi_freq[] = {
 	{ AMD_SPI_MIN_HZ,   F_800KHz,         0},
 };
 
-static int amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
+static void amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
 {
 	unsigned int i, spd7_val, alt_spd;
 
-	if (speed_hz < AMD_SPI_MIN_HZ)
-		return -EINVAL;
-
 	for (i = 0; i < ARRAY_SIZE(amd_spi_freq); i++)
 		if (speed_hz >= amd_spi_freq[i].speed_hz)
 			break;
 
 	if (amd_spi->speed_hz == amd_spi_freq[i].speed_hz)
-		return 0;
+		return;
 
 	amd_spi->speed_hz = amd_spi_freq[i].speed_hz;
 
@@ -329,8 +326,6 @@ static int amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
 		amd_spi_setclear_reg32(amd_spi, AMD_SPI_SPEED_REG, spd7_val,
 				       AMD_SPI_SPD7_MASK);
 	}
-
-	return 0;
 }
 
 static inline int amd_spi_fifo_xfer(struct amd_spi *amd_spi,
@@ -679,9 +674,7 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,
 
 	amd_spi = spi_controller_get_devdata(mem->spi->controller);
 
-	ret = amd_set_spi_freq(amd_spi, op->max_freq);
-	if (ret)
-		return ret;
+	amd_set_spi_freq(amd_spi, op->max_freq);
 
 	if (amd_spi->version == AMD_SPI_V2)
 		amd_set_spi_addr_mode(amd_spi, op);

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 05/27] spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (3 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 04/27] spi: amd: Drop redundant check Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 06/27] spi: cadence-qspi: " Miquel Raynal
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-amlogic-spifc-a1.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-amlogic-spifc-a1.c b/drivers/spi/spi-amlogic-spifc-a1.c
index fadf6667cd51c40a29749b378b82161a337edc62..18c9aa2cbc290d8ac179438ab42c27e1a722d422 100644
--- a/drivers/spi/spi-amlogic-spifc-a1.c
+++ b/drivers/spi/spi-amlogic-spifc-a1.c
@@ -259,7 +259,7 @@ static int amlogic_spifc_a1_exec_op(struct spi_mem *mem,
 	size_t data_size = op->data.nbytes;
 	int ret;
 
-	ret = amlogic_spifc_a1_set_freq(spifc, mem->spi->max_speed_hz);
+	ret = amlogic_spifc_a1_set_freq(spifc, op->max_freq);
 	if (ret)
 		return ret;
 
@@ -320,6 +320,10 @@ static const struct spi_controller_mem_ops amlogic_spifc_a1_mem_ops = {
 	.adjust_op_size = amlogic_spifc_a1_adjust_op_size,
 };
 
+static const struct spi_controller_mem_caps amlogic_spifc_a1_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int amlogic_spifc_a1_probe(struct platform_device *pdev)
 {
 	struct spi_controller *ctrl;
@@ -356,6 +360,7 @@ static int amlogic_spifc_a1_probe(struct platform_device *pdev)
 	ctrl->bits_per_word_mask = SPI_BPW_MASK(8);
 	ctrl->auto_runtime_pm = true;
 	ctrl->mem_ops = &amlogic_spifc_a1_mem_ops;
+	ctrl->mem_caps = &amlogic_spifc_a1_mem_caps;
 	ctrl->min_speed_hz = SPIFC_A1_MIN_HZ;
 	ctrl->max_speed_hz = SPIFC_A1_MAX_HZ;
 	ctrl->mode_bits = (SPI_RX_DUAL | SPI_TX_DUAL |

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 06/27] spi: cadence-qspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (4 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 05/27] spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 07/27] spi: dw: " Miquel Raynal
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, Tudor Ambarus

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-cadence-quadspi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 0b45b7b2b3ab30951d94ea2ce57dcba3a2600847..e4862163252ed35053f743c74f1175e033940b17 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1407,7 +1407,7 @@ static int cqspi_mem_process(struct spi_mem *mem, const struct spi_mem_op *op)
 	struct cqspi_flash_pdata *f_pdata;
 
 	f_pdata = &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)];
-	cqspi_configure(f_pdata, mem->spi->max_speed_hz);
+	cqspi_configure(f_pdata, op->max_freq);
 
 	if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) {
 	/*
@@ -1655,6 +1655,7 @@ static const struct spi_controller_mem_ops cqspi_mem_ops = {
 
 static const struct spi_controller_mem_caps cqspi_mem_caps = {
 	.dtr = true,
+	.per_op_freq = true,
 };
 
 static int cqspi_setup_flash(struct cqspi_st *cqspi)

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 07/27] spi: dw: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (5 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 06/27] spi: cadence-qspi: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 08/27] spi: fsl-qspi: " Miquel Raynal
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-dw-core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index 431788dd848cea1d854affe0d1fb971f680824a1..3d49b1dbaed4d491c0df659c061582e71f2c514d 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -677,7 +677,7 @@ static int dw_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
 	 * operation. Transmit-only mode is suitable for the rest of them.
 	 */
 	cfg.dfs = 8;
-	cfg.freq = clamp(mem->spi->max_speed_hz, 0U, dws->max_mem_freq);
+	cfg.freq = clamp(op->max_freq, 0U, dws->max_mem_freq);
 	if (op->data.dir == SPI_MEM_DATA_IN) {
 		cfg.tmode = DW_SPI_CTRLR0_TMOD_EPROMREAD;
 		cfg.ndf = op->data.nbytes;
@@ -894,6 +894,10 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws)
 		dw_writel(dws, DW_SPI_CS_OVERRIDE, 0xF);
 }
 
+static const struct spi_controller_mem_caps dw_spi_mem_caps = {
+	.per_op_freq = true,
+};
+
 int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 {
 	struct spi_controller *host;
@@ -941,8 +945,10 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 		host->set_cs = dw_spi_set_cs;
 	host->transfer_one = dw_spi_transfer_one;
 	host->handle_err = dw_spi_handle_err;
-	if (dws->mem_ops.exec_op)
+	if (dws->mem_ops.exec_op) {
 		host->mem_ops = &dws->mem_ops;
+		host->mem_caps = &dw_spi_mem_caps;
+	}
 	host->max_speed_hz = dws->max_freq;
 	host->flags = SPI_CONTROLLER_GPIO_SS;
 	host->auto_runtime_pm = true;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 08/27] spi: fsl-qspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (6 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 07/27] spi: dw: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 09/27] spi: microchip-core-qspi: " Miquel Raynal
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Han Xu <han.xu@nxp.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-fsl-qspi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 9ec53bf0dda8ead27bc7a11a9bb09a08efe2ea05..355e6a39fb41896f460e2474a90b8f0b42068ff3 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -522,9 +522,10 @@ static void fsl_qspi_invalidate(struct fsl_qspi *q)
 	qspi_writel(q, reg, q->iobase + QUADSPI_MCR);
 }
 
-static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_device *spi)
+static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_device *spi,
+				const struct spi_mem_op *op)
 {
-	unsigned long rate = spi->max_speed_hz;
+	unsigned long rate = op->max_freq;
 	int ret;
 
 	if (q->selected == spi_get_chipselect(spi, 0))
@@ -652,7 +653,7 @@ static int fsl_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 	fsl_qspi_readl_poll_tout(q, base + QUADSPI_SR, (QUADSPI_SR_IP_ACC_MASK |
 				 QUADSPI_SR_AHB_ACC_MASK), 10, 1000);
 
-	fsl_qspi_select_mem(q, mem->spi);
+	fsl_qspi_select_mem(q, mem->spi, op);
 
 	if (needs_amba_base_offset(q))
 		addr_offset = q->memmap_phy;
@@ -839,6 +840,10 @@ static const struct spi_controller_mem_ops fsl_qspi_mem_ops = {
 	.get_name = fsl_qspi_get_name,
 };
 
+static const struct spi_controller_mem_caps fsl_qspi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int fsl_qspi_probe(struct platform_device *pdev)
 {
 	struct spi_controller *ctlr;
@@ -923,6 +928,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 	ctlr->bus_num = -1;
 	ctlr->num_chipselect = 4;
 	ctlr->mem_ops = &fsl_qspi_mem_ops;
+	ctlr->mem_caps = &fsl_qspi_mem_caps;
 
 	fsl_qspi_default_setup(q);
 

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 09/27] spi: microchip-core-qspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (7 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 08/27] spi: fsl-qspi: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 10/27] spi: mt65xx: " Miquel Raynal
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

This controller however performed a frequency check, which is also
observed during the ->check_op() phase.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Conor Dooley <conor.dooley@microchip.com>
Cc: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-microchip-core-qspi.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-microchip-core-qspi.c b/drivers/spi/spi-microchip-core-qspi.c
index ad2b5ffa6153433490f09bdd4c362273a0218432..fa828fcaaef2d4b44c21e08c09e6afbb7ba3de3d 100644
--- a/drivers/spi/spi-microchip-core-qspi.c
+++ b/drivers/spi/spi-microchip-core-qspi.c
@@ -265,7 +265,8 @@ static irqreturn_t mchp_coreqspi_isr(int irq, void *dev_id)
 	return ret;
 }
 
-static int mchp_coreqspi_setup_clock(struct mchp_coreqspi *qspi, struct spi_device *spi)
+static int mchp_coreqspi_setup_clock(struct mchp_coreqspi *qspi, struct spi_device *spi,
+				     const struct spi_mem_op *op)
 {
 	unsigned long clk_hz;
 	u32 control, baud_rate_val = 0;
@@ -274,11 +275,11 @@ static int mchp_coreqspi_setup_clock(struct mchp_coreqspi *qspi, struct spi_devi
 	if (!clk_hz)
 		return -EINVAL;
 
-	baud_rate_val = DIV_ROUND_UP(clk_hz, 2 * spi->max_speed_hz);
+	baud_rate_val = DIV_ROUND_UP(clk_hz, 2 * op->max_freq);
 	if (baud_rate_val > MAX_DIVIDER || baud_rate_val < MIN_DIVIDER) {
 		dev_err(&spi->dev,
 			"could not configure the clock for spi clock %d Hz & system clock %ld Hz\n",
-			spi->max_speed_hz, clk_hz);
+			op->max_freq, clk_hz);
 		return -EINVAL;
 	}
 
@@ -399,7 +400,7 @@ static int mchp_coreqspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *o
 	if (err)
 		goto error;
 
-	err = mchp_coreqspi_setup_clock(qspi, mem->spi);
+	err = mchp_coreqspi_setup_clock(qspi, mem->spi, op);
 	if (err)
 		goto error;
 
@@ -457,6 +458,10 @@ static int mchp_coreqspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *o
 
 static bool mchp_coreqspi_supports_op(struct spi_mem *mem, const struct spi_mem_op *op)
 {
+	struct mchp_coreqspi *qspi = spi_controller_get_devdata(mem->spi->controller);
+	unsigned long clk_hz;
+	u32 baud_rate_val;
+
 	if (!spi_mem_default_supports_op(mem, op))
 		return false;
 
@@ -479,6 +484,14 @@ static bool mchp_coreqspi_supports_op(struct spi_mem *mem, const struct spi_mem_
 			return false;
 	}
 
+	clk_hz = clk_get_rate(qspi->clk);
+	if (!clk_hz)
+		return false;
+
+	baud_rate_val = DIV_ROUND_UP(clk_hz, 2 * op->max_freq);
+	if (baud_rate_val > MAX_DIVIDER || baud_rate_val < MIN_DIVIDER)
+		return false;
+
 	return true;
 }
 
@@ -498,6 +511,10 @@ static const struct spi_controller_mem_ops mchp_coreqspi_mem_ops = {
 	.exec_op = mchp_coreqspi_exec_op,
 };
 
+static const struct spi_controller_mem_caps mchp_coreqspi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int mchp_coreqspi_probe(struct platform_device *pdev)
 {
 	struct spi_controller *ctlr;
@@ -540,6 +557,7 @@ static int mchp_coreqspi_probe(struct platform_device *pdev)
 
 	ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
 	ctlr->mem_ops = &mchp_coreqspi_mem_ops;
+	ctlr->mem_caps = &mchp_coreqspi_mem_caps;
 	ctlr->setup = mchp_coreqspi_setup_op;
 	ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD |
 			  SPI_TX_DUAL | SPI_TX_QUAD;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 10/27] spi: mt65xx: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (8 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 09/27] spi: microchip-core-qspi: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 11/27] spi: mxic: " Miquel Raynal
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-mt65xx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 85f3bafc975dbc3fd95f77b8dcfc0ca9aac32f5d..197bf2dbe5de7e853ccddf2c90d8bff40202f025 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -961,7 +961,7 @@ static int mtk_spi_mem_exec_op(struct spi_mem *mem,
 
 	mtk_spi_reset(mdata);
 	mtk_spi_hw_init(mem->spi->controller, mem->spi);
-	mtk_spi_prepare_transfer(mem->spi->controller, mem->spi->max_speed_hz);
+	mtk_spi_prepare_transfer(mem->spi->controller, op->max_freq);
 
 	reg_val = readl(mdata->base + SPI_CFG3_IPM_REG);
 	/* opcode byte len */
@@ -1122,6 +1122,10 @@ static const struct spi_controller_mem_ops mtk_spi_mem_ops = {
 	.exec_op = mtk_spi_mem_exec_op,
 };
 
+static const struct spi_controller_mem_caps mtk_spi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int mtk_spi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -1160,6 +1164,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
 	if (mdata->dev_comp->ipm_design) {
 		mdata->dev = dev;
 		host->mem_ops = &mtk_spi_mem_ops;
+		host->mem_caps = &mtk_spi_mem_caps;
 		init_completion(&mdata->spimem_done);
 	}
 

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 11/27] spi: mxic: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (9 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 10/27] spi: mt65xx: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 12/27] spi: nxp-fspi: " Miquel Raynal
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-mxic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
index 809767d3145c17291525ab7c246085597e0ff5e6..eeaea6a5e3103952e71a474e0de84099bc476a79 100644
--- a/drivers/spi/spi-mxic.c
+++ b/drivers/spi/spi-mxic.c
@@ -522,7 +522,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem *mem,
 	int i, ret;
 	u8 addr[8], cmd[2];
 
-	ret = mxic_spi_set_freq(mxic, mem->spi->max_speed_hz);
+	ret = mxic_spi_set_freq(mxic, op->max_freq);
 	if (ret)
 		return ret;
 
@@ -582,6 +582,7 @@ static const struct spi_controller_mem_caps mxic_spi_mem_caps = {
 	.dtr = true,
 	.ecc = true,
 	.swap16 = true,
+	.per_op_freq = true,
 };
 
 static void mxic_spi_set_cs(struct spi_device *spi, bool lvl)

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 12/27] spi: nxp-fspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (10 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 11/27] spi: mxic: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 13/27] spi: rockchip-sfc: " Miquel Raynal
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-nxp-fspi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 1161b9e5a4dce633718e22022410b5e7435bb51c..bad6b30bab0ecb90d0aaf603b6de5bc834d19de6 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -705,9 +705,10 @@ static void nxp_fspi_dll_calibration(struct nxp_fspi *f)
  * Value for rest of the CS FLSHxxCR0 register would be zero.
  *
  */
-static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
+static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
+				const struct spi_mem_op *op)
 {
-	unsigned long rate = spi->max_speed_hz;
+	unsigned long rate = op->max_freq;
 	int ret;
 	uint64_t size_kb;
 
@@ -931,7 +932,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 				   FSPI_STS0_ARB_IDLE, 1, POLL_TOUT, true);
 	WARN_ON(err);
 
-	nxp_fspi_select_mem(f, mem->spi);
+	nxp_fspi_select_mem(f, mem->spi, op);
 
 	nxp_fspi_prepare_lut(f, op);
 	/*
@@ -1149,6 +1150,10 @@ static const struct spi_controller_mem_ops nxp_fspi_mem_ops = {
 	.get_name = nxp_fspi_get_name,
 };
 
+static const struct spi_controller_mem_caps nxp_fspi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int nxp_fspi_probe(struct platform_device *pdev)
 {
 	struct spi_controller *ctlr;
@@ -1246,6 +1251,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
 	ctlr->bus_num = -1;
 	ctlr->num_chipselect = NXP_FSPI_MAX_CHIPSELECT;
 	ctlr->mem_ops = &nxp_fspi_mem_ops;
+	ctlr->mem_caps = &nxp_fspi_mem_caps;
 
 	nxp_fspi_default_setup(f);
 

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 13/27] spi: rockchip-sfc: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (11 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 12/27] spi: nxp-fspi: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:05 ` [PATCH v2 14/27] spi: spi-sn-f-ospi: " Miquel Raynal
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Han Xu <han.xu@nxp.com>
Cc: Haibo Chen <haibo.chen@nxp.com>
Cc: Yogesh Gaur <yogeshgaur.83@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-rockchip-sfc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c
index 69d0f21755684a8a01724c29eb97123044dcf6ae..a8163fbc18923f8a96114785e46623476cf97d04 100644
--- a/drivers/spi/spi-rockchip-sfc.c
+++ b/drivers/spi/spi-rockchip-sfc.c
@@ -491,11 +491,11 @@ static int rockchip_sfc_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op
 	u32 len = op->data.nbytes;
 	int ret;
 
-	if (unlikely(mem->spi->max_speed_hz != sfc->frequency)) {
-		ret = clk_set_rate(sfc->clk, mem->spi->max_speed_hz);
+	if (unlikely(op->max_freq != sfc->frequency)) {
+		ret = clk_set_rate(sfc->clk, op->max_freq);
 		if (ret)
 			return ret;
-		sfc->frequency = mem->spi->max_speed_hz;
+		sfc->frequency = op->max_freq;
 		dev_dbg(sfc->dev, "set_freq=%dHz real_freq=%ldHz\n",
 			sfc->frequency, clk_get_rate(sfc->clk));
 	}
@@ -535,6 +535,10 @@ static const struct spi_controller_mem_ops rockchip_sfc_mem_ops = {
 	.adjust_op_size = rockchip_sfc_adjust_op_size,
 };
 
+static const struct spi_controller_mem_caps rockchip_sfc_mem_caps = {
+	.per_op_freq = true,
+};
+
 static irqreturn_t rockchip_sfc_irq_handler(int irq, void *dev_id)
 {
 	struct rockchip_sfc *sfc = dev_id;
@@ -567,6 +571,7 @@ static int rockchip_sfc_probe(struct platform_device *pdev)
 
 	host->flags = SPI_CONTROLLER_HALF_DUPLEX;
 	host->mem_ops = &rockchip_sfc_mem_ops;
+	host->mem_caps = &rockchip_sfc_mem_caps;
 	host->dev.of_node = pdev->dev.of_node;
 	host->mode_bits = SPI_TX_QUAD | SPI_TX_DUAL | SPI_RX_QUAD | SPI_RX_DUAL;
 	host->max_speed_hz = SFC_MAX_SPEED;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 14/27] spi: spi-sn-f-ospi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (12 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 13/27] spi: rockchip-sfc: " Miquel Raynal
@ 2024-12-24 17:05 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 15/27] spi: spi-ti-qspi: " Miquel Raynal
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:05 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-sn-f-ospi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c
index adac645732fedfe6e33a5a0979ba43d5d203bfce..6ad4b729897e3909a5e22b33aa47b812219a6ee5 100644
--- a/drivers/spi/spi-sn-f-ospi.c
+++ b/drivers/spi/spi-sn-f-ospi.c
@@ -335,7 +335,6 @@ static void f_ospi_config_indir_protocol(struct f_ospi *ospi,
 static int f_ospi_indir_prepare_op(struct f_ospi *ospi, struct spi_mem *mem,
 				   const struct spi_mem_op *op)
 {
-	struct spi_device *spi = mem->spi;
 	u32 irq_stat_en;
 	int ret;
 
@@ -343,7 +342,7 @@ static int f_ospi_indir_prepare_op(struct f_ospi *ospi, struct spi_mem *mem,
 	if (ret)
 		return ret;
 
-	f_ospi_config_clk(ospi, spi->max_speed_hz);
+	f_ospi_config_clk(ospi, op->max_freq);
 
 	f_ospi_config_indir_protocol(ospi, mem, op);
 
@@ -577,6 +576,10 @@ static const struct spi_controller_mem_ops f_ospi_mem_ops = {
 	.exec_op = f_ospi_exec_op,
 };
 
+static const struct spi_controller_mem_caps f_ospi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int f_ospi_init(struct f_ospi *ospi)
 {
 	int ret;
@@ -614,6 +617,7 @@ static int f_ospi_probe(struct platform_device *pdev)
 		| SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL
 		| SPI_MODE_0 | SPI_MODE_1 | SPI_LSB_FIRST;
 	ctlr->mem_ops = &f_ospi_mem_ops;
+	ctlr->mem_caps = &f_ospi_mem_caps;
 	ctlr->bus_num = -1;
 	of_property_read_u32(dev->of_node, "num-cs", &num_cs);
 	if (num_cs > OSPI_NUM_CS) {

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 15/27] spi: spi-ti-qspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (13 preceding siblings ...)
  2024-12-24 17:05 ` [PATCH v2 14/27] spi: spi-sn-f-ospi: " Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 16/27] spi: zynq-qspi: " Miquel Raynal
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-ti-qspi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index 9122350402b5062dfc8bcf70ac47ba51fad64b3e..49516fee74b0f2062c43d714fcb97c7a55580b37 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -623,7 +623,7 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem,
 	mutex_lock(&qspi->list_lock);
 
 	if (!qspi->mmap_enabled || qspi->current_cs != spi_get_chipselect(mem->spi, 0)) {
-		ti_qspi_setup_clk(qspi, mem->spi->max_speed_hz);
+		ti_qspi_setup_clk(qspi, op->max_freq);
 		ti_qspi_enable_memory_map(mem->spi);
 	}
 	ti_qspi_setup_mmap_read(mem->spi, op->cmd.opcode, op->data.buswidth,
@@ -658,6 +658,10 @@ static const struct spi_controller_mem_ops ti_qspi_mem_ops = {
 	.adjust_op_size = ti_qspi_adjust_op_size,
 };
 
+static const struct spi_controller_mem_caps ti_qspi_mem_caps = {
+	.per_op_freq = true,
+};
+
 static int ti_qspi_start_transfer_one(struct spi_controller *host,
 		struct spi_message *m)
 {
@@ -777,6 +781,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
 	host->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) |
 				   SPI_BPW_MASK(8);
 	host->mem_ops = &ti_qspi_mem_ops;
+	host->mem_caps = &ti_qspi_mem_caps;
 
 	if (!of_property_read_u32(np, "num-cs", &num_cs))
 		host->num_chipselect = num_cs;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 16/27] spi: zynq-qspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (14 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 15/27] spi: spi-ti-qspi: " Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 17/27] spi: zynqmp-gqspi: " Miquel Raynal
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-zynq-qspi.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c
index dee9c339a35e74c86fe1c768990a3f870b0a1b9d..f3cacb01e25b97892f9fbefc6e5cf43b9722ae4d 100644
--- a/drivers/spi/spi-zynq-qspi.c
+++ b/drivers/spi/spi-zynq-qspi.c
@@ -318,6 +318,7 @@ static void zynq_qspi_chipselect(struct spi_device *spi, bool assert)
  * zynq_qspi_config_op - Configure QSPI controller for specified transfer
  * @xqspi:	Pointer to the zynq_qspi structure
  * @spi:	Pointer to the spi_device structure
+ * @op:		The memory operation to execute
  *
  * Sets the operational mode of QSPI controller for the next QSPI transfer and
  * sets the requested clock frequency.
@@ -331,7 +332,8 @@ static void zynq_qspi_chipselect(struct spi_device *spi, bool assert)
  * controller the driver will set the highest or lowest frequency supported by
  * controller.
  */
-static int zynq_qspi_config_op(struct zynq_qspi *xqspi, struct spi_device *spi)
+static int zynq_qspi_config_op(struct zynq_qspi *xqspi, struct spi_device *spi,
+			       const struct spi_mem_op *op)
 {
 	u32 config_reg, baud_rate_val = 0;
 
@@ -346,7 +348,7 @@ static int zynq_qspi_config_op(struct zynq_qspi *xqspi, struct spi_device *spi)
 	 */
 	while ((baud_rate_val < ZYNQ_QSPI_CONFIG_BAUD_DIV_MAX)  &&
 	       (clk_get_rate(xqspi->refclk) / (2 << baud_rate_val)) >
-		spi->max_speed_hz)
+		op->max_freq)
 		baud_rate_val++;
 
 	config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_CONFIG_OFFSET);
@@ -534,7 +536,7 @@ static int zynq_qspi_exec_mem_op(struct spi_mem *mem,
 		op->dummy.buswidth, op->data.buswidth);
 
 	zynq_qspi_chipselect(mem->spi, true);
-	zynq_qspi_config_op(xqspi, mem->spi);
+	zynq_qspi_config_op(xqspi, mem->spi, op);
 
 	if (op->cmd.opcode) {
 		reinit_completion(&xqspi->data_completion);
@@ -620,6 +622,10 @@ static const struct spi_controller_mem_ops zynq_qspi_mem_ops = {
 	.exec_op = zynq_qspi_exec_mem_op,
 };
 
+static const struct spi_controller_mem_caps zynq_qspi_mem_caps = {
+	.per_op_freq = true,
+};
+
 /**
  * zynq_qspi_probe - Probe method for the QSPI driver
  * @pdev:	Pointer to the platform_device structure
@@ -706,6 +712,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
 	ctlr->mode_bits =  SPI_RX_DUAL | SPI_RX_QUAD |
 			    SPI_TX_DUAL | SPI_TX_QUAD;
 	ctlr->mem_ops = &zynq_qspi_mem_ops;
+	ctlr->mem_caps = &zynq_qspi_mem_caps;
 	ctlr->setup = zynq_qspi_setup_op;
 	ctlr->max_speed_hz = clk_get_rate(xqspi->refclk) / 2;
 	ctlr->dev.of_node = np;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 17/27] spi: zynqmp-gqspi: Support per spi-mem operation frequency switches
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (15 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 16/27] spi: zynq-qspi: " Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 18/27] spi: spi-mem: Reorder spi-mem macro assignments Miquel Raynal
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: Michal Simek <michal.simek@amd.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-zynqmp-gqspi.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 549a6e0c96546211223dd45e8e70620fa5fd18ab..d800d79f62a70c74551e1ad6f628685ec6c18b0d 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -535,7 +535,7 @@ static inline u32 zynqmp_qspi_selectspimode(struct zynqmp_qspi *xqspi,
  * zynqmp_qspi_config_op - Configure QSPI controller for specified
  *				transfer
  * @xqspi:	Pointer to the zynqmp_qspi structure
- * @qspi:	Pointer to the spi_device structure
+ * @op:		The memory operation to execute
  *
  * Sets the operational mode of QSPI controller for the next QSPI transfer and
  * sets the requested clock frequency.
@@ -553,12 +553,12 @@ static inline u32 zynqmp_qspi_selectspimode(struct zynqmp_qspi *xqspi,
  *	frequency supported by controller.
  */
 static int zynqmp_qspi_config_op(struct zynqmp_qspi *xqspi,
-				 struct spi_device *qspi)
+				 const struct spi_mem_op *op)
 {
 	ulong clk_rate;
 	u32 config_reg, req_speed_hz, baud_rate_val = 0;
 
-	req_speed_hz = qspi->max_speed_hz;
+	req_speed_hz = op->max_freq;
 
 	if (xqspi->speed_hz != req_speed_hz) {
 		xqspi->speed_hz = req_speed_hz;
@@ -1072,7 +1072,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem,
 		op->dummy.buswidth, op->data.buswidth);
 
 	mutex_lock(&xqspi->op_lock);
-	zynqmp_qspi_config_op(xqspi, mem->spi);
+	zynqmp_qspi_config_op(xqspi, op);
 	zynqmp_qspi_chipselect(mem->spi, false);
 	genfifoentry |= xqspi->genfifocs;
 	genfifoentry |= xqspi->genfifobus;
@@ -1224,6 +1224,10 @@ static const struct spi_controller_mem_ops zynqmp_qspi_mem_ops = {
 	.exec_op = zynqmp_qspi_exec_op,
 };
 
+static const struct spi_controller_mem_caps zynqmp_qspi_mem_caps = {
+	.per_op_freq = true,
+};
+
 /**
  * zynqmp_qspi_probe - Probe method for the QSPI driver
  * @pdev:	Pointer to the platform_device structure
@@ -1333,6 +1337,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
 
 	ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
 	ctlr->mem_ops = &zynqmp_qspi_mem_ops;
+	ctlr->mem_caps = &zynqmp_qspi_mem_caps;
 	ctlr->setup = zynqmp_qspi_setup_op;
 	ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
 	ctlr->dev.of_node = np;

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 18/27] spi: spi-mem: Reorder spi-mem macro assignments
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (16 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 17/27] spi: zynqmp-gqspi: " Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 19/27] spi: spi-mem: Create macros for DTR operation Miquel Raynal
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Follow the order in which all the `struct spi_mem_op` members are
defined.

This is purely aesthetics, there is no functional change.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 include/linux/spi/spi-mem.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index c7a7719c264846ad9fce613ba96d9284ad7893e7..ca6ea01c40f85095ac2730cb424cfb21d7daa700 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -15,16 +15,16 @@
 
 #define SPI_MEM_OP_CMD(__opcode, __buswidth)			\
 	{							\
+		.nbytes = 1,					\
 		.buswidth = __buswidth,				\
 		.opcode = __opcode,				\
-		.nbytes = 1,					\
 	}
 
 #define SPI_MEM_OP_ADDR(__nbytes, __val, __buswidth)		\
 	{							\
 		.nbytes = __nbytes,				\
-		.val = __val,					\
 		.buswidth = __buswidth,				\
+		.val = __val,					\
 	}
 
 #define SPI_MEM_OP_NO_ADDR	{ }
@@ -39,18 +39,18 @@
 
 #define SPI_MEM_OP_DATA_IN(__nbytes, __buf, __buswidth)		\
 	{							\
+		.buswidth = __buswidth,				\
 		.dir = SPI_MEM_DATA_IN,				\
 		.nbytes = __nbytes,				\
 		.buf.in = __buf,				\
-		.buswidth = __buswidth,				\
 	}
 
 #define SPI_MEM_OP_DATA_OUT(__nbytes, __buf, __buswidth)	\
 	{							\
+		.buswidth = __buswidth,				\
 		.dir = SPI_MEM_DATA_OUT,			\
 		.nbytes = __nbytes,				\
 		.buf.out = __buf,				\
-		.buswidth = __buswidth,				\
 	}
 
 #define SPI_MEM_OP_NO_DATA	{ }

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 19/27] spi: spi-mem: Create macros for DTR operation
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (17 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 18/27] spi: spi-mem: Reorder spi-mem macro assignments Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations Miquel Raynal
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

We do have macros for defining command, address, dummy and data
cycles. We also have a .dtr flag that implies sampling the bus on both
edges, but there are currently no macros enabling it. We might make use
of such macros, so let's create:
- SPI_MEM_DTR_OP_CMD
- SPI_MEM_DTR_OP_ADDR
- SPI_MEM_DTR_OP_DUMMY
- SPI_MEM_DTR_OP_DATA_OUT
- SPI_MEM_DTR_OP_DATA_OUT

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 include/linux/spi/spi-mem.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index ca6ea01c40f85095ac2730cb424cfb21d7daa700..306c05dd13789017da2c5339cddc031f03302bb9 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -20,6 +20,14 @@
 		.opcode = __opcode,				\
 	}
 
+#define SPI_MEM_DTR_OP_CMD(__opcode, __buswidth)		\
+	{							\
+		.nbytes = 1,					\
+		.opcode = __opcode,				\
+		.buswidth = __buswidth,				\
+		.dtr = true,					\
+	}
+
 #define SPI_MEM_OP_ADDR(__nbytes, __val, __buswidth)		\
 	{							\
 		.nbytes = __nbytes,				\
@@ -27,6 +35,14 @@
 		.val = __val,					\
 	}
 
+#define SPI_MEM_DTR_OP_ADDR(__nbytes, __val, __buswidth)	\
+	{							\
+		.nbytes = __nbytes,				\
+		.val = __val,					\
+		.buswidth = __buswidth,				\
+		.dtr = true,					\
+	}
+
 #define SPI_MEM_OP_NO_ADDR	{ }
 
 #define SPI_MEM_OP_DUMMY(__nbytes, __buswidth)			\
@@ -35,6 +51,13 @@
 		.buswidth = __buswidth,				\
 	}
 
+#define SPI_MEM_DTR_OP_DUMMY(__nbytes, __buswidth)		\
+	{							\
+		.nbytes = __nbytes,				\
+		.buswidth = __buswidth,				\
+		.dtr = true,					\
+	}
+
 #define SPI_MEM_OP_NO_DUMMY	{ }
 
 #define SPI_MEM_OP_DATA_IN(__nbytes, __buf, __buswidth)		\
@@ -45,6 +68,15 @@
 		.buf.in = __buf,				\
 	}
 
+#define SPI_MEM_DTR_OP_DATA_IN(__nbytes, __buf, __buswidth)	\
+	{							\
+		.dir = SPI_MEM_DATA_IN,				\
+		.nbytes = __nbytes,				\
+		.buf.in = __buf,				\
+		.buswidth = __buswidth,				\
+		.dtr = true,					\
+	}
+
 #define SPI_MEM_OP_DATA_OUT(__nbytes, __buf, __buswidth)	\
 	{							\
 		.buswidth = __buswidth,				\
@@ -53,6 +85,15 @@
 		.buf.out = __buf,				\
 	}
 
+#define SPI_MEM_DTR_OP_DATA_OUT(__nbytes, __buf, __buswidth)	\
+	{							\
+		.dir = SPI_MEM_DATA_OUT,			\
+		.nbytes = __nbytes,				\
+		.buf.out = __buf,				\
+		.buswidth = __buswidth,				\
+		.dtr = true,					\
+	}
+
 #define SPI_MEM_OP_NO_DATA	{ }
 
 /**

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (18 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 19/27] spi: spi-mem: Create macros for DTR operation Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2025-01-10 12:42   ` Mark Brown
  2024-12-24 17:06 ` [PATCH v2 21/27] mtd: spinand: Create distinct fast and slow read from cache variants Miquel Raynal
                   ` (7 subsequent siblings)
  27 siblings, 1 reply; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

In the SPI-NAND layer, we currently make list of operation variants from
the fastest one to the slowest and there is a bit of logic in the core
to go over them and pick the first one that is supported by the
controller, ie. the fastest one among the supported ops.

This kind of logic only works if all operations run at the same
frequency, but as soon as we introduce per operation max frequencies it
is not longer as obvious which operation will be faster, especially
since it also depends on the PCB/controller frequency limitation.

One way to make this choice more clever is to go over all the
variants and for each of them derive an indicator which will help derive
the theoretical best. In this case, we derive a theoretical duration for
the entire operation and we take the smallest one.

Add a helper that parses the spi-mem operation and returns this value.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-mem.c       | 30 ++++++++++++++++++++++++++++++
 include/linux/spi/spi-mem.h |  1 +
 2 files changed, 31 insertions(+)

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 96374afd0193ca2cf4f50004f66c36dce32894e8..a9f0f47f4759b0e1ce22348e713a3b42cfb8ea9c 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -562,6 +562,36 @@ void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op)
 }
 EXPORT_SYMBOL_GPL(spi_mem_adjust_op_freq);
 
+/**
+ * spi_mem_calc_op_duration() - Derives the theoretical length (in ns) of an
+ *			        operation. This helps finding the best variant
+ *			        among a list of possible choices.
+ * @op: the operation to benchmark
+ *
+ * Some chips have per-op frequency limitations, PCBs usually have their own
+ * limitations as well, and controllers can support dual, quad or even octal
+ * modes, sometimes in DTR. All these combinations make it impossible to
+ * statically list the best combination for all situations. If we want something
+ * accurate, all these combinations should be rated (eg. with a time estimate)
+ * and the best pick should be taken based on these calculations.
+ *
+ * Returns a ns estimate for the time this op would take.
+ */
+u64 spi_mem_calc_op_duration(struct spi_mem_op *op)
+{
+	u64 ncycles = 0;
+	u32 ns_per_cycles;
+
+	ns_per_cycles = 1000000000 / op->max_freq;
+	ncycles += ((op->cmd.nbytes * 8) / op->cmd.buswidth) / (op->cmd.dtr ? 2 : 1);
+	ncycles += ((op->addr.nbytes * 8) / op->addr.buswidth) / (op->addr.dtr ? 2 : 1);
+	ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
+	ncycles += ((op->data.nbytes * 8) / op->data.buswidth) / (op->data.dtr ? 2 : 1);
+
+	return ncycles * ns_per_cycles;
+}
+EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration);
+
 static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc,
 				      u64 offs, size_t len, void *buf)
 {
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 306c05dd13789017da2c5339cddc031f03302bb9..82390712794c5a4dcef1319c19d74b77b6e1e724 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -424,6 +424,7 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
 
 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);
 void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op);
+u64 spi_mem_calc_op_duration(struct spi_mem *mem, struct spi_mem_op *op);
 
 bool spi_mem_supports_op(struct spi_mem *mem,
 			 const struct spi_mem_op *op);

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 21/27] mtd: spinand: Create distinct fast and slow read from cache variants
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (19 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 22/27] mtd: spinand: Add an optional frequency to read from cache macros Miquel Raynal
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, Tudor Ambarus

So far, the SPINAND_PAGE_READ_FROM_CACHE_OP macro was taking a first
argument, "fast", which was inducing the possibility to support higher
bus frequencies than with the normal (slower) read from cache
alternative. In practice, without frequency change on the bus, this was
likely without effect, besides perhaps allowing another variant of the
same command, that could run at the default highest speed. If we want to
support this fully, we need to add a frequency parameter to the slowest
command. But before we do that, let's drop the "fast" boolean from the
macro and duplicate it, this will further help supporting having
different frequencies allowed for each variant.

The change is also of course propagated to all users. It has the nice
effect to have all macros aligned on the same pattern.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/spi/alliancememory.c |  4 ++--
 drivers/mtd/nand/spi/ato.c            |  4 ++--
 drivers/mtd/nand/spi/esmt.c           |  4 ++--
 drivers/mtd/nand/spi/foresee.c        |  4 ++--
 drivers/mtd/nand/spi/gigadevice.c     | 16 ++++++++--------
 drivers/mtd/nand/spi/macronix.c       |  4 ++--
 drivers/mtd/nand/spi/micron.c         |  8 ++++----
 drivers/mtd/nand/spi/paragon.c        |  4 ++--
 drivers/mtd/nand/spi/toshiba.c        |  4 ++--
 drivers/mtd/nand/spi/winbond.c        |  4 ++--
 drivers/mtd/nand/spi/xtx.c            |  4 ++--
 include/linux/mtd/spinand.h           | 20 ++++++++++++++++----
 12 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/drivers/mtd/nand/spi/alliancememory.c b/drivers/mtd/nand/spi/alliancememory.c
index 7936ea546b038e3441fcd81bd92e358a0f22ed82..6046c73f8424e9fb338ec3a1d35dc6fe30a2e1bc 100644
--- a/drivers/mtd/nand/spi/alliancememory.c
+++ b/drivers/mtd/nand/spi/alliancememory.c
@@ -21,8 +21,8 @@ static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 			   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/ato.c b/drivers/mtd/nand/spi/ato.c
index 82b377c068124ec8c982bd526cd088ae20ebe7b0..bb5298911137f08c1793d244b33dddf1971e2fed 100644
--- a/drivers/mtd/nand/spi/ato.c
+++ b/drivers/mtd/nand/spi/ato.c
@@ -15,8 +15,8 @@
 
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/esmt.c b/drivers/mtd/nand/spi/esmt.c
index 4597a82de23a45919adf97f36ac0ea87d6ef6f53..323a20901fc9fcc252b8317d9434aabf5e30a495 100644
--- a/drivers/mtd/nand/spi/esmt.c
+++ b/drivers/mtd/nand/spi/esmt.c
@@ -15,8 +15,8 @@
 static SPINAND_OP_VARIANTS(read_cache_variants,
 			   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 			   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-			   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-			   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+			   SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+			   SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 			   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/foresee.c b/drivers/mtd/nand/spi/foresee.c
index e0d2d9257045a86c64b3a2d93a8d836b1322413e..cb5c9e0517eaa5b6e609f34fecac9a8c18451190 100644
--- a/drivers/mtd/nand/spi/foresee.c
+++ b/drivers/mtd/nand/spi/foresee.c
@@ -14,8 +14,8 @@
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/gigadevice.c b/drivers/mtd/nand/spi/gigadevice.c
index 6023cba748bb858373a54dd58c5808057d9841fc..d620bb02a20a0df04e8d0af187ee277d6ef430f2 100644
--- a/drivers/mtd/nand/spi/gigadevice.c
+++ b/drivers/mtd/nand/spi/gigadevice.c
@@ -28,32 +28,32 @@ static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(read_cache_variants_f,
 		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP_3A(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP_3A(false, 0, 0, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP_3A(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP_3A(0, 0, NULL, 0));
 
 static SPINAND_OP_VARIANTS(read_cache_variants_1gq5,
 		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(read_cache_variants_2gq5,
 		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index d277c3220fdcbcd6d9ff7ea2690492e0893f5e4a..3dc4d63d6832d0213387f335fd233f1c4306bfff 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -28,8 +28,8 @@ struct macronix_priv {
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
index 12601bc4227a729575eb9fb28adf9992d7961b3c..ad0bb9755a099dc668e4a0b0a56928f968fba824 100644
--- a/drivers/mtd/nand/spi/micron.c
+++ b/drivers/mtd/nand/spi/micron.c
@@ -33,8 +33,8 @@ static SPINAND_OP_VARIANTS(quadio_read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(x4_write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
@@ -48,8 +48,8 @@ static SPINAND_OP_VARIANTS(x4_update_cache_variants,
 static SPINAND_OP_VARIANTS(x4_read_cache_variants,
 			   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 			   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-			   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-			   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+			   SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+			   SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(x1_write_cache_variants,
 			   SPINAND_PROG_LOAD(true, 0, NULL, 0));
diff --git a/drivers/mtd/nand/spi/paragon.c b/drivers/mtd/nand/spi/paragon.c
index 519ade513c1f34cf7499c6bacff61b23412ece88..6e7cc6995380c00ae40fe362f711a490ff463130 100644
--- a/drivers/mtd/nand/spi/paragon.c
+++ b/drivers/mtd/nand/spi/paragon.c
@@ -26,8 +26,8 @@ static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
index bbbcaa87c0bc78576ff9ca0b88deb4fa81703276..2e2106b2705f0852aa5b13263d29d8916c1a6e7d 100644
--- a/drivers/mtd/nand/spi/toshiba.c
+++ b/drivers/mtd/nand/spi/toshiba.c
@@ -17,8 +17,8 @@
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_x4_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 7180e615ac975259d79f065dc8f0dadc998a2770..fb6fee71bcb6d00c5ae7a5578b57c8c3725c7391 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -22,8 +22,8 @@ static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/drivers/mtd/nand/spi/xtx.c b/drivers/mtd/nand/spi/xtx.c
index 66a4255bdf06617f76f502ddaa873c1334c24ea4..3f539ca0de861c082217701607f96c2a6b7c5378 100644
--- a/drivers/mtd/nand/spi/xtx.c
+++ b/drivers/mtd/nand/spi/xtx.c
@@ -27,8 +27,8 @@ static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0));
 
 static SPINAND_OP_VARIANTS(write_cache_variants,
 		SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 702e5fb13dae73de5e77ddc71964dd46ff756253..63c89307c86524143913660c66ec4fe4375904f8 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -62,14 +62,26 @@
 		   SPI_MEM_OP_NO_DUMMY,					\
 		   SPI_MEM_OP_NO_DATA)
 
-#define SPINAND_PAGE_READ_FROM_CACHE_OP(fast, addr, ndummy, buf, len)	\
-	SPI_MEM_OP(SPI_MEM_OP_CMD(fast ? 0x0b : 0x03, 1),		\
+#define SPINAND_PAGE_READ_FROM_CACHE_OP(addr, ndummy, buf, len) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x03, 1),				\
 		   SPI_MEM_OP_ADDR(2, addr, 1),				\
 		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 1))
 
-#define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(fast, addr, ndummy, buf, len) \
-	SPI_MEM_OP(SPI_MEM_OP_CMD(fast ? 0x0b : 0x03, 1),		\
+#define SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(addr, ndummy, buf, len) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x0b, 1),			\
+			 SPI_MEM_OP_ADDR(2, addr, 1),			\
+			 SPI_MEM_OP_DUMMY(ndummy, 1),			\
+			 SPI_MEM_OP_DATA_IN(len, buf, 1))
+
+#define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(addr, ndummy, buf, len) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x03, 1),				\
+		   SPI_MEM_OP_ADDR(3, addr, 1),				\
+		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
+		   SPI_MEM_OP_DATA_IN(len, buf, 1))
+
+#define SPINAND_PAGE_READ_FROM_CACHE_FAST_OP_3A(addr, ndummy, buf, len) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x0b, 1),				\
 		   SPI_MEM_OP_ADDR(3, addr, 1),				\
 		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 1))

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 22/27] mtd: spinand: Add an optional frequency to read from cache macros
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (20 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 21/27] mtd: spinand: Create distinct fast and slow read from cache variants Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 23/27] mtd: spinand: Enhance the logic when picking a variant Miquel Raynal
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

While the SPINAND_PAGE_READ_FROM_CACHE_FAST_OP macro is supposed to be
able to run at the flash highest supported frequency, it is not the case
of the regular read from cache, which may be limited in terms of maximum
frequency. Add an optional argument to this macro, which will be used to
set the maximum frequency, if any.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 include/linux/mtd/spinand.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 63c89307c86524143913660c66ec4fe4375904f8..1948e654b8aacb3d4b774a00939e8e8198f53da7 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -62,11 +62,12 @@
 		   SPI_MEM_OP_NO_DUMMY,					\
 		   SPI_MEM_OP_NO_DATA)
 
-#define SPINAND_PAGE_READ_FROM_CACHE_OP(addr, ndummy, buf, len) \
+#define SPINAND_PAGE_READ_FROM_CACHE_OP(addr, ndummy, buf, len, ...) \
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0x03, 1),				\
 		   SPI_MEM_OP_ADDR(2, addr, 1),				\
 		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
-		   SPI_MEM_OP_DATA_IN(len, buf, 1))
+		   SPI_MEM_OP_DATA_IN(len, buf, 1),			\
+		   __VA_OPT__(SPI_MEM_OP_MAX_FREQ(__VA_ARGS__)))
 
 #define SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(addr, ndummy, buf, len) \
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0x0b, 1),			\

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 23/27] mtd: spinand: Enhance the logic when picking a variant
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (21 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 22/27] mtd: spinand: Add an optional frequency to read from cache macros Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 24/27] mtd: spinand: Add support for read DTR operations Miquel Raynal
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Currently the best variant picked in the first one in the list provided
in the manufacturer driver. This worked well while all operations where
performed at the same speed, but with the introduction of DTR transfers
and per operation maximum frequencies, this no longer works correctly.

Let's continue iterating over all the alternatives, even if we find a
match, keeping a reference over the theoretically fastest
operation. Only at the end we can tell which variant is the best.

This logic happening only once at boot, the extra computing needed
compared to the previous version is acceptable wrt. the expected
improvements.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/spi/core.c | 13 ++++++++++---
 include/linux/spi/spi-mem.h |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 94f33c8be031ac60208e22e4e3fa0d90cfae093c..a2a8cfd1752139e3227fa4a39ab0e25bbeec53f8 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1198,10 +1198,13 @@ spinand_select_op_variant(struct spinand_device *spinand,
 			  const struct spinand_op_variants *variants)
 {
 	struct nand_device *nand = spinand_to_nand(spinand);
+	const struct spi_mem_op *best_variant = NULL;
+	u64 best_op_duration_ns = ULLONG_MAX;
 	unsigned int i;
 
 	for (i = 0; i < variants->nops; i++) {
 		struct spi_mem_op op = variants->ops[i];
+		u64 op_duration_ns = 0;
 		unsigned int nbytes;
 		int ret;
 
@@ -1220,13 +1223,17 @@ spinand_select_op_variant(struct spinand_device *spinand,
 				break;
 
 			nbytes -= op.data.nbytes;
+
+			op_duration_ns += spi_mem_calc_op_duration(&op);
 		}
 
-		if (!nbytes)
-			return &variants->ops[i];
+		if (!nbytes && op_duration_ns < best_op_duration_ns) {
+			best_op_duration_ns = op_duration_ns;
+			best_variant = &variants->ops[i];
+		}
 	}
 
-	return NULL;
+	return best_variant;
 }
 
 /**
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 82390712794c5a4dcef1319c19d74b77b6e1e724..c4830dfaff3db5549c45bb7a9c4bf5110fa2e338 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -424,7 +424,7 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
 
 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op);
 void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op);
-u64 spi_mem_calc_op_duration(struct spi_mem *mem, struct spi_mem_op *op);
+u64 spi_mem_calc_op_duration(struct spi_mem_op *op);
 
 bool spi_mem_supports_op(struct spi_mem *mem,
 			 const struct spi_mem_op *op);

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 24/27] mtd: spinand: Add support for read DTR operations
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (22 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 23/27] mtd: spinand: Enhance the logic when picking a variant Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 25/27] mtd: spinand: winbond: Update the *JW chip definitions Miquel Raynal
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Advanced SPI-NAND chips are capable of reading data much faster by
leveraging DTR support. This support extends to dual and quad
configurations.

Create macros defining all possible read from cache DTR variants:
- SPINAND_PAGE_READ_FROM_CACHE_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_X2_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_X4_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_DUALIO_DTR_OP
- SPINAND_PAGE_READ_FROM_CACHE_QUADIO_DTR_OP

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 include/linux/mtd/spinand.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 1948e654b8aacb3d4b774a00939e8e8198f53da7..eeabf4a17c578405550fcc1ed1653f9ef09b5ff6 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -87,6 +87,13 @@
 		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 1))
 
+#define SPINAND_PAGE_READ_FROM_CACHE_DTR_OP(addr, ndummy, buf, len, freq) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x0d, 1),				\
+		   SPI_MEM_DTR_OP_ADDR(2, addr, 1),			\
+		   SPI_MEM_DTR_OP_DUMMY(ndummy, 1),			\
+		   SPI_MEM_DTR_OP_DATA_IN(len, buf, 1),			\
+		   SPI_MEM_OP_MAX_FREQ(freq))
+
 #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP(addr, ndummy, buf, len)	\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0x3b, 1),				\
 		   SPI_MEM_OP_ADDR(2, addr, 1),				\
@@ -99,6 +106,13 @@
 		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 2))
 
+#define SPINAND_PAGE_READ_FROM_CACHE_X2_DTR_OP(addr, ndummy, buf, len, freq) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x3d, 1),				\
+		   SPI_MEM_DTR_OP_ADDR(2, addr, 1),			\
+		   SPI_MEM_DTR_OP_DUMMY(ndummy, 1),			\
+		   SPI_MEM_DTR_OP_DATA_IN(len, buf, 2),			\
+		   SPI_MEM_OP_MAX_FREQ(freq))
+
 #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP(addr, ndummy, buf, len)	\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0x6b, 1),				\
 		   SPI_MEM_OP_ADDR(2, addr, 1),				\
@@ -111,6 +125,13 @@
 		   SPI_MEM_OP_DUMMY(ndummy, 1),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 4))
 
+#define SPINAND_PAGE_READ_FROM_CACHE_X4_DTR_OP(addr, ndummy, buf, len, freq) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0x6d, 1),				\
+		   SPI_MEM_DTR_OP_ADDR(2, addr, 1),			\
+		   SPI_MEM_DTR_OP_DUMMY(ndummy, 1),			\
+		   SPI_MEM_DTR_OP_DATA_IN(len, buf, 4),			\
+		   SPI_MEM_OP_MAX_FREQ(freq))
+
 #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(addr, ndummy, buf, len)	\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0xbb, 1),				\
 		   SPI_MEM_OP_ADDR(2, addr, 2),				\
@@ -123,6 +144,13 @@
 		   SPI_MEM_OP_DUMMY(ndummy, 2),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 2))
 
+#define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_DTR_OP(addr, ndummy, buf, len, freq) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0xbd, 1),				\
+		   SPI_MEM_DTR_OP_ADDR(2, addr, 2),			\
+		   SPI_MEM_DTR_OP_DUMMY(ndummy, 2),			\
+		   SPI_MEM_DTR_OP_DATA_IN(len, buf, 2),			\
+		   SPI_MEM_OP_MAX_FREQ(freq))
+
 #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(addr, ndummy, buf, len)	\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0xeb, 1),				\
 		   SPI_MEM_OP_ADDR(2, addr, 4),				\
@@ -135,6 +163,13 @@
 		   SPI_MEM_OP_DUMMY(ndummy, 4),				\
 		   SPI_MEM_OP_DATA_IN(len, buf, 4))
 
+#define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_DTR_OP(addr, ndummy, buf, len, freq) \
+	SPI_MEM_OP(SPI_MEM_OP_CMD(0xed, 1),				\
+		   SPI_MEM_DTR_OP_ADDR(2, addr, 4),			\
+		   SPI_MEM_DTR_OP_DUMMY(ndummy, 4),			\
+		   SPI_MEM_DTR_OP_DATA_IN(len, buf, 4),			\
+		   SPI_MEM_OP_MAX_FREQ(freq))
+
 #define SPINAND_PROG_EXEC_OP(addr)					\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(0x10, 1),				\
 		   SPI_MEM_OP_ADDR(3, addr, 1),				\

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 25/27] mtd: spinand: winbond: Update the *JW chip definitions
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (23 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 24/27] mtd: spinand: Add support for read DTR operations Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 26/27] mtd: spinand: winbond: Add comment about naming Miquel Raynal
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, stable+noautosel

W25N01JW and W25N02JW use a different technology with higher frequencies
supported (up to 166MHz). There is one drawback though, the slowest
READ_FROM_CACHE command cannot run above 54MHz. Because of that, we need
to set a limit for these chips on the basic READ_FROM_CACHE variant.

Duplicating this list is not a problem because these chips have DTR
support, and the list of supported variants will diverge from all the
other chips when adding support for it.

Cc: <stable+noautosel@kernel.org> # New feature being added
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/spi/winbond.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index fb6fee71bcb6d00c5ae7a5578b57c8c3725c7391..97517d495e57a6e9e616ed7e66b4a8e9fc1fe62a 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -10,6 +10,7 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/mtd/spinand.h>
+#include <linux/units.h>
 
 #define SPINAND_MFR_WINBOND		0xEF
 
@@ -17,6 +18,14 @@
 
 #define W25N04KV_STATUS_ECC_5_8_BITFLIPS	(3 << 4)
 
+static SPINAND_OP_VARIANTS(read_cache_dtr_variants,
+		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0, 54 * HZ_PER_MHZ));
+
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
@@ -194,7 +203,7 @@ static const struct spinand_info winbond_spinand_table[] = {
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xbc, 0x21),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
 		     NAND_ECCREQ(1, 512),
-		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_dtr_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
 		     0,
@@ -223,7 +232,7 @@ static const struct spinand_info winbond_spinand_table[] = {
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xbf, 0x22),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 2, 1),
 		     NAND_ECCREQ(1, 512),
-		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_dtr_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
 		     0,

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 26/27] mtd: spinand: winbond: Add comment about naming
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (24 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 25/27] mtd: spinand: winbond: Update the *JW chip definitions Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2024-12-24 17:06 ` [PATCH v2 27/27] mtd: spinand: winbond: Add support for DTR operations Miquel Raynal
  2025-01-10 15:47 ` (subset) [PATCH v2 00/27] spi-nand/spi-mem DTR support Mark Brown
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Make the link between the core macros and the datasheet.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/spi/winbond.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 97517d495e57a6e9e616ed7e66b4a8e9fc1fe62a..51972ba0f193c7b27ece0296c1590ddfed0ac813 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -18,6 +18,11 @@
 
 #define W25N04KV_STATUS_ECC_5_8_BITFLIPS	(3 << 4)
 
+/*
+ * "X2" in the core is equivalent to "dual output" in the datasheets,
+ * "X4" in the core is equivalent to "quad output" in the datasheets.
+ */
+
 static SPINAND_OP_VARIANTS(read_cache_dtr_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 27/27] mtd: spinand: winbond: Add support for DTR operations
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (25 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 26/27] mtd: spinand: winbond: Add comment about naming Miquel Raynal
@ 2024-12-24 17:06 ` Miquel Raynal
  2025-01-10 15:47 ` (subset) [PATCH v2 00/27] spi-nand/spi-mem DTR support Mark Brown
  27 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2024-12-24 17:06 UTC (permalink / raw)
  To: Mark Brown, Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley,
	Daire McNamara, Matthias Brugger, AngeloGioacchino Del Regno,
	Haibo Chen, Yogesh Gaur, Heiko Stuebner, Michal Simek,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo, Cédric Le Goater,
	Joel Stanley, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Maxime Coquelin, Alexandre Torgue, Raju Rangoju
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

W25N01JW and W25N02JW support many DTR read modes in single, dual and
quad configurations.

DTR modes however cannot be used at 166MHz, as the bus frequency in
this case must be lowered to 80MHz.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/spi/winbond.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 51972ba0f193c7b27ece0296c1590ddfed0ac813..8394a1b1fb0c125ddb614269069d107463e905a3 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -24,10 +24,15 @@
  */
 
 static SPINAND_OP_VARIANTS(read_cache_dtr_variants,
+		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_DTR_OP(0, 8, NULL, 0, 80 * HZ_PER_MHZ),
+		SPINAND_PAGE_READ_FROM_CACHE_X4_DTR_OP(0, 2, NULL, 0, 80 * HZ_PER_MHZ),
 		SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_DTR_OP(0, 4, NULL, 0, 80 * HZ_PER_MHZ),
+		SPINAND_PAGE_READ_FROM_CACHE_X2_DTR_OP(0, 2, NULL, 0, 80 * HZ_PER_MHZ),
 		SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_DTR_OP(0, 2, NULL, 0, 80 * HZ_PER_MHZ),
 		SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(0, 1, NULL, 0),
 		SPINAND_PAGE_READ_FROM_CACHE_OP(0, 1, NULL, 0, 54 * HZ_PER_MHZ));
 

-- 
2.47.0



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations
  2024-12-24 17:06 ` [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations Miquel Raynal
@ 2025-01-10 12:42   ` Mark Brown
  2025-01-10 14:37     ` Miquel Raynal
  0 siblings, 1 reply; 33+ messages in thread
From: Mark Brown @ 2025-01-10 12:42 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley, Daire McNamara,
	Matthias Brugger, AngeloGioacchino Del Regno, Haibo Chen,
	Yogesh Gaur, Heiko Stuebner, Michal Simek, Richard Weinberger,
	Vignesh Raghavendra, Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo,
	Cédric Le Goater, Joel Stanley, Andrew Jeffery, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Maxime Coquelin, Alexandre Torgue, Raju Rangoju,
	Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 3123 bytes --]

On Tue, Dec 24, 2024 at 06:06:05PM +0100, Miquel Raynal wrote:
> In the SPI-NAND layer, we currently make list of operation variants from
> the fastest one to the slowest and there is a bit of logic in the core
> to go over them and pick the first one that is supported by the
> controller, ie. the fastest one among the supported ops.

This breaks the build:

/build/stage/linux/drivers/spi/spi-mem.c:580:5: error: conflicting types for ‘spi_mem_calc_op_duration’; have ‘u64(struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem_op *)’}
  580 | u64 spi_mem_calc_op_duration(struct spi_mem_op *op)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /build/stage/linux/drivers/spi/spi-mem.c:12:
/build/stage/linux/include/linux/spi/spi-mem.h:427:5: note: previous declaration of ‘spi_mem_calc_op_duration’ with type ‘u64(struct spi_mem *, struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem *, struct spi_mem_op *)’}
  427 | u64 spi_mem_calc_op_duration(struct spi_mem *mem, struct spi_mem_op *op);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /build/stage/linux/include/linux/linkage.h:7,
                 from /build/stage/linux/arch/arm/include/asm/bug.h:5,
                 from /build/stage/linux/include/linux/bug.h:5,
                 from /build/stage/linux/include/linux/thread_info.h:13,
                 from /build/stage/linux/include/linux/sched.h:14,
                 from /build/stage/linux/include/linux/ratelimit.h:6,
                 from /build/stage/linux/include/linux/dev_printk.h:16,
                 from /build/stage/linux/include/linux/device.h:15,
                 from /build/stage/linux/include/linux/dmaengine.h:8,
                 from /build/stage/linux/drivers/spi/spi-mem.c:8:
/build/stage/linux/drivers/spi/spi-mem.c:593:19: error: conflicting types for ‘spi_mem_calc_op_duration’; have ‘u64(struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem_op *)’}
  593 | EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~
/build/stage/linux/include/linux/export.h:56:28: note: in definition of macro ‘__EXPORT_SYMBOL’
   56 |         extern typeof(sym) sym;                                 \
      |                            ^~~
/build/stage/linux/include/linux/export.h:69:41: note: in expansion of macro ‘_EXPORT_SYMBOL’
   69 | #define EXPORT_SYMBOL_GPL(sym)          _EXPORT_SYMBOL(sym, "GPL")
      |                                         ^~~~~~~~~~~~~~
/build/stage/linux/drivers/spi/spi-mem.c:593:1: note: in expansion of macro ‘EXPORT_SYMBOL_GPL’
  593 | EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration);
      | ^~~~~~~~~~~~~~~~~
/build/stage/linux/include/linux/spi/spi-mem.h:427:5: note: previous declaration of ‘spi_mem_calc_op_duration’ with type ‘u64(struct spi_mem *, struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem *, struct spi_mem_op *)’}
  427 | u64 spi_mem_calc_op_duration(struct spi_mem *mem, struct spi_mem_op *op);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations
  2025-01-10 12:42   ` Mark Brown
@ 2025-01-10 14:37     ` Miquel Raynal
  2025-01-10 14:52       ` Mark Brown
  0 siblings, 1 reply; 33+ messages in thread
From: Miquel Raynal @ 2025-01-10 14:37 UTC (permalink / raw)
  To: Mark Brown
  Cc: Sanjay R Mehta, Serge Semin, Han Xu, Conor Dooley, Daire McNamara,
	Matthias Brugger, AngeloGioacchino Del Regno, Haibo Chen,
	Yogesh Gaur, Heiko Stuebner, Michal Simek, Richard Weinberger,
	Vignesh Raghavendra, Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo,
	Cédric Le Goater, Joel Stanley, Andrew Jeffery, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Maxime Coquelin, Alexandre Torgue, Raju Rangoju,
	Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

Hi Mark,

On 10/01/2025 at 12:42:47 GMT, Mark Brown <broonie@kernel.org> wrote:

> On Tue, Dec 24, 2024 at 06:06:05PM +0100, Miquel Raynal wrote:
>> In the SPI-NAND layer, we currently make list of operation variants from
>> the fastest one to the slowest and there is a bit of logic in the core
>> to go over them and pick the first one that is supported by the
>> controller, ie. the fastest one among the supported ops.
>
> This breaks the build:
>
> /build/stage/linux/drivers/spi/spi-mem.c:580:5: error: conflicting types for ‘spi_mem_calc_op_duration’; have ‘u64(struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem_op *)’}
>   580 | u64 spi_mem_calc_op_duration(struct spi_mem_op *op)

Crap, that's a fixup that landed in the wrong commit (mtd: spinand:
Enhance the logic when picking a variant). I'll fix it.

Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations
  2025-01-10 14:37     ` Miquel Raynal
@ 2025-01-10 14:52       ` Mark Brown
  2025-01-10 15:06         ` Miquel Raynal
  0 siblings, 1 reply; 33+ messages in thread
From: Mark Brown @ 2025-01-10 14:52 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Sanjay R Mehta, Han Xu, Conor Dooley, Daire McNamara,
	Matthias Brugger, AngeloGioacchino Del Regno, Haibo Chen,
	Yogesh Gaur, Heiko Stuebner, Michal Simek, Richard Weinberger,
	Vignesh Raghavendra, Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo,
	Cédric Le Goater, Joel Stanley, Andrew Jeffery, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Maxime Coquelin, Alexandre Torgue, Raju Rangoju,
	Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 682 bytes --]

On Fri, Jan 10, 2025 at 03:37:52PM +0100, Miquel Raynal wrote:
> On 10/01/2025 at 12:42:47 GMT, Mark Brown <broonie@kernel.org> wrote:

> > This breaks the build:

> > /build/stage/linux/drivers/spi/spi-mem.c:580:5: error: conflicting types for ‘spi_mem_calc_op_duration’; have ‘u64(struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem_op *)’}
> >   580 | u64 spi_mem_calc_op_duration(struct spi_mem_op *op)

> Crap, that's a fixup that landed in the wrong commit (mtd: spinand:
> Enhance the logic when picking a variant). I'll fix it.

Please only resend that patch - the rest builds and tests fine in my CI,
I'm just checking a merge fixup.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations
  2025-01-10 14:52       ` Mark Brown
@ 2025-01-10 15:06         ` Miquel Raynal
  0 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2025-01-10 15:06 UTC (permalink / raw)
  To: Mark Brown
  Cc: Sanjay R Mehta, Han Xu, Conor Dooley, Daire McNamara,
	Matthias Brugger, AngeloGioacchino Del Regno, Haibo Chen,
	Yogesh Gaur, Heiko Stuebner, Michal Simek, Richard Weinberger,
	Vignesh Raghavendra, Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo,
	Cédric Le Goater, Joel Stanley, Andrew Jeffery, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Maxime Coquelin, Alexandre Torgue, Raju Rangoju,
	Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32

On 10/01/2025 at 14:52:29 GMT, Mark Brown <broonie@kernel.org> wrote:

> On Fri, Jan 10, 2025 at 03:37:52PM +0100, Miquel Raynal wrote:
>> On 10/01/2025 at 12:42:47 GMT, Mark Brown <broonie@kernel.org> wrote:
>
>> > This breaks the build:
>
>> > /build/stage/linux/drivers/spi/spi-mem.c:580:5: error: conflicting types for ‘spi_mem_calc_op_duration’; have ‘u64(struct spi_mem_op *)’ {aka ‘long long unsigned int(struct spi_mem_op *)’}
>> >   580 | u64 spi_mem_calc_op_duration(struct spi_mem_op *op)
>
>> Crap, that's a fixup that landed in the wrong commit (mtd: spinand:
>> Enhance the logic when picking a variant). I'll fix it.
>
> Please only resend that patch - the rest builds and tests fine in my CI,
> I'm just checking a merge fixup.

Ah, oops, didn't see this in time and rushed v3.


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: (subset) [PATCH v2 00/27] spi-nand/spi-mem DTR support
  2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
                   ` (26 preceding siblings ...)
  2024-12-24 17:06 ` [PATCH v2 27/27] mtd: spinand: winbond: Add support for DTR operations Miquel Raynal
@ 2025-01-10 15:47 ` Mark Brown
  27 siblings, 0 replies; 33+ messages in thread
From: Mark Brown @ 2025-01-10 15:47 UTC (permalink / raw)
  To: Sanjay R Mehta, Han Xu, Conor Dooley, Daire McNamara,
	Matthias Brugger, AngeloGioacchino Del Regno, Haibo Chen,
	Yogesh Gaur, Heiko Stuebner, Michal Simek, Richard Weinberger,
	Vignesh Raghavendra, Jacky Huang, Shan-Chun Hung, Chin-Ting Kuo,
	Cédric Le Goater, Joel Stanley, Andrew Jeffery, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Maxime Coquelin, Alexandre Torgue, Raju Rangoju,
	Miquel Raynal
  Cc: Thomas Petazzoni, Steam Lin, linux-spi, linux-kernel, imx,
	linux-riscv, linux-arm-kernel, linux-mediatek, linux-rockchip,
	linux-mtd, linux-aspeed, openbmc, linux-stm32, Pratyush Yadav,
	Tudor Ambarus, stable+noautosel

On Tue, 24 Dec 2024 18:05:45 +0100, Miquel Raynal wrote:
> Here is a (big) series supposed to bring DTR support in SPI-NAND.
> 
> I could have split this into two but I eventually preferred showing the
> big picture. Once v1 will be over, I can make it two. However when we'll
> discuss merging, we'll have to share an immutable tag among the two
> subsystems.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[01/27] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency
        commit: 0fefeade90e74bc8f40ab0e460f483565c492e28
[02/27] spi: spi-mem: Add a new controller capability
        commit: 1248c9b8d54120950fda10fbeb98fb8932b4d45c
[03/27] spi: amd: Support per spi-mem operation frequency switches
        commit: d0e5faccb229b1dacc4c9fa11f6df33bb1fdabd8
[04/27] spi: amd: Drop redundant check
        commit: e6204f39fe3a7b4538815a2d778b601bd543649e
[05/27] spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches
        commit: 5baa189789e8894c58eacc7803e3c163c1d0fc0a
[06/27] spi: cadence-qspi: Support per spi-mem operation frequency switches
        commit: 06e9f5a1f6ba774d8942a168d3ec5ed5a008fbcb
[07/27] spi: dw: Support per spi-mem operation frequency switches
        commit: eee7bc9e7ade6f7ac17d9ec02887cd5509ba9427
[08/27] spi: fsl-qspi: Support per spi-mem operation frequency switches
        commit: 2438db5253eb17a7c0ccb15aea4252a150dda057
[09/27] spi: microchip-core-qspi: Support per spi-mem operation frequency switches
        commit: 13529647743d906ed3cf991f1d77727e7ff1fb6f
[10/27] spi: mt65xx: Support per spi-mem operation frequency switches
        commit: 13fd04b53053bbfa741a0f2a781837ab80e485f6
[11/27] spi: mxic: Support per spi-mem operation frequency switches
        commit: 67707cb094f134f5b3931eefbedbb9ca7e3209d0
[12/27] spi: nxp-fspi: Support per spi-mem operation frequency switches
        commit: 26851cf65ffca2d3a8d529a125e54cf0084d69e7
[13/27] spi: rockchip-sfc: Support per spi-mem operation frequency switches
        commit: d3f35dd3ad968256ed1080e3ea2022f947861cff
[14/27] spi: spi-sn-f-ospi: Support per spi-mem operation frequency switches
        commit: 1a206344218cc15ad8f321e3abab3f3d36ab639f
[15/27] spi: spi-ti-qspi: Support per spi-mem operation frequency switches
        commit: b2fac3192919dd07e7ce30558e34abd7e07dde77
[16/27] spi: zynq-qspi: Support per spi-mem operation frequency switches
        commit: 9a68f6c8d6cfddeac7c5874528ed04e50a1cb579
[17/27] spi: zynqmp-gqspi: Support per spi-mem operation frequency switches
        commit: 30eb2e6e78225f92f04a2325c6fd77fe8f5b4aab
[18/27] spi: spi-mem: Reorder spi-mem macro assignments
        commit: d1f85873d2d62d6980e68d21d3a21f20b0664cc3
[19/27] spi: spi-mem: Create macros for DTR operation
        commit: f0006897a96c736623ddeb9b68c3880eb5cdebe7
[20/27] spi: spi-mem: Estimate the time taken by operations
        (no commit info)

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark



^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2025-01-10 16:15 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-24 17:05 [PATCH v2 00/27] spi-nand/spi-mem DTR support Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 01/27] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 02/27] spi: spi-mem: Add a new controller capability Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 03/27] spi: amd: Support per spi-mem operation frequency switches Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 04/27] spi: amd: Drop redundant check Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 05/27] spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 06/27] spi: cadence-qspi: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 07/27] spi: dw: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 08/27] spi: fsl-qspi: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 09/27] spi: microchip-core-qspi: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 10/27] spi: mt65xx: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 11/27] spi: mxic: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 12/27] spi: nxp-fspi: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 13/27] spi: rockchip-sfc: " Miquel Raynal
2024-12-24 17:05 ` [PATCH v2 14/27] spi: spi-sn-f-ospi: " Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 15/27] spi: spi-ti-qspi: " Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 16/27] spi: zynq-qspi: " Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 17/27] spi: zynqmp-gqspi: " Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 18/27] spi: spi-mem: Reorder spi-mem macro assignments Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 19/27] spi: spi-mem: Create macros for DTR operation Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 20/27] spi: spi-mem: Estimate the time taken by operations Miquel Raynal
2025-01-10 12:42   ` Mark Brown
2025-01-10 14:37     ` Miquel Raynal
2025-01-10 14:52       ` Mark Brown
2025-01-10 15:06         ` Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 21/27] mtd: spinand: Create distinct fast and slow read from cache variants Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 22/27] mtd: spinand: Add an optional frequency to read from cache macros Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 23/27] mtd: spinand: Enhance the logic when picking a variant Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 24/27] mtd: spinand: Add support for read DTR operations Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 25/27] mtd: spinand: winbond: Update the *JW chip definitions Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 26/27] mtd: spinand: winbond: Add comment about naming Miquel Raynal
2024-12-24 17:06 ` [PATCH v2 27/27] mtd: spinand: winbond: Add support for DTR operations Miquel Raynal
2025-01-10 15:47 ` (subset) [PATCH v2 00/27] spi-nand/spi-mem DTR support Mark Brown

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).