linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] spi: stm32-qspi: flags management fixes
@ 2022-05-11  7:46 patrice.chotard
  2022-05-11  7:46 ` [PATCH 1/3] spi: stm32-qspi: Fix wait_cmd timeout in APM mode patrice.chotard
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: patrice.chotard @ 2022-05-11  7:46 UTC (permalink / raw)
  To: Mark Brown, Alexandre Torgue
  Cc: linux-spi, linux-stm32, linux-arm-kernel, linux-kernel,
	christophe.kerello, patrice.chotard

From: Patrice Chotard <patrice.chotard@foss.st.com>

This series update flags management in the following cases:
  - In APM mode, don't take care of TCF and TEF flags
  - Always check TCF flag in stm32_qspi_wait_cmd()
  - Don't check BUSY flag when sending new command

Patrice Chotard (3):
  spi: stm32-qspi: Fix wait_cmd timeout in APM mode
  spi: stm32-qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
  spi: stm32-qspi: Remove SR_BUSY bit check before sending command

 drivers/spi/spi-stm32-qspi.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] spi: stm32-qspi: Fix wait_cmd timeout in APM mode
  2022-05-11  7:46 [PATCH 0/3] spi: stm32-qspi: flags management fixes patrice.chotard
@ 2022-05-11  7:46 ` patrice.chotard
  2022-05-11  7:46 ` [PATCH 2/3] spi: stm32-qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() patrice.chotard
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: patrice.chotard @ 2022-05-11  7:46 UTC (permalink / raw)
  To: Mark Brown, Alexandre Torgue
  Cc: linux-spi, linux-stm32, linux-arm-kernel, linux-kernel,
	christophe.kerello, patrice.chotard, eberhard.stoll

From: Patrice Chotard <patrice.chotard@foss.st.com>

In APM mode, TCF and TEF flags are not set. To avoid timeout in
stm32_qspi_wait_cmd(), don't check if TCF/TEF are set.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reported-by: eberhard.stoll@kontron.de
---
 drivers/spi/spi-stm32-qspi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index bf47a1452001..12d8bec35bf6 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -308,7 +308,8 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi,
 	if (!op->data.nbytes)
 		goto wait_nobusy;
 
-	if (readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF)
+	if ((readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF) ||
+	    qspi->fmode == CCR_FMODE_APM)
 		goto out;
 
 	reinit_completion(&qspi->data_completion);
-- 
2.25.1


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

* [PATCH 2/3] spi: stm32-qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
  2022-05-11  7:46 [PATCH 0/3] spi: stm32-qspi: flags management fixes patrice.chotard
  2022-05-11  7:46 ` [PATCH 1/3] spi: stm32-qspi: Fix wait_cmd timeout in APM mode patrice.chotard
@ 2022-05-11  7:46 ` patrice.chotard
  2022-05-11  7:46 ` [PATCH 3/3] spi: stm32-qspi: Remove SR_BUSY bit check before sending command patrice.chotard
  2022-05-11 18:49 ` [PATCH 0/3] spi: stm32-qspi: flags management fixes Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: patrice.chotard @ 2022-05-11  7:46 UTC (permalink / raw)
  To: Mark Brown, Alexandre Torgue
  Cc: linux-spi, linux-stm32, linux-arm-kernel, linux-kernel,
	christophe.kerello, patrice.chotard

From: Patrice Chotard <patrice.chotard@foss.st.com>

Currently, SR_TCF flag is checked in case there is data, this criteria
is not correct.

SR_TCF flags is set when programmed number of bytes has been transferred
to the memory device ("bytes" comprised command and data send to the
SPI device).
So even if there is no data, we must check SR_TCF flag.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
 drivers/spi/spi-stm32-qspi.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 12d8bec35bf6..1660ca5bd1c5 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -305,9 +305,6 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi,
 	u32 cr, sr;
 	int err = 0;
 
-	if (!op->data.nbytes)
-		goto wait_nobusy;
-
 	if ((readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF) ||
 	    qspi->fmode == CCR_FMODE_APM)
 		goto out;
@@ -328,7 +325,6 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi,
 out:
 	/* clear flags */
 	writel_relaxed(FCR_CTCF | FCR_CTEF, qspi->io_base + QSPI_FCR);
-wait_nobusy:
 	if (!err)
 		err = stm32_qspi_wait_nobusy(qspi);
 
-- 
2.25.1


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

* [PATCH 3/3] spi: stm32-qspi: Remove SR_BUSY bit check before sending command
  2022-05-11  7:46 [PATCH 0/3] spi: stm32-qspi: flags management fixes patrice.chotard
  2022-05-11  7:46 ` [PATCH 1/3] spi: stm32-qspi: Fix wait_cmd timeout in APM mode patrice.chotard
  2022-05-11  7:46 ` [PATCH 2/3] spi: stm32-qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() patrice.chotard
@ 2022-05-11  7:46 ` patrice.chotard
  2022-05-11 18:49 ` [PATCH 0/3] spi: stm32-qspi: flags management fixes Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: patrice.chotard @ 2022-05-11  7:46 UTC (permalink / raw)
  To: Mark Brown, Alexandre Torgue
  Cc: linux-spi, linux-stm32, linux-arm-kernel, linux-kernel,
	christophe.kerello, patrice.chotard

From: Patrice Chotard <patrice.chotard@foss.st.com>

Waiting for SR_BUSY bit when receiving a new command is not needed.
SR_BUSY bit is already managed in the previous command treatment.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
 drivers/spi/spi-stm32-qspi.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 1660ca5bd1c5..c0239e405c39 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -369,10 +369,6 @@ static int stm32_qspi_send(struct spi_mem *mem, const struct spi_mem_op *op)
 		op->dummy.buswidth, op->data.buswidth,
 		op->addr.val, op->data.nbytes);
 
-	err = stm32_qspi_wait_nobusy(qspi);
-	if (err)
-		goto abort;
-
 	cr = readl_relaxed(qspi->io_base + QSPI_CR);
 	cr &= ~CR_PRESC_MASK & ~CR_FSEL;
 	cr |= FIELD_PREP(CR_PRESC_MASK, flash->presc);
-- 
2.25.1


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

* Re: [PATCH 0/3] spi: stm32-qspi: flags management fixes
  2022-05-11  7:46 [PATCH 0/3] spi: stm32-qspi: flags management fixes patrice.chotard
                   ` (2 preceding siblings ...)
  2022-05-11  7:46 ` [PATCH 3/3] spi: stm32-qspi: Remove SR_BUSY bit check before sending command patrice.chotard
@ 2022-05-11 18:49 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-05-11 18:49 UTC (permalink / raw)
  To: alexandre.torgue, patrice.chotard
  Cc: linux-stm32, christophe.kerello, linux-kernel, linux-spi,
	linux-arm-kernel

On Wed, 11 May 2022 09:46:41 +0200, patrice.chotard@foss.st.com wrote:
> From: Patrice Chotard <patrice.chotard@foss.st.com>
> 
> This series update flags management in the following cases:
>   - In APM mode, don't take care of TCF and TEF flags
>   - Always check TCF flag in stm32_qspi_wait_cmd()
>   - Don't check BUSY flag when sending new command
> 
> [...]

Applied to

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

Thanks!

[1/3] spi: stm32-qspi: Fix wait_cmd timeout in APM mode
      commit: d83d89ea68b4726700fa87b22db075e4217e691c
[2/3] spi: stm32-qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
      commit: 0cf8d32600cf5660ee45d421f1b6e3a129ca58b6
[3/3] spi: stm32-qspi: Remove SR_BUSY bit check before sending command
      commit: ae16cc18f37bcdea7d4ef57a5e526a60b09a1506

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

end of thread, other threads:[~2022-05-11 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  7:46 [PATCH 0/3] spi: stm32-qspi: flags management fixes patrice.chotard
2022-05-11  7:46 ` [PATCH 1/3] spi: stm32-qspi: Fix wait_cmd timeout in APM mode patrice.chotard
2022-05-11  7:46 ` [PATCH 2/3] spi: stm32-qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() patrice.chotard
2022-05-11  7:46 ` [PATCH 3/3] spi: stm32-qspi: Remove SR_BUSY bit check before sending command patrice.chotard
2022-05-11 18:49 ` [PATCH 0/3] spi: stm32-qspi: flags management fixes 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).