All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
@ 2021-06-20 22:49 Marek Vasut
  2021-06-21 12:14 ` Lucas Stach
  2021-06-22 14:04 ` Jagan Teki
  0 siblings, 2 replies; 13+ messages in thread
From: Marek Vasut @ 2021-06-20 22:49 UTC (permalink / raw)
  To: dri-devel; +Cc: Marek Vasut, ch, Emil Velikov, Daniel Abrecht, Laurent Pinchart

Make sure the FIFO_CLEAR bit is latched in when configuring the
controller, so that the FIFO is really cleared. And then clear
the FIFO_CLEAR bit, since it is not self-clearing.

Fixes: 45d59d704080 ("drm: Add new driver for MXSFB controller")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Daniel Abrecht <public@danielabrecht.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Stefan Agner <stefan@agner.ch>
---
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 98d8ba0bae84..22cb749fc9bc 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
 
 	/* Clear the FIFOs */
 	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
+	readl(mxsfb->base + LCDC_CTRL1);
+	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_CLR);
+	readl(mxsfb->base + LCDC_CTRL1);
 
 	if (mxsfb->devdata->has_overlay)
 		writel(0, mxsfb->base + LCDC_AS_CTRL);
-- 
2.30.2


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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-20 22:49 [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit Marek Vasut
@ 2021-06-21 12:14 ` Lucas Stach
  2021-06-21 16:30   ` Marek Vasut
  2021-06-22 14:04 ` Jagan Teki
  1 sibling, 1 reply; 13+ messages in thread
From: Lucas Stach @ 2021-06-21 12:14 UTC (permalink / raw)
  To: Marek Vasut, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

Am Montag, dem 21.06.2021 um 00:49 +0200 schrieb Marek Vasut:
> Make sure the FIFO_CLEAR bit is latched in when configuring the
> controller, so that the FIFO is really cleared. And then clear
> the FIFO_CLEAR bit, since it is not self-clearing.
> 
> Fixes: 45d59d704080 ("drm: Add new driver for MXSFB controller")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Daniel Abrecht <public@danielabrecht.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Stefan Agner <stefan@agner.ch>
> ---
>  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> index 98d8ba0bae84..22cb749fc9bc 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
>  
>  	/* Clear the FIFOs */
>  	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
> +	readl(mxsfb->base + LCDC_CTRL1);

Do you really need those readbacks? As both writes are targeting the
same slave interface, the memory barrier in the clear write should push
the set write.

> +	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> +	readl(mxsfb->base + LCDC_CTRL1);
>  
>  	if (mxsfb->devdata->has_overlay)
>  		writel(0, mxsfb->base + LCDC_AS_CTRL);



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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-21 12:14 ` Lucas Stach
@ 2021-06-21 16:30   ` Marek Vasut
  2021-06-22  7:28     ` Lucas Stach
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-06-21 16:30 UTC (permalink / raw)
  To: Lucas Stach, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

On 6/21/21 2:14 PM, Lucas Stach wrote:

[...]

>> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>> index 98d8ba0bae84..22cb749fc9bc 100644
>> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>> @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
>>   
>>   	/* Clear the FIFOs */
>>   	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
>> +	readl(mxsfb->base + LCDC_CTRL1);
> 
> Do you really need those readbacks? As both writes are targeting the
> same slave interface, the memory barrier in the clear write should push
> the set write.

What would push the clear write then ? We can drop one of the readl()s, 
but not the last one.

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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-21 16:30   ` Marek Vasut
@ 2021-06-22  7:28     ` Lucas Stach
  2021-06-22  9:33       ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Lucas Stach @ 2021-06-22  7:28 UTC (permalink / raw)
  To: Marek Vasut, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
> On 6/21/21 2:14 PM, Lucas Stach wrote:
> 
> [...]
> 
> > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > index 98d8ba0bae84..22cb749fc9bc 100644
> > > --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
> > >   
> > >   	/* Clear the FIFOs */
> > >   	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
> > > +	readl(mxsfb->base + LCDC_CTRL1);
> > 
> > Do you really need those readbacks? As both writes are targeting the
> > same slave interface, the memory barrier in the clear write should push
> > the set write.
> 
> What would push the clear write then ? We can drop one of the readl()s, 
> but not the last one.

There are a lot of more writes with barriers to the controller slave
interface in that function after clearing the FIFO. I don't see why
this readback would be required.

Regards,
Lucas


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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-22  7:28     ` Lucas Stach
@ 2021-06-22  9:33       ` Marek Vasut
  2021-06-24 12:01         ` Lucas Stach
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-06-22  9:33 UTC (permalink / raw)
  To: Lucas Stach, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

On 6/22/21 9:28 AM, Lucas Stach wrote:
> Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
>> On 6/21/21 2:14 PM, Lucas Stach wrote:
>>
>> [...]
>>
>>>> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>> index 98d8ba0bae84..22cb749fc9bc 100644
>>>> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>> @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
>>>>    
>>>>    	/* Clear the FIFOs */
>>>>    	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
>>>> +	readl(mxsfb->base + LCDC_CTRL1);
>>>
>>> Do you really need those readbacks? As both writes are targeting the
>>> same slave interface, the memory barrier in the clear write should push
>>> the set write.
>>
>> What would push the clear write then ? We can drop one of the readl()s,
>> but not the last one.
> 
> There are a lot of more writes with barriers to the controller slave
> interface in that function after clearing the FIFO. I don't see why
> this readback would be required.

Because you really do want to make sure the fifo is cleared before you 
start doing any of those other writes or configuring the controller in 
any way.

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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-20 22:49 [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit Marek Vasut
  2021-06-21 12:14 ` Lucas Stach
@ 2021-06-22 14:04 ` Jagan Teki
  1 sibling, 0 replies; 13+ messages in thread
From: Jagan Teki @ 2021-06-22 14:04 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Daniel Abrecht, Emil Velikov, Claudius Heine, dri-devel,
	Laurent Pinchart

On Mon, Jun 21, 2021 at 4:19 AM Marek Vasut <marex@denx.de> wrote:
>
> Make sure the FIFO_CLEAR bit is latched in when configuring the
> controller, so that the FIFO is really cleared. And then clear
> the FIFO_CLEAR bit, since it is not self-clearing.
>
> Fixes: 45d59d704080 ("drm: Add new driver for MXSFB controller")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Daniel Abrecht <public@danielabrecht.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Stefan Agner <stefan@agner.ch>
> ---

Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Tested-by: Jagan Teki <jagan@amarulasolutions.com> # i.Core MX8MM

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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-22  9:33       ` Marek Vasut
@ 2021-06-24 12:01         ` Lucas Stach
  2021-06-26 18:15           ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Lucas Stach @ 2021-06-24 12:01 UTC (permalink / raw)
  To: Marek Vasut, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
> On 6/22/21 9:28 AM, Lucas Stach wrote:
> > Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
> > > On 6/21/21 2:14 PM, Lucas Stach wrote:
> > > 
> > > [...]
> > > 
> > > > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > index 98d8ba0bae84..22cb749fc9bc 100644
> > > > > --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
> > > > >    
> > > > >    	/* Clear the FIFOs */
> > > > >    	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
> > > > > +	readl(mxsfb->base + LCDC_CTRL1);
> > > > 
> > > > Do you really need those readbacks? As both writes are targeting the
> > > > same slave interface, the memory barrier in the clear write should push
> > > > the set write.
> > > 
> > > What would push the clear write then ? We can drop one of the readl()s,
> > > but not the last one.
> > 
> > There are a lot of more writes with barriers to the controller slave
> > interface in that function after clearing the FIFO. I don't see why
> > this readback would be required.
> 
> Because you really do want to make sure the fifo is cleared before you 
> start doing any of those other writes or configuring the controller in 
> any way.

I still don't see the reason. What additional properties do you think
the readback provides that isn't already provided by the barriers in
the following writes?

Regards,
Lucas


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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-24 12:01         ` Lucas Stach
@ 2021-06-26 18:15           ` Marek Vasut
  2021-06-28  8:09             ` Lucas Stach
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-06-26 18:15 UTC (permalink / raw)
  To: Lucas Stach, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

On 6/24/21 2:01 PM, Lucas Stach wrote:
> Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
>> On 6/22/21 9:28 AM, Lucas Stach wrote:
>>> Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
>>>> On 6/21/21 2:14 PM, Lucas Stach wrote:
>>>>
>>>> [...]
>>>>
>>>>>> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>> index 98d8ba0bae84..22cb749fc9bc 100644
>>>>>> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>> @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
>>>>>>     
>>>>>>     	/* Clear the FIFOs */
>>>>>>     	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
>>>>>> +	readl(mxsfb->base + LCDC_CTRL1);
>>>>>
>>>>> Do you really need those readbacks? As both writes are targeting the
>>>>> same slave interface, the memory barrier in the clear write should push
>>>>> the set write.
>>>>
>>>> What would push the clear write then ? We can drop one of the readl()s,
>>>> but not the last one.
>>>
>>> There are a lot of more writes with barriers to the controller slave
>>> interface in that function after clearing the FIFO. I don't see why
>>> this readback would be required.
>>
>> Because you really do want to make sure the fifo is cleared before you
>> start doing any of those other writes or configuring the controller in
>> any way.
> 
> I still don't see the reason. What additional properties do you think
> the readback provides that isn't already provided by the barriers in
> the following writes?

See the paragraph above -- we have to make sure the writes that trigger 
the FIFO clearing really take place before any other writes do.

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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-26 18:15           ` Marek Vasut
@ 2021-06-28  8:09             ` Lucas Stach
  2021-06-29  3:04               ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Lucas Stach @ 2021-06-28  8:09 UTC (permalink / raw)
  To: Marek Vasut, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

Am Samstag, dem 26.06.2021 um 20:15 +0200 schrieb Marek Vasut:
> On 6/24/21 2:01 PM, Lucas Stach wrote:
> > Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
> > > On 6/22/21 9:28 AM, Lucas Stach wrote:
> > > > Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
> > > > > On 6/21/21 2:14 PM, Lucas Stach wrote:
> > > > > 
> > > > > [...]
> > > > > 
> > > > > > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > index 98d8ba0bae84..22cb749fc9bc 100644
> > > > > > > --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
> > > > > > >     
> > > > > > >     	/* Clear the FIFOs */
> > > > > > >     	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
> > > > > > > +	readl(mxsfb->base + LCDC_CTRL1);
> > > > > > 
> > > > > > Do you really need those readbacks? As both writes are targeting the
> > > > > > same slave interface, the memory barrier in the clear write should push
> > > > > > the set write.
> > > > > 
> > > > > What would push the clear write then ? We can drop one of the readl()s,
> > > > > but not the last one.
> > > > 
> > > > There are a lot of more writes with barriers to the controller slave
> > > > interface in that function after clearing the FIFO. I don't see why
> > > > this readback would be required.
> > > 
> > > Because you really do want to make sure the fifo is cleared before you
> > > start doing any of those other writes or configuring the controller in
> > > any way.
> > 
> > I still don't see the reason. What additional properties do you think
> > the readback provides that isn't already provided by the barriers in
> > the following writes?
> 
> See the paragraph above -- we have to make sure the writes that trigger 
> the FIFO clearing really take place before any other writes do.

And they do, as there are write barriers prepended to the writes
following the FIFO clear. The readback just lets the CPU wait until the
write reached the peripheral, which I don't see a reason to do here.
The ordering of the writes from the perspective of the peripheral is
completely the same with or without the readback. The later writes can
not overtake the FIFO clear writes due to the barriers.

I'm strongly against adding stuff because it "might have an effect", if
it isn't required by architectural rules. It clutters the code and some
months/years down the line nobody dares to cleanup/remove this stuff
anymore, because everyone assumes that there was a good reason for
adding those things.

Regards,
Lucas


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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-28  8:09             ` Lucas Stach
@ 2021-06-29  3:04               ` Marek Vasut
  2021-06-29  8:02                 ` Lucas Stach
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-06-29  3:04 UTC (permalink / raw)
  To: Lucas Stach, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

On 6/28/21 10:09 AM, Lucas Stach wrote:
> Am Samstag, dem 26.06.2021 um 20:15 +0200 schrieb Marek Vasut:
>> On 6/24/21 2:01 PM, Lucas Stach wrote:
>>> Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
>>>> On 6/22/21 9:28 AM, Lucas Stach wrote:
>>>>> Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
>>>>>> On 6/21/21 2:14 PM, Lucas Stach wrote:
>>>>>>
>>>>>> [...]
>>>>>>
>>>>>>>> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>>>> index 98d8ba0bae84..22cb749fc9bc 100644
>>>>>>>> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>>>> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>>>> @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
>>>>>>>>      
>>>>>>>>      	/* Clear the FIFOs */
>>>>>>>>      	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
>>>>>>>> +	readl(mxsfb->base + LCDC_CTRL1);
>>>>>>>
>>>>>>> Do you really need those readbacks? As both writes are targeting the
>>>>>>> same slave interface, the memory barrier in the clear write should push
>>>>>>> the set write.
>>>>>>
>>>>>> What would push the clear write then ? We can drop one of the readl()s,
>>>>>> but not the last one.
>>>>>
>>>>> There are a lot of more writes with barriers to the controller slave
>>>>> interface in that function after clearing the FIFO. I don't see why
>>>>> this readback would be required.
>>>>
>>>> Because you really do want to make sure the fifo is cleared before you
>>>> start doing any of those other writes or configuring the controller in
>>>> any way.
>>>
>>> I still don't see the reason. What additional properties do you think
>>> the readback provides that isn't already provided by the barriers in
>>> the following writes?
>>
>> See the paragraph above -- we have to make sure the writes that trigger
>> the FIFO clearing really take place before any other writes do.
> 
> And they do, as there are write barriers prepended to the writes
> following the FIFO clear. The readback just lets the CPU wait until the
> write reached the peripheral, which I don't see a reason to do here.
> The ordering of the writes from the perspective of the peripheral is
> completely the same with or without the readback. The later writes can
> not overtake the FIFO clear writes due to the barriers.
> 
> I'm strongly against adding stuff because it "might have an effect", if
> it isn't required by architectural rules. It clutters the code and some
> months/years down the line nobody dares to cleanup/remove this stuff
> anymore, because everyone assumes that there was a good reason for
> adding those things.

Since there is no RTL for any of the iMXes or their IPs, how do you 
propose anyone except NXP can validate what is and what is not required ?

This patch helps with a problem where I sporadically observe shifted 
image on boot on mx8mm.

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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-29  3:04               ` Marek Vasut
@ 2021-06-29  8:02                 ` Lucas Stach
  2021-06-30 22:50                   ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Lucas Stach @ 2021-06-29  8:02 UTC (permalink / raw)
  To: Marek Vasut, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

Am Dienstag, dem 29.06.2021 um 05:04 +0200 schrieb Marek Vasut:
> On 6/28/21 10:09 AM, Lucas Stach wrote:
> > Am Samstag, dem 26.06.2021 um 20:15 +0200 schrieb Marek Vasut:
> > > On 6/24/21 2:01 PM, Lucas Stach wrote:
> > > > Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
> > > > > On 6/22/21 9:28 AM, Lucas Stach wrote:
> > > > > > Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
> > > > > > > On 6/21/21 2:14 PM, Lucas Stach wrote:
> > > > > > > 
> > > > > > > [...]
> > > > > > > 
> > > > > > > > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > > > index 98d8ba0bae84..22cb749fc9bc 100644
> > > > > > > > > --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > > > +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > > > @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
> > > > > > > > >      
> > > > > > > > >      	/* Clear the FIFOs */
> > > > > > > > >      	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
> > > > > > > > > +	readl(mxsfb->base + LCDC_CTRL1);
> > > > > > > > 
> > > > > > > > Do you really need those readbacks? As both writes are targeting the
> > > > > > > > same slave interface, the memory barrier in the clear write should push
> > > > > > > > the set write.
> > > > > > > 
> > > > > > > What would push the clear write then ? We can drop one of the readl()s,
> > > > > > > but not the last one.
> > > > > > 
> > > > > > There are a lot of more writes with barriers to the controller slave
> > > > > > interface in that function after clearing the FIFO. I don't see why
> > > > > > this readback would be required.
> > > > > 
> > > > > Because you really do want to make sure the fifo is cleared before you
> > > > > start doing any of those other writes or configuring the controller in
> > > > > any way.
> > > > 
> > > > I still don't see the reason. What additional properties do you think
> > > > the readback provides that isn't already provided by the barriers in
> > > > the following writes?
> > > 
> > > See the paragraph above -- we have to make sure the writes that trigger
> > > the FIFO clearing really take place before any other writes do.
> > 
> > And they do, as there are write barriers prepended to the writes
> > following the FIFO clear. The readback just lets the CPU wait until the
> > write reached the peripheral, which I don't see a reason to do here.
> > The ordering of the writes from the perspective of the peripheral is
> > completely the same with or without the readback. The later writes can
> > not overtake the FIFO clear writes due to the barriers.
> > 
> > I'm strongly against adding stuff because it "might have an effect", if
> > it isn't required by architectural rules. It clutters the code and some
> > months/years down the line nobody dares to cleanup/remove this stuff
> > anymore, because everyone assumes that there was a good reason for
> > adding those things.
> 
> Since there is no RTL for any of the iMXes or their IPs, how do you 
> propose anyone except NXP can validate what is and what is not required ?
> 
> This patch helps with a problem where I sporadically observe shifted 
> image on boot on mx8mm.

The order of writes to a device mapped region are defined by the ARM
architecture and the AMBA bus standard, not the peripheral. I'm not
saying this patch isn't needed. I'm saying the readbacks look bogus.

Have you checked that just adding the write to the REG_CLR doesn't fix
your issue?

Regards,
Lucas


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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-29  8:02                 ` Lucas Stach
@ 2021-06-30 22:50                   ` Marek Vasut
  2021-07-14 14:28                     ` Lucas Stach
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2021-06-30 22:50 UTC (permalink / raw)
  To: Lucas Stach, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

On 6/29/21 10:02 AM, Lucas Stach wrote:
> Am Dienstag, dem 29.06.2021 um 05:04 +0200 schrieb Marek Vasut:
>> On 6/28/21 10:09 AM, Lucas Stach wrote:
>>> Am Samstag, dem 26.06.2021 um 20:15 +0200 schrieb Marek Vasut:
>>>> On 6/24/21 2:01 PM, Lucas Stach wrote:
>>>>> Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
>>>>>> On 6/22/21 9:28 AM, Lucas Stach wrote:
>>>>>>> Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
>>>>>>>> On 6/21/21 2:14 PM, Lucas Stach wrote:
>>>>>>>>
>>>>>>>> [...]
>>>>>>>>
>>>>>>>>>> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>>>>>> index 98d8ba0bae84..22cb749fc9bc 100644
>>>>>>>>>> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>>>>>> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
>>>>>>>>>> @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
>>>>>>>>>>       
>>>>>>>>>>       	/* Clear the FIFOs */
>>>>>>>>>>       	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
>>>>>>>>>> +	readl(mxsfb->base + LCDC_CTRL1);
>>>>>>>>>
>>>>>>>>> Do you really need those readbacks? As both writes are targeting the
>>>>>>>>> same slave interface, the memory barrier in the clear write should push
>>>>>>>>> the set write.
>>>>>>>>
>>>>>>>> What would push the clear write then ? We can drop one of the readl()s,
>>>>>>>> but not the last one.
>>>>>>>
>>>>>>> There are a lot of more writes with barriers to the controller slave
>>>>>>> interface in that function after clearing the FIFO. I don't see why
>>>>>>> this readback would be required.
>>>>>>
>>>>>> Because you really do want to make sure the fifo is cleared before you
>>>>>> start doing any of those other writes or configuring the controller in
>>>>>> any way.
>>>>>
>>>>> I still don't see the reason. What additional properties do you think
>>>>> the readback provides that isn't already provided by the barriers in
>>>>> the following writes?
>>>>
>>>> See the paragraph above -- we have to make sure the writes that trigger
>>>> the FIFO clearing really take place before any other writes do.
>>>
>>> And they do, as there are write barriers prepended to the writes
>>> following the FIFO clear. The readback just lets the CPU wait until the
>>> write reached the peripheral, which I don't see a reason to do here.
>>> The ordering of the writes from the perspective of the peripheral is
>>> completely the same with or without the readback. The later writes can
>>> not overtake the FIFO clear writes due to the barriers.
>>>
>>> I'm strongly against adding stuff because it "might have an effect", if
>>> it isn't required by architectural rules. It clutters the code and some
>>> months/years down the line nobody dares to cleanup/remove this stuff
>>> anymore, because everyone assumes that there was a good reason for
>>> adding those things.
>>
>> Since there is no RTL for any of the iMXes or their IPs, how do you
>> propose anyone except NXP can validate what is and what is not required ?
>>
>> This patch helps with a problem where I sporadically observe shifted
>> image on boot on mx8mm.
> 
> The order of writes to a device mapped region are defined by the ARM
> architecture and the AMBA bus standard, not the peripheral. I'm not
> saying this patch isn't needed. I'm saying the readbacks look bogus.
> 
> Have you checked that just adding the write to the REG_CLR doesn't fix
> your issue?

No, it does not help with the issue.

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

* Re: [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit
  2021-06-30 22:50                   ` Marek Vasut
@ 2021-07-14 14:28                     ` Lucas Stach
  0 siblings, 0 replies; 13+ messages in thread
From: Lucas Stach @ 2021-07-14 14:28 UTC (permalink / raw)
  To: Marek Vasut, dri-devel; +Cc: Daniel Abrecht, Emil Velikov, ch, Laurent Pinchart

Am Donnerstag, dem 01.07.2021 um 00:50 +0200 schrieb Marek Vasut:
> On 6/29/21 10:02 AM, Lucas Stach wrote:
> > Am Dienstag, dem 29.06.2021 um 05:04 +0200 schrieb Marek Vasut:
> > > On 6/28/21 10:09 AM, Lucas Stach wrote:
> > > > Am Samstag, dem 26.06.2021 um 20:15 +0200 schrieb Marek Vasut:
> > > > > On 6/24/21 2:01 PM, Lucas Stach wrote:
> > > > > > Am Dienstag, dem 22.06.2021 um 11:33 +0200 schrieb Marek Vasut:
> > > > > > > On 6/22/21 9:28 AM, Lucas Stach wrote:
> > > > > > > > Am Montag, dem 21.06.2021 um 18:30 +0200 schrieb Marek Vasut:
> > > > > > > > > On 6/21/21 2:14 PM, Lucas Stach wrote:
> > > > > > > > > 
> > > > > > > > > [...]
> > > > > > > > > 
> > > > > > > > > > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > > > > > index 98d8ba0bae84..22cb749fc9bc 100644
> > > > > > > > > > > --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > > > > > +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> > > > > > > > > > > @@ -241,6 +241,9 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
> > > > > > > > > > >       
> > > > > > > > > > >       	/* Clear the FIFOs */
> > > > > > > > > > >       	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
> > > > > > > > > > > +	readl(mxsfb->base + LCDC_CTRL1);
> > > > > > > > > > 
> > > > > > > > > > Do you really need those readbacks? As both writes are targeting the
> > > > > > > > > > same slave interface, the memory barrier in the clear write should push
> > > > > > > > > > the set write.
> > > > > > > > > 
> > > > > > > > > What would push the clear write then ? We can drop one of the readl()s,
> > > > > > > > > but not the last one.
> > > > > > > > 
> > > > > > > > There are a lot of more writes with barriers to the controller slave
> > > > > > > > interface in that function after clearing the FIFO. I don't see why
> > > > > > > > this readback would be required.
> > > > > > > 
> > > > > > > Because you really do want to make sure the fifo is cleared before you
> > > > > > > start doing any of those other writes or configuring the controller in
> > > > > > > any way.
> > > > > > 
> > > > > > I still don't see the reason. What additional properties do you think
> > > > > > the readback provides that isn't already provided by the barriers in
> > > > > > the following writes?
> > > > > 
> > > > > See the paragraph above -- we have to make sure the writes that trigger
> > > > > the FIFO clearing really take place before any other writes do.
> > > > 
> > > > And they do, as there are write barriers prepended to the writes
> > > > following the FIFO clear. The readback just lets the CPU wait until the
> > > > write reached the peripheral, which I don't see a reason to do here.
> > > > The ordering of the writes from the perspective of the peripheral is
> > > > completely the same with or without the readback. The later writes can
> > > > not overtake the FIFO clear writes due to the barriers.
> > > > 
> > > > I'm strongly against adding stuff because it "might have an effect", if
> > > > it isn't required by architectural rules. It clutters the code and some
> > > > months/years down the line nobody dares to cleanup/remove this stuff
> > > > anymore, because everyone assumes that there was a good reason for
> > > > adding those things.
> > > 
> > > Since there is no RTL for any of the iMXes or their IPs, how do you
> > > propose anyone except NXP can validate what is and what is not required ?
> > > 
> > > This patch helps with a problem where I sporadically observe shifted
> > > image on boot on mx8mm.
> > 
> > The order of writes to a device mapped region are defined by the ARM
> > architecture and the AMBA bus standard, not the peripheral. I'm not
> > saying this patch isn't needed. I'm saying the readbacks look bogus.
> > 
> > Have you checked that just adding the write to the REG_CLR doesn't fix
> > your issue?
> 
> No, it does not help with the issue.

Okay, i don't want to hold up this patch over technicalities if it
fixes the issue, in which case the readbacks probably provide just the
right amount of delay for the FIFO clear to happen in hardware. FWIW:

Acked-by: Lucas Stach <l.stach@pengutronix.de>

Regards,
Lucas


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

end of thread, other threads:[~2021-07-14 14:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-20 22:49 [PATCH] drm: mxsfb: Clear FIFO_CLEAR bit Marek Vasut
2021-06-21 12:14 ` Lucas Stach
2021-06-21 16:30   ` Marek Vasut
2021-06-22  7:28     ` Lucas Stach
2021-06-22  9:33       ` Marek Vasut
2021-06-24 12:01         ` Lucas Stach
2021-06-26 18:15           ` Marek Vasut
2021-06-28  8:09             ` Lucas Stach
2021-06-29  3:04               ` Marek Vasut
2021-06-29  8:02                 ` Lucas Stach
2021-06-30 22:50                   ` Marek Vasut
2021-07-14 14:28                     ` Lucas Stach
2021-06-22 14:04 ` 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.