linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read
@ 2023-03-20  9:59 Sai Krishna Potthuri
  2023-03-20  9:59 ` [PATCH 1/2] spi: cadence-quadspi: Update the read timeout based on the length Sai Krishna Potthuri
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sai Krishna Potthuri @ 2023-03-20  9:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, git, saikrishna12468, Sai Krishna Potthuri

Update Xilinx Versal external DMA read logic to fix random issues
- Instead of having the fixed timeout, update the read timeout based on
the length of the transfer to avoid timeout for larger data size.
- While switching between external DMA read and indirect read, disable the
SPI before configuration and enable it after configuration as recommended
by Octal-SPI Flash Controller specification.

Sai Krishna Potthuri (2):
  spi: cadence-quadspi: Update the read timeout based on the length
  spi: cadence-quadspi: Disable the SPI before reconfiguring

 drivers/spi/spi-cadence-quadspi.c | 40 ++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 16 deletions(-)

-- 
2.25.1


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

* [PATCH 1/2] spi: cadence-quadspi: Update the read timeout based on the length
  2023-03-20  9:59 [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Sai Krishna Potthuri
@ 2023-03-20  9:59 ` Sai Krishna Potthuri
  2023-03-20  9:59 ` [PATCH 2/2] spi: cadence-quadspi: Disable the SPI before reconfiguring Sai Krishna Potthuri
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Sai Krishna Potthuri @ 2023-03-20  9:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, git, saikrishna12468, Sai Krishna Potthuri

When performing indirect read via external DMA the timeout for
completion is set equal to the read length instead of fixed timeout value.
For reads larger than 500 bytes, the timeout will continue to be
equal to the read length whereas for a small read like the Read Status
Register command, the timeout would be 1 or 2 milliseconds. This is not
enough to cover the overhead needed in setting up DMA, in that case make
sure the timeout is at least 500ms to allow DMA to finish. This solution
is inline with the timeout used for Direct read via DMA.

Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
---
 drivers/spi/spi-cadence-quadspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 79ab7e309644..e281732aba91 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -863,7 +863,7 @@ static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdata,
 	reinit_completion(&cqspi->transfer_complete);
 
 	if (!wait_for_completion_timeout(&cqspi->transfer_complete,
-					 msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS))) {
+					 msecs_to_jiffies(max_t(size_t, bytes_to_dma, 500)))) {
 		ret = -ETIMEDOUT;
 		goto failrd;
 	}
-- 
2.25.1


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

* [PATCH 2/2] spi: cadence-quadspi: Disable the SPI before reconfiguring
  2023-03-20  9:59 [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Sai Krishna Potthuri
  2023-03-20  9:59 ` [PATCH 1/2] spi: cadence-quadspi: Update the read timeout based on the length Sai Krishna Potthuri
@ 2023-03-20  9:59 ` Sai Krishna Potthuri
  2023-04-14  6:05 ` [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Potthuri, Sai Krishna
  2023-04-17 19:28 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Sai Krishna Potthuri @ 2023-03-20  9:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, git, saikrishna12468, Sai Krishna Potthuri

Observed random DMA timeout failures while doing back to back
transfers which involves switching the modes from DMA to NON-DMA.
This issue is observed while testing the OSPI+UBIFS file system test case
where rootfs is mounted from OSPI UBIFS partition.
To avoid this issue, disable the SPI before changing the configuration
from external DMA to NON-DMA and vice versa and reenable it after changing
the configuration.
As per the Cadence Octal SPI design specification, it is recommended to
disable the Octal-SPI enable bit before reconfiguring.

Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
---
 drivers/spi/spi-cadence-quadspi.c | 38 +++++++++++++++++++------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index e281732aba91..d4a2b72985da 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -791,6 +791,21 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
 	return ret;
 }
 
+static void cqspi_controller_enable(struct cqspi_st *cqspi, bool enable)
+{
+	void __iomem *reg_base = cqspi->iobase;
+	unsigned int reg;
+
+	reg = readl(reg_base + CQSPI_REG_CONFIG);
+
+	if (enable)
+		reg |= CQSPI_REG_CONFIG_ENABLE_MASK;
+	else
+		reg &= ~CQSPI_REG_CONFIG_ENABLE_MASK;
+
+	writel(reg, reg_base + CQSPI_REG_CONFIG);
+}
+
 static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdata,
 					  u_char *rxbuf, loff_t from_addr,
 					  size_t n_rx)
@@ -815,10 +830,14 @@ static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdata,
 	if (ret)
 		return ret;
 
+	cqspi_controller_enable(cqspi, 0);
+
 	reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
 	reg |= CQSPI_REG_CONFIG_DMA_MASK;
 	writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
 
+	cqspi_controller_enable(cqspi, 1);
+
 	dma_addr = dma_map_single(dev, rxbuf, bytes_to_dma, DMA_FROM_DEVICE);
 	if (dma_mapping_error(dev, dma_addr)) {
 		dev_err(dev, "dma mapping failed\n");
@@ -876,10 +895,14 @@ static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdata,
 	       cqspi->iobase + CQSPI_REG_INDIRECTRD);
 	dma_unmap_single(dev, dma_addr, bytes_to_dma, DMA_FROM_DEVICE);
 
+	cqspi_controller_enable(cqspi, 0);
+
 	reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
 	reg &= ~CQSPI_REG_CONFIG_DMA_MASK;
 	writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
 
+	cqspi_controller_enable(cqspi, 1);
+
 	ret = zynqmp_pm_ospi_mux_select(cqspi->pd_dev_id,
 					PM_OSPI_MUX_SEL_LINEAR);
 	if (ret)
@@ -1182,21 +1205,6 @@ static void cqspi_readdata_capture(struct cqspi_st *cqspi,
 	writel(reg, reg_base + CQSPI_REG_READCAPTURE);
 }
 
-static void cqspi_controller_enable(struct cqspi_st *cqspi, bool enable)
-{
-	void __iomem *reg_base = cqspi->iobase;
-	unsigned int reg;
-
-	reg = readl(reg_base + CQSPI_REG_CONFIG);
-
-	if (enable)
-		reg |= CQSPI_REG_CONFIG_ENABLE_MASK;
-	else
-		reg &= ~CQSPI_REG_CONFIG_ENABLE_MASK;
-
-	writel(reg, reg_base + CQSPI_REG_CONFIG);
-}
-
 static void cqspi_configure(struct cqspi_flash_pdata *f_pdata,
 			    unsigned long sclk)
 {
-- 
2.25.1


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

* RE: [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read
  2023-03-20  9:59 [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Sai Krishna Potthuri
  2023-03-20  9:59 ` [PATCH 1/2] spi: cadence-quadspi: Update the read timeout based on the length Sai Krishna Potthuri
  2023-03-20  9:59 ` [PATCH 2/2] spi: cadence-quadspi: Disable the SPI before reconfiguring Sai Krishna Potthuri
@ 2023-04-14  6:05 ` Potthuri, Sai Krishna
  2023-04-17 12:50   ` Mark Brown
  2023-04-17 19:28 ` Mark Brown
  3 siblings, 1 reply; 6+ messages in thread
From: Potthuri, Sai Krishna @ 2023-04-14  6:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, git (AMD-Xilinx), saikrishna12468

> -----Original Message-----
> From: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> Sent: Monday, March 20, 2023 3:29 PM
> To: Mark Brown <broonie@kernel.org>
> Cc: linux-spi@vger.kernel.org; linux-kernel@vger.kernel.org; git (AMD-Xilinx)
> <git@amd.com>; saikrishna12468@gmail.com; Potthuri, Sai Krishna
> <sai.krishna.potthuri@amd.com>
> Subject: [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal
> DMA read
> 
> Update Xilinx Versal external DMA read logic to fix random issues
> - Instead of having the fixed timeout, update the read timeout based on the
> length of the transfer to avoid timeout for larger data size.
> - While switching between external DMA read and indirect read, disable the SPI
> before configuration and enable it after configuration as recommended by Octal-
> SPI Flash Controller specification.
> 
> Sai Krishna Potthuri (2):
>   spi: cadence-quadspi: Update the read timeout based on the length
>   spi: cadence-quadspi: Disable the SPI before reconfiguring
> 
>  drivers/spi/spi-cadence-quadspi.c | 40 ++++++++++++++++++-------------
>  1 file changed, 24 insertions(+), 16 deletions(-)
> 
> --
Mark: Do you have any comments on this series?

Regards
Sai Krishna

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

* Re: [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read
  2023-04-14  6:05 ` [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Potthuri, Sai Krishna
@ 2023-04-17 12:50   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2023-04-17 12:50 UTC (permalink / raw)
  To: Potthuri, Sai Krishna
  Cc: linux-spi, linux-kernel, git (AMD-Xilinx), saikrishna12468

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

On Fri, Apr 14, 2023 at 06:05:15AM +0000, Potthuri, Sai Krishna wrote:

> Mark: Do you have any comments on this series?

Please don't send content free pings and please allow a reasonable time
for review.  People get busy, go on holiday, attend conferences and so 
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review.  If there have been
review comments then people may be waiting for those to be addressed.

Sending content free pings adds to the mail volume (if they are seen at
all) which is often the problem and since they can't be reviewed
directly if something has gone wrong you'll have to resend the patches
anyway, so sending again is generally a better approach though there are
some other maintainers who like them - if in doubt look at how patches
for the subsystem are normally handled.

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

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

* Re: [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read
  2023-03-20  9:59 [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Sai Krishna Potthuri
                   ` (2 preceding siblings ...)
  2023-04-14  6:05 ` [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Potthuri, Sai Krishna
@ 2023-04-17 19:28 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2023-04-17 19:28 UTC (permalink / raw)
  To: Sai Krishna Potthuri; +Cc: linux-spi, linux-kernel, git, saikrishna12468

On Mon, 20 Mar 2023 15:29:29 +0530, Sai Krishna Potthuri wrote:
> Update Xilinx Versal external DMA read logic to fix random issues
> - Instead of having the fixed timeout, update the read timeout based on
> the length of the transfer to avoid timeout for larger data size.
> - While switching between external DMA read and indirect read, disable the
> SPI before configuration and enable it after configuration as recommended
> by Octal-SPI Flash Controller specification.
> 
> [...]

Applied to

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

Thanks!

[1/2] spi: cadence-quadspi: Update the read timeout based on the length
      commit: 22c8ce0aa274cea2ff538ffdf723053ecf77d78b
[2/2] spi: cadence-quadspi: Disable the SPI before reconfiguring
      commit: c0b53f4e545e4c6106aab553eb351138d46211cc

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] 6+ messages in thread

end of thread, other threads:[~2023-04-17 19:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20  9:59 [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Sai Krishna Potthuri
2023-03-20  9:59 ` [PATCH 1/2] spi: cadence-quadspi: Update the read timeout based on the length Sai Krishna Potthuri
2023-03-20  9:59 ` [PATCH 2/2] spi: cadence-quadspi: Disable the SPI before reconfiguring Sai Krishna Potthuri
2023-04-14  6:05 ` [PATCH 0/2] spi: cadence-quadspi: Fix random issues with Xilinx Versal DMA read Potthuri, Sai Krishna
2023-04-17 12:50   ` Mark Brown
2023-04-17 19:28 ` 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).