mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] spi: airoha: Explicitly prevent continuous reads
@ 2026-11-18 13:59 Miquel Raynal
  2026-11-18 18:37 ` Mikhail Kshevetskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Miquel Raynal @ 2026-11-18 13:59 UTC (permalink / raw)
  To: Lorenzo Bianconi, Ray Liu, Mark Brown
  Cc: Thomas Petazzoni, Mikhail Kshevetskiy, linux-arm-kernel,
	linux-spi, linux-kernel, Miquel Raynal

The SPI NAND core currently treats the lack of "large reads" as an
indication that continuous reads might not be properly supported, but
this is fragile and might evolve. The real problem with the Airoha
controller is that it lacks full control over its CS, which may be
spuriously deasserted. We now have a flag for this, so set it and make
it clear that this controller is not suitable for continuous reading, at
least with chips processing a CS deassertion as an end of read
condition.

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

diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c
index 95bfde7c8e7f..1070d4697fcb 100644
--- a/drivers/spi/spi-airoha-snfi.c
+++ b/drivers/spi/spi-airoha-snfi.c
@@ -1018,6 +1018,10 @@ static const struct spi_controller_mem_ops airoha_snand_nodma_mem_ops = {
 	.exec_op = airoha_snand_exec_op,
 };
 
+static const struct spi_controller_mem_caps airoha_snand_mem_caps = {
+	.no_cs_assertion = true,
+};
+
 static int airoha_snand_setup(struct spi_device *spi)
 {
 	struct airoha_snand_ctrl *as_ctrl;
@@ -1121,6 +1125,7 @@ static int airoha_snand_probe(struct platform_device *pdev)
 	ctrl->num_chipselect = 2;
 	ctrl->mem_ops = dma_enable ? &airoha_snand_mem_ops
 				   : &airoha_snand_nodma_mem_ops;
+	ctrl->mem_caps = &airoha_snand_mem_caps;
 	ctrl->bits_per_word_mask = SPI_BPW_MASK(8);
 	ctrl->mode_bits = SPI_RX_DUAL;
 	ctrl->setup = airoha_snand_setup;

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261118-winbond-upstreaming-airoha-cont-read-1332872b972c

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


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

* Re: [PATCH] spi: airoha: Explicitly prevent continuous reads
  2026-11-18 13:59 [PATCH] spi: airoha: Explicitly prevent continuous reads Miquel Raynal
@ 2026-11-18 18:37 ` Mikhail Kshevetskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Mikhail Kshevetskiy @ 2026-11-18 18:37 UTC (permalink / raw)
  To: Miquel Raynal, Lorenzo Bianconi, Ray Liu, Mark Brown
  Cc: Thomas Petazzoni, linux-arm-kernel, linux-spi, linux-kernel

Hello Miquel,

I think the patch is bad for the following reasons:
* As I know there is no CS issue with Airoha controller. It works properly.
* Airoha controller supports large reads (but only in PIO  mode). Thus
  continuous reading may work properly. Unfortunately PIO reading several
  times slower than DMA reading.
* DMA reading is much faster, but can't be used for continuous reading.
  Maximum transfer size is 8191 bytes.

Thus for new Airoha controllers (en7523, an7581 and newer) it's better do
not use continuous reading and read pages using DMA. Old controllers (like
en7512) does not support DMA, so they can benefit from continuous mode
reading.

On 11/18/26 16:59, Miquel Raynal wrote:
> The SPI NAND core currently treats the lack of "large reads" as an
> indication that continuous reads might not be properly supported, but
> this is fragile and might evolve. The real problem with the Airoha
> controller is that it lacks full control over its CS, which may be
> spuriously deasserted. We now have a flag for this, so set it and make
> it clear that this controller is not suitable for continuous reading, at
> least with chips processing a CS deassertion as an end of read
> condition.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/spi/spi-airoha-snfi.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c
> index 95bfde7c8e7f..1070d4697fcb 100644
> --- a/drivers/spi/spi-airoha-snfi.c
> +++ b/drivers/spi/spi-airoha-snfi.c
> @@ -1018,6 +1018,10 @@ static const struct spi_controller_mem_ops airoha_snand_nodma_mem_ops = {
>  	.exec_op = airoha_snand_exec_op,
>  };
>  
> +static const struct spi_controller_mem_caps airoha_snand_mem_caps = {
> +	.no_cs_assertion = true,
> +};
> +
>  static int airoha_snand_setup(struct spi_device *spi)
>  {
>  	struct airoha_snand_ctrl *as_ctrl;
> @@ -1121,6 +1125,7 @@ static int airoha_snand_probe(struct platform_device *pdev)
>  	ctrl->num_chipselect = 2;
>  	ctrl->mem_ops = dma_enable ? &airoha_snand_mem_ops
>  				   : &airoha_snand_nodma_mem_ops;
> +	ctrl->mem_caps = &airoha_snand_mem_caps;
>  	ctrl->bits_per_word_mask = SPI_BPW_MASK(8);
>  	ctrl->mode_bits = SPI_RX_DUAL;
>  	ctrl->setup = airoha_snand_setup;
>
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20261118-winbond-upstreaming-airoha-cont-read-1332872b972c
>
> Best regards,

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

end of thread, other threads:[~2026-11-18 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 13:59 [PATCH] spi: airoha: Explicitly prevent continuous reads Miquel Raynal
2026-11-18 18:37 ` Mikhail Kshevetskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®