All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: cqspi: Wait for transfer completion
@ 2021-09-14  3:22 Marek Vasut
  2021-09-14 17:42 ` Pratyush Yadav
  2021-12-02  5:48 ` Jagan Teki
  0 siblings, 2 replies; 13+ messages in thread
From: Marek Vasut @ 2021-09-14  3:22 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Jagan Teki, Vignesh R, Pratyush Yadav

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

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Pratyush Yadav <p.yadav@ti.com>
---
 drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
index 429ee335db6..2cdf4c9c9f8 100644
--- a/drivers/spi/cadence_qspi_apb.c
+++ b/drivers/spi/cadence_qspi_apb.c
@@ -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;
-- 
2.33.0


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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-09-14  3:22 [PATCH] mtd: cqspi: Wait for transfer completion Marek Vasut
@ 2021-09-14 17:42 ` Pratyush Yadav
  2021-09-14 18:22   ` Marek Vasut
  2021-12-02  5:48 ` Jagan Teki
  1 sibling, 1 reply; 13+ messages in thread
From: Pratyush Yadav @ 2021-09-14 17:42 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Jagan Teki, Vignesh R

On 14/09/21 05:22AM, Marek Vasut wrote:
> Wait for the read/write transfer finish bit get actually cleared,
> this does not happen immediately on at least SoCFPGA Gen5.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
> Cc: Vignesh R <vigneshr@ti.com>
> Cc: Pratyush Yadav <p.yadav@ti.com>
> ---
>  drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> index 429ee335db6..2cdf4c9c9f8 100644
> --- a/drivers/spi/cadence_qspi_apb.c
> +++ b/drivers/spi/cadence_qspi_apb.c
> @@ -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;
> +	}
> +

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?

>  	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;
> -- 
> 2.33.0
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-09-14 17:42 ` Pratyush Yadav
@ 2021-09-14 18:22   ` Marek Vasut
  2021-09-15  8:28     ` Pratyush Yadav
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-09-14 18:22 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: u-boot, Jagan Teki, Vignesh R

On 9/14/21 7:42 PM, Pratyush Yadav wrote:
> On 14/09/21 05:22AM, Marek Vasut wrote:
>> Wait for the read/write transfer finish bit get actually cleared,
>> this does not happen immediately on at least SoCFPGA Gen5.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Jagan Teki <jagan@amarulasolutions.com>
>> Cc: Vignesh R <vigneshr@ti.com>
>> Cc: Pratyush Yadav <p.yadav@ti.com>
>> ---
>>   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
>> index 429ee335db6..2cdf4c9c9f8 100644
>> --- a/drivers/spi/cadence_qspi_apb.c
>> +++ b/drivers/spi/cadence_qspi_apb.c
>> @@ -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;
>> +	}
>> +
> 
> 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.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-09-14 18:22   ` Marek Vasut
@ 2021-09-15  8:28     ` Pratyush Yadav
  2021-09-15  8:35       ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Pratyush Yadav @ 2021-09-15  8:28 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Jagan Teki, Vignesh R

On 14/09/21 08:22PM, Marek Vasut wrote:
> On 9/14/21 7:42 PM, Pratyush Yadav wrote:
> > On 14/09/21 05:22AM, Marek Vasut wrote:
> > > Wait for the read/write transfer finish bit get actually cleared,
> > > this does not happen immediately on at least SoCFPGA Gen5.
> > > 
> > > Signed-off-by: Marek Vasut <marex@denx.de>
> > > Cc: Jagan Teki <jagan@amarulasolutions.com>
> > > Cc: Vignesh R <vigneshr@ti.com>
> > > Cc: Pratyush Yadav <p.yadav@ti.com>
> > > ---
> > >   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
> > >   1 file changed, 17 insertions(+)
> > > 
> > > diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> > > index 429ee335db6..2cdf4c9c9f8 100644
> > > --- a/drivers/spi/cadence_qspi_apb.c
> > > +++ b/drivers/spi/cadence_qspi_apb.c
> > > @@ -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;
> > > +	}
> > > +
> > 
> > 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.

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.

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-09-15  8:28     ` Pratyush Yadav
@ 2021-09-15  8:35       ` Marek Vasut
  2021-10-08 12:36         ` Jagan Teki
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-09-15  8:35 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: u-boot, Jagan Teki, Vignesh R

On 9/15/21 10:28 AM, Pratyush Yadav wrote:
> On 14/09/21 08:22PM, Marek Vasut wrote:
>> On 9/14/21 7:42 PM, Pratyush Yadav wrote:
>>> On 14/09/21 05:22AM, Marek Vasut wrote:
>>>> Wait for the read/write transfer finish bit get actually cleared,
>>>> this does not happen immediately on at least SoCFPGA Gen5.
>>>>
>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>> Cc: Jagan Teki <jagan@amarulasolutions.com>
>>>> Cc: Vignesh R <vigneshr@ti.com>
>>>> Cc: Pratyush Yadav <p.yadav@ti.com>
>>>> ---
>>>>    drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
>>>>    1 file changed, 17 insertions(+)
>>>>
>>>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
>>>> index 429ee335db6..2cdf4c9c9f8 100644
>>>> --- a/drivers/spi/cadence_qspi_apb.c
>>>> +++ b/drivers/spi/cadence_qspi_apb.c
>>>> @@ -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;
>>>> +	}
>>>> +
>>>
>>> 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.
> 
> 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.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-09-15  8:35       ` Marek Vasut
@ 2021-10-08 12:36         ` Jagan Teki
  2021-10-25 19:53           ` Pratyush Yadav
  0 siblings, 1 reply; 13+ messages in thread
From: Jagan Teki @ 2021-10-08 12:36 UTC (permalink / raw)
  To: Marek Vasut, Pratyush Yadav; +Cc: U-Boot-Denx, Vignesh R

On Wed, Sep 15, 2021 at 2:05 PM Marek Vasut <marex@denx.de> wrote:
>
> On 9/15/21 10:28 AM, Pratyush Yadav wrote:
> > On 14/09/21 08:22PM, Marek Vasut wrote:
> >> On 9/14/21 7:42 PM, Pratyush Yadav wrote:
> >>> On 14/09/21 05:22AM, Marek Vasut wrote:
> >>>> Wait for the read/write transfer finish bit get actually cleared,
> >>>> this does not happen immediately on at least SoCFPGA Gen5.
> >>>>
> >>>> Signed-off-by: Marek Vasut <marex@denx.de>
> >>>> Cc: Jagan Teki <jagan@amarulasolutions.com>
> >>>> Cc: Vignesh R <vigneshr@ti.com>
> >>>> Cc: Pratyush Yadav <p.yadav@ti.com>
> >>>> ---
> >>>>    drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
> >>>>    1 file changed, 17 insertions(+)
> >>>>
> >>>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> >>>> index 429ee335db6..2cdf4c9c9f8 100644
> >>>> --- a/drivers/spi/cadence_qspi_apb.c
> >>>> +++ b/drivers/spi/cadence_qspi_apb.c
> >>>> @@ -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;
> >>>> +  }
> >>>> +
> >>>
> >>> 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.
> >
> > 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.

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

Jagan.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-10-08 12:36         ` Jagan Teki
@ 2021-10-25 19:53           ` Pratyush Yadav
  2021-10-25 20:25             ` Marek Vasut
  2021-11-01  7:07             ` Jagan Teki
  0 siblings, 2 replies; 13+ messages in thread
From: Pratyush Yadav @ 2021-10-25 19:53 UTC (permalink / raw)
  To: Jagan Teki; +Cc: Marek Vasut, U-Boot-Denx, Vignesh R

On 08/10/21 06:06PM, Jagan Teki wrote:
> On Wed, Sep 15, 2021 at 2:05 PM Marek Vasut <marex@denx.de> wrote:
> >
> > On 9/15/21 10:28 AM, Pratyush Yadav wrote:
> > > On 14/09/21 08:22PM, Marek Vasut wrote:
> > >> On 9/14/21 7:42 PM, Pratyush Yadav wrote:
> > >>> On 14/09/21 05:22AM, Marek Vasut wrote:
> > >>>> Wait for the read/write transfer finish bit get actually cleared,
> > >>>> this does not happen immediately on at least SoCFPGA Gen5.
> > >>>>
> > >>>> Signed-off-by: Marek Vasut <marex@denx.de>
> > >>>> Cc: Jagan Teki <jagan@amarulasolutions.com>
> > >>>> Cc: Vignesh R <vigneshr@ti.com>
> > >>>> Cc: Pratyush Yadav <p.yadav@ti.com>
> > >>>> ---
> > >>>>    drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
> > >>>>    1 file changed, 17 insertions(+)
> > >>>>
> > >>>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> > >>>> index 429ee335db6..2cdf4c9c9f8 100644
> > >>>> --- a/drivers/spi/cadence_qspi_apb.c
> > >>>> +++ b/drivers/spi/cadence_qspi_apb.c
> > >>>> @@ -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;
> > >>>> +  }
> > >>>> +
> > >>>
> > >>> 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.
> > >
> > > 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.
> 
> 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.

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-10-25 19:53           ` Pratyush Yadav
@ 2021-10-25 20:25             ` Marek Vasut
  2021-12-02  9:01               ` Pratyush Yadav
  2021-11-01  7:07             ` Jagan Teki
  1 sibling, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-10-25 20:25 UTC (permalink / raw)
  To: Pratyush Yadav, Jagan Teki; +Cc: U-Boot-Denx, Vignesh R

On 10/25/21 9:53 PM, Pratyush Yadav wrote:
> On 08/10/21 06:06PM, Jagan Teki wrote:
>> On Wed, Sep 15, 2021 at 2:05 PM Marek Vasut <marex@denx.de> wrote:
>>>
>>> On 9/15/21 10:28 AM, Pratyush Yadav wrote:
>>>> On 14/09/21 08:22PM, Marek Vasut wrote:
>>>>> On 9/14/21 7:42 PM, Pratyush Yadav wrote:
>>>>>> On 14/09/21 05:22AM, Marek Vasut wrote:
>>>>>>> Wait for the read/write transfer finish bit get actually cleared,
>>>>>>> this does not happen immediately on at least SoCFPGA Gen5.
>>>>>>>
>>>>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>>>>> Cc: Jagan Teki <jagan@amarulasolutions.com>
>>>>>>> Cc: Vignesh R <vigneshr@ti.com>
>>>>>>> Cc: Pratyush Yadav <p.yadav@ti.com>
>>>>>>> ---
>>>>>>>     drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
>>>>>>>     1 file changed, 17 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
>>>>>>> index 429ee335db6..2cdf4c9c9f8 100644
>>>>>>> --- a/drivers/spi/cadence_qspi_apb.c
>>>>>>> +++ b/drivers/spi/cadence_qspi_apb.c
>>>>>>> @@ -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;
>>>>>>> +  }
>>>>>>> +
>>>>>>
>>>>>> 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.
>>>>
>>>> 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.
>>
>> 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 ?

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-10-25 19:53           ` Pratyush Yadav
  2021-10-25 20:25             ` Marek Vasut
@ 2021-11-01  7:07             ` Jagan Teki
  1 sibling, 0 replies; 13+ messages in thread
From: Jagan Teki @ 2021-11-01  7:07 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: Marek Vasut, U-Boot-Denx, Vignesh R

Hi Pratyush,

On Tue, Oct 26, 2021 at 1:23 AM Pratyush Yadav <p.yadav@ti.com> wrote:
>
> On 08/10/21 06:06PM, Jagan Teki wrote:
> > On Wed, Sep 15, 2021 at 2:05 PM Marek Vasut <marex@denx.de> wrote:
> > >
> > > On 9/15/21 10:28 AM, Pratyush Yadav wrote:
> > > > On 14/09/21 08:22PM, Marek Vasut wrote:
> > > >> On 9/14/21 7:42 PM, Pratyush Yadav wrote:
> > > >>> On 14/09/21 05:22AM, Marek Vasut wrote:
> > > >>>> Wait for the read/write transfer finish bit get actually cleared,
> > > >>>> this does not happen immediately on at least SoCFPGA Gen5.
> > > >>>>
> > > >>>> Signed-off-by: Marek Vasut <marex@denx.de>
> > > >>>> Cc: Jagan Teki <jagan@amarulasolutions.com>
> > > >>>> Cc: Vignesh R <vigneshr@ti.com>
> > > >>>> Cc: Pratyush Yadav <p.yadav@ti.com>
> > > >>>> ---
> > > >>>>    drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
> > > >>>>    1 file changed, 17 insertions(+)
> > > >>>>
> > > >>>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> > > >>>> index 429ee335db6..2cdf4c9c9f8 100644
> > > >>>> --- a/drivers/spi/cadence_qspi_apb.c
> > > >>>> +++ b/drivers/spi/cadence_qspi_apb.c
> > > >>>> @@ -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;
> > > >>>> +  }
> > > >>>> +
> > > >>>
> > > >>> 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.
> > > >
> > > > 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.
> >
> > 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.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-09-14  3:22 [PATCH] mtd: cqspi: Wait for transfer completion Marek Vasut
  2021-09-14 17:42 ` Pratyush Yadav
@ 2021-12-02  5:48 ` Jagan Teki
  2021-12-02  5:50   ` Marek Vasut
  1 sibling, 1 reply; 13+ messages in thread
From: Jagan Teki @ 2021-12-02  5:48 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Vignesh R, Pratyush Yadav

Hi Marek,

On Tue, Sep 14, 2021 at 8:52 AM Marek Vasut <marex@denx.de> wrote:
>
> Wait for the read/write transfer finish bit get actually cleared,
> this does not happen immediately on at least SoCFPGA Gen5.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
> Cc: Vignesh R <vigneshr@ti.com>
> Cc: Pratyush Yadav <p.yadav@ti.com>
> ---
>  drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> index 429ee335db6..2cdf4c9c9f8 100644
> --- a/drivers/spi/cadence_qspi_apb.c
> +++ b/drivers/spi/cadence_qspi_apb.c
> @@ -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;
> +       }
> +

Does this patch to be part of the release?

Jagan.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-12-02  5:48 ` Jagan Teki
@ 2021-12-02  5:50   ` Marek Vasut
  2021-12-02  5:52     ` Jagan Teki
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-12-02  5:50 UTC (permalink / raw)
  To: Jagan Teki; +Cc: u-boot, Vignesh R, Pratyush Yadav

On 12/2/21 06:48, Jagan Teki wrote:
> Hi Marek,
> 
> On Tue, Sep 14, 2021 at 8:52 AM Marek Vasut <marex@denx.de> wrote:
>>
>> Wait for the read/write transfer finish bit get actually cleared,
>> this does not happen immediately on at least SoCFPGA Gen5.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Jagan Teki <jagan@amarulasolutions.com>
>> Cc: Vignesh R <vigneshr@ti.com>
>> Cc: Pratyush Yadav <p.yadav@ti.com>
>> ---
>>   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
>> index 429ee335db6..2cdf4c9c9f8 100644
>> --- a/drivers/spi/cadence_qspi_apb.c
>> +++ b/drivers/spi/cadence_qspi_apb.c
>> @@ -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;
>> +       }
>> +
> 
> 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.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-12-02  5:50   ` Marek Vasut
@ 2021-12-02  5:52     ` Jagan Teki
  0 siblings, 0 replies; 13+ messages in thread
From: Jagan Teki @ 2021-12-02  5:52 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Vignesh R, Pratyush Yadav

On Thu, Dec 2, 2021 at 11:20 AM Marek Vasut <marex@denx.de> wrote:
>
> On 12/2/21 06:48, Jagan Teki wrote:
> > Hi Marek,
> >
> > On Tue, Sep 14, 2021 at 8:52 AM Marek Vasut <marex@denx.de> wrote:
> >>
> >> Wait for the read/write transfer finish bit get actually cleared,
> >> this does not happen immediately on at least SoCFPGA Gen5.
> >>
> >> Signed-off-by: Marek Vasut <marex@denx.de>
> >> Cc: Jagan Teki <jagan@amarulasolutions.com>
> >> Cc: Vignesh R <vigneshr@ti.com>
> >> Cc: Pratyush Yadav <p.yadav@ti.com>
> >> ---
> >>   drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
> >>   1 file changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> >> index 429ee335db6..2cdf4c9c9f8 100644
> >> --- a/drivers/spi/cadence_qspi_apb.c
> >> +++ b/drivers/spi/cadence_qspi_apb.c
> >> @@ -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;
> >> +       }
> >> +
> >
> > 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.

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

Thanks,
Jagan.

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

* Re: [PATCH] mtd: cqspi: Wait for transfer completion
  2021-10-25 20:25             ` Marek Vasut
@ 2021-12-02  9:01               ` Pratyush Yadav
  0 siblings, 0 replies; 13+ messages in thread
From: Pratyush Yadav @ 2021-12-02  9:01 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Jagan Teki, U-Boot-Denx, Vignesh R

Hi Marek,

On 25/10/21 10:25PM, Marek Vasut wrote:
> On 10/25/21 9:53 PM, Pratyush Yadav wrote:
> > On 08/10/21 06:06PM, Jagan Teki wrote:
> > > On Wed, Sep 15, 2021 at 2:05 PM Marek Vasut <marex@denx.de> wrote:
> > > > 
> > > > On 9/15/21 10:28 AM, Pratyush Yadav wrote:
> > > > > On 14/09/21 08:22PM, Marek Vasut wrote:
> > > > > > On 9/14/21 7:42 PM, Pratyush Yadav wrote:
> > > > > > > On 14/09/21 05:22AM, Marek Vasut wrote:
> > > > > > > > Wait for the read/write transfer finish bit get actually cleared,
> > > > > > > > this does not happen immediately on at least SoCFPGA Gen5.
> > > > > > > > 
> > > > > > > > Signed-off-by: Marek Vasut <marex@denx.de>
> > > > > > > > Cc: Jagan Teki <jagan@amarulasolutions.com>
> > > > > > > > Cc: Vignesh R <vigneshr@ti.com>
> > > > > > > > Cc: Pratyush Yadav <p.yadav@ti.com>
> > > > > > > > ---
> > > > > > > >     drivers/spi/cadence_qspi_apb.c | 17 +++++++++++++++++
> > > > > > > >     1 file changed, 17 insertions(+)
> > > > > > > > 
> > > > > > > > diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
> > > > > > > > index 429ee335db6..2cdf4c9c9f8 100644
> > > > > > > > --- a/drivers/spi/cadence_qspi_apb.c
> > > > > > > > +++ b/drivers/spi/cadence_qspi_apb.c
> > > > > > > > @@ -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;
> > > > > > > > +  }
> > > > > > > > +
> > > > > > > 
> > > > > > > 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.
> > > > > 
> > > > > 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.
> > > 
> > > 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.

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

end of thread, other threads:[~2021-12-02  9:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14  3:22 [PATCH] mtd: cqspi: Wait for transfer completion Marek Vasut
2021-09-14 17:42 ` Pratyush Yadav
2021-09-14 18:22   ` Marek Vasut
2021-09-15  8:28     ` Pratyush Yadav
2021-09-15  8:35       ` Marek Vasut
2021-10-08 12:36         ` Jagan Teki
2021-10-25 19:53           ` Pratyush Yadav
2021-10-25 20:25             ` Marek Vasut
2021-12-02  9:01               ` Pratyush Yadav
2021-11-01  7:07             ` Jagan Teki
2021-12-02  5:48 ` Jagan Teki
2021-12-02  5:50   ` Marek Vasut
2021-12-02  5:52     ` Jagan Teki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.