Skip to contentSkip to conversation

mtd: cqspi: Wait for transfer completion

PATCH In review Marek Vasut 3 participants 13 messages Sep 14, 2021 – Dec 2, 2021 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: cqspi: Wait for transfer completion

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
 drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +17 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
 	writel(CQSPI_REG_INDIRECTRD_DONE,
 	       plat->regbase + CQSPI_REG_INDIRECTRD);
 
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+				CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect read clear completion error (%i)\n", ret);
+		goto failrd;
+	}
+
 	return 0;
 
 failrd:
@@ -1012,6 +1020,15 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat,
 	/* Clear indirect completion status */
 	writel(CQSPI_REG_INDIRECTWR_DONE,
 	       plat->regbase + CQSPI_REG_INDIRECTWR);
+
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTWR,
+				CQSPI_REG_INDIRECTWR_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect write clear completion error (%i)\n", ret);
+		goto failwr;
+	}
+
 	if (bounce_buf)
 		free(bounce_buf);
 	return 0;
Signature · 1 line
2.33.0
#1 lore raw
Quoted 17 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
 drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +0 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
 	writel(CQSPI_REG_INDIRECTRD_DONE,

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 868

Quoted 10 lines
drivers/spi/cadence_qspi_apb.c +8 -0
 	       plat->regbase + CQSPI_REG_INDIRECTRD);
 
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+				CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect read clear completion error (%i)\n", ret);
+		goto failrd;
+	}
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 22 lines
drivers/spi/cadence_qspi_apb.c +9 -0
 	return 0;
 
 failrd:
@@ -1012,6 +1020,15 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat,
 	/* Clear indirect completion status */
 	writel(CQSPI_REG_INDIRECTWR_DONE,
 	       plat->regbase + CQSPI_REG_INDIRECTWR);
+
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTWR,
+				CQSPI_REG_INDIRECTWR_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect write clear completion error (%i)\n", ret);
+		goto failwr;
+	}
+
 	if (bounce_buf)
 		free(bounce_buf);
 	return 0;
Signature · 1 line
2.33.0
Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#2 lore raw
Quoted 20 lines · Pratyush Yadav
Quoted 19 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
  drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +0 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
  	writel(CQSPI_REG_INDIRECTRD_DONE,
  	       plat->regbase + CQSPI_REG_INDIRECTRD);
 
Quoted 13 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 868

Quoted 8 lines
drivers/spi/cadence_qspi_apb.c +8 -0
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+				CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect read clear completion error (%i)\n", ret);
+		goto failrd;
+	}
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

#3 lore raw
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
  drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
  	writel(CQSPI_REG_INDIRECTRD_DONE,
  	       plat->regbase + CQSPI_REG_INDIRECTRD);
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+				CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 868

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+		goto failrd;
+	}
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#4 lore raw
Quoted 38 lines · Pratyush Yadav
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
   	writel(CQSPI_REG_INDIRECTRD_DONE,
   	       plat->regbase + CQSPI_REG_INDIRECTRD);
+	/* Check indirect done status */
+	ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+				CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+	if (ret) {
+		printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 868

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+		goto failrd;
+	}
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

Quoted 7 lines

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

As far as I recall, the problem was triggered when using UBI on the SPI NOR, so that could very well be the next transfer.

#5 lore raw
Quoted 43 lines · Marek Vasut
Quoted 41 lines · Pratyush Yadav
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
           writel(CQSPI_REG_INDIRECTRD_DONE,
                  plat->regbase + CQSPI_REG_INDIRECTRD);
+  /* Check indirect done status */
+  ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                          CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+  if (ret) {
+          printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 868

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+          goto failrd;
+  }
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

Quoted 7 lines
Quoted 4 lines

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

As far as I recall, the problem was triggered when using UBI on the SPI NOR, so that could very well be the next transfer.

Any further decisions here? shall I take it or v2?

Jagan.

#6 lore raw
Quoted 49 lines · Jagan Teki
Quoted 48 lines · Marek Vasut
Quoted 45 lines · Pratyush Yadav
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
           writel(CQSPI_REG_INDIRECTRD_DONE,
                  plat->regbase + CQSPI_REG_INDIRECTRD);
+  /* Check indirect done status */
+  ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                          CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+  if (ret) {
+          printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 868

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+          goto failrd;
+  }
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

Quoted 4 lines
Quoted 2 lines

As far as I recall, the problem was triggered when using UBI on the SPI NOR, so that could very well be the next transfer.

Any further decisions here? shall I take it or v2?

I think we need more information here. I don't see why checking this bit would interfere with the current transfer since that is already finished by the time we get here. If it is the next transfer then this might just be a symptom and the real problem might be somewhere else.

Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#7 lore raw
Quoted 53 lines · Pratyush Yadav
Quoted 52 lines · Jagan Teki
Quoted 50 lines · Marek Vasut
Quoted 38 lines · Pratyush Yadav
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
    drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
    1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
            writel(CQSPI_REG_INDIRECTRD_DONE,
                   plat->regbase + CQSPI_REG_INDIRECTRD);
+  /* Check indirect done status */
+  ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                          CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+  if (ret) {
+          printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 867

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+          goto failrd;
+  }
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

Quoted 7 lines

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

As far as I recall, the problem was triggered when using UBI on the SPI NOR, so that could very well be the next transfer.

Quoted 6 lines
Quoted 1 line

Any further decisions here? shall I take it or v2?

I think we need more information here. I don't see why checking this bit would interfere with the current transfer since that is already finished by the time we get here. If it is the next transfer then this might just be a symptom and the real problem might be somewhere else.

What additional information do you need ?

#8 lore raw

Hi Marek,

Quoted 54 lines · Marek Vasut
Quoted 53 lines · Pratyush Yadav
Quoted 52 lines · Jagan Teki
Quoted 50 lines · Marek Vasut
Quoted 38 lines · Pratyush Yadav
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
    drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
    1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
            writel(CQSPI_REG_INDIRECTRD_DONE,
                   plat->regbase + CQSPI_REG_INDIRECTRD);
+  /* Check indirect done status */
+  ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                          CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+  if (ret) {
+          printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 867

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+          goto failrd;
+  }
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

Quoted 7 lines

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

As far as I recall, the problem was triggered when using UBI on the SPI NOR, so that could very well be the next transfer.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Any further decisions here? shall I take it or v2?

I think we need more information here. I don't see why checking this bit would interfere with the current transfer since that is already finished by the time we get here. If it is the next transfer then this might just be a symptom and the real problem might be somewhere else.

What additional information do you need ?

Sorry for the late reply. I dropped the ball on this one.

The additional information I needed was to know what exactly happens if we don't wait for this bit to be cleared. Does the _current_ transfer go though fine? If it does, what gets corrupted in the next transfer? Do you only get partial data? Do you get garbage data? Do you get no data at all?

All this information would be useful for understanding if this fix is the right one, and if so why it is the right one.

Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#9 lore raw
In reply to Pratyush Yadav

Hi Pratyush,

Quoted 54 lines · Pratyush Yadav
Quoted 52 lines · Jagan Teki
Quoted 50 lines · Marek Vasut
Quoted 38 lines · Pratyush Yadav
Quoted 34 lines · Marek Vasut
Quoted 24 lines · Pratyush Yadav
Quoted 23 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +5 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
           writel(CQSPI_REG_INDIRECTRD_DONE,
                  plat->regbase + CQSPI_REG_INDIRECTRD);
+  /* Check indirect done status */
+  ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                          CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+  if (ret) {
+          printf("Indirect read clear completion error (%i)\n", ret);
Quoted 8 lines

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, · line 867

Quoted 3 lines
drivers/spi/cadence_qspi_apb.c +3 -0
+          goto failrd;
+  }
+

Huh, this is strange. I would expect the bit to clear immediately since it doesn't really do any operation on the flash. How long does it usually take to clear? If you don't wait for it to clear does anything break?

Quoted 2 lines

Often it does clear immediately, but there were a few odd cases where it did not happen right away, in which case I had transfer corruption.

Quoted 7 lines

By "transfer corruption" do you mean the current transfer gets corrupted or the next one?

We get here _after_ the transfer is completed and this bit should have little to do with the data received. If the current transfer fails then I suspect something else might be going wrong the this is just a symptom of the problem.

As far as I recall, the problem was triggered when using UBI on the SPI NOR, so that could very well be the next transfer.

Quoted 6 lines
Quoted 1 line

Any further decisions here? shall I take it or v2?

I think we need more information here. I don't see why checking this bit would interfere with the current transfer since that is already finished by the time we get here. If it is the next transfer then this might just be a symptom and the real problem might be somewhere else.

Do you mean the bit is using on the patch is not proper for all transfers? did you find any issues on your tests some where? please indicate what's wrong?

Jagan.

#10 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 34 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
 drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +8 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
        writel(CQSPI_REG_INDIRECTRD_DONE,
               plat->regbase + CQSPI_REG_INDIRECTRD);
 
+       /* Check indirect done status */
+       ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                               CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+       if (ret) {
+               printf("Indirect read clear completion error (%i)\n", ret);
+               goto failrd;
+       }
+
        return 0;
 
 failrd:
@@ -1012,6 +1020,15 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat,
        /* Clear indirect completion status */
        writel(CQSPI_REG_INDIRECTWR_DONE,

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat, · line 1031

Quoted 10 lines
drivers/spi/cadence_qspi_apb.c +9 -0
               plat->regbase + CQSPI_REG_INDIRECTWR);
+
+       /* Check indirect done status */
+       ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTWR,
+                               CQSPI_REG_INDIRECTWR_DONE, 0, 10, 0);
+       if (ret) {
+               printf("Indirect write clear completion error (%i)\n", ret);
+               goto failwr;
+       }
+

Does this patch to be part of the release?

Jagan.

#11 lore raw
Quoted 33 lines · Jagan Teki

Hi Marek,

Quoted 30 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
  drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +8 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
         writel(CQSPI_REG_INDIRECTRD_DONE,
                plat->regbase + CQSPI_REG_INDIRECTRD);
 
+       /* Check indirect done status */
+       ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                               CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+       if (ret) {
+               printf("Indirect read clear completion error (%i)\n", ret);
+               goto failrd;
+       }
+
         return 0;
 
Quoted 16 lines
Quoted 4 lines
drivers/spi/cadence_qspi_apb.c +0 -0
  failrd:
@@ -1012,6 +1020,15 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat,
         /* Clear indirect completion status */
         writel(CQSPI_REG_INDIRECTWR_DONE,

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat, · line 1031

Quoted 10 lines
drivers/spi/cadence_qspi_apb.c +9 -0
                plat->regbase + CQSPI_REG_INDIRECTWR);
+
+       /* Check indirect done status */
+       ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTWR,
+                               CQSPI_REG_INDIRECTWR_DONE, 0, 10, 0);
+       if (ret) {
+               printf("Indirect write clear completion error (%i)\n", ret);
+               goto failwr;
+       }
+

Does this patch to be part of the release?

Yes, this fix was posted way before the 2022.01 MR even opened, it can be added.

#12 lore raw
Quoted 52 lines · Marek Vasut
Quoted 33 lines · Jagan Teki

Hi Marek,

Quoted 30 lines · Marek Vasut

Wait for the read/write transfer finish bit get actually cleared, this does not happen immediately on at least SoCFPGA Gen5.

Cc Jagan Teki <[email protected]>
Cc Vignesh R <[email protected]>
Cc Pratyush Yadav <[email protected]>
---
  drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/spi/cadence_qspi_apb.c +8 -0
index 429ee335db6..2cdf4c9c9f8 100644
@@ -858,6 +858,14 @@ cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat,
         writel(CQSPI_REG_INDIRECTRD_DONE,
                plat->regbase + CQSPI_REG_INDIRECTRD);
 
+       /* Check indirect done status */
+       ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTRD,
+                               CQSPI_REG_INDIRECTRD_DONE, 0, 10, 0);
+       if (ret) {
+               printf("Indirect read clear completion error (%i)\n", ret);
+               goto failrd;
+       }
+
         return 0;
 
Quoted 16 lines
Quoted 4 lines
drivers/spi/cadence_qspi_apb.c +0 -0
  failrd:
@@ -1012,6 +1020,15 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat,
         /* Clear indirect completion status */
         writel(CQSPI_REG_INDIRECTWR_DONE,

drivers/spi/cadence_qspi_apb.c cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat, · line 1031

Quoted 10 lines
drivers/spi/cadence_qspi_apb.c +9 -0
                plat->regbase + CQSPI_REG_INDIRECTWR);
+
+       /* Check indirect done status */
+       ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_INDIRECTWR,
+                               CQSPI_REG_INDIRECTWR_DONE, 0, 10, 0);
+       if (ret) {
+               printf("Indirect write clear completion error (%i)\n", ret);
+               goto failwr;
+       }
+

Does this patch to be part of the release?

Quoted 2 lines

Yes, this fix was posted way before the 2022.01 MR even opened, it can be added.

Yeah. was delayed. in fact I was waited response from Pratyush previous comments. I will send the PR anyway.

Thanks,
Jagan.