diff mbox

[v2,01/10] drm/exynos/decon5433: use readl_poll_timeout helpers

Message ID 1503581639-580-2-git-send-email-a.hajda@samsung.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andrzej Hajda Aug. 24, 2017, 1:33 p.m. UTC
Linux core provide helpers for polling with timeout, lets use them.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Comments

Tobias Jakobi Aug. 24, 2017, 1:54 p.m. UTC | #1
Hello Andrzej,


Andrzej Hajda wrote:
> Linux core provide helpers for polling with timeout, lets use them.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> index 5792ca88..237b4c9 100644
> --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> @@ -13,6 +13,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
>  #include <linux/component.h>
> +#include <linux/iopoll.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/of_device.h>
>  #include <linux/of_gpio.h>
> @@ -407,24 +408,19 @@ static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
>  
>  static void decon_swreset(struct decon_context *ctx)
>  {
> -	unsigned int tries;
>  	unsigned long flags;
> +	u32 val;
> +	int ret;
>  
>  	writel(0, ctx->addr + DECON_VIDCON0);
> -	for (tries = 2000; tries; --tries) {
> -		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_STOP_STATUS)
> -			break;
> -		udelay(10);
> -	}
> +	readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
> +			   ~val & VIDCON0_STOP_STATUS, 12, 20000);
Wouldn't it be more consistent to also check for a timeout here?

With best wishes,
Tobias



>  	writel(VIDCON0_SWRESET, ctx->addr + DECON_VIDCON0);
> -	for (tries = 2000; tries; --tries) {
> -		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_SWRESET)
> -			break;
> -		udelay(10);
> -	}
> +	ret = readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
> +				 ~val & VIDCON0_SWRESET, 12, 20000);
>  
> -	WARN(tries == 0, "failed to software reset DECON\n");
> +	WARN(ret < 0, "failed to software reset DECON\n");
>  
>  	spin_lock_irqsave(&ctx->vblank_lock, flags);
>  	ctx->frame_id = 0;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrzej Hajda Aug. 24, 2017, 4:18 p.m. UTC | #2
On 24.08.2017 15:54, Tobias Jakobi wrote:
> Hello Andrzej,
>
>
> Andrzej Hajda wrote:
>> Linux core provide helpers for polling with timeout, lets use them.
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>> ---
>>  drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 20 ++++++++------------
>>  1 file changed, 8 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
>> index 5792ca88..237b4c9 100644
>> --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
>> +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
>> @@ -13,6 +13,7 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/clk.h>
>>  #include <linux/component.h>
>> +#include <linux/iopoll.h>
>>  #include <linux/mfd/syscon.h>
>>  #include <linux/of_device.h>
>>  #include <linux/of_gpio.h>
>> @@ -407,24 +408,19 @@ static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
>>  
>>  static void decon_swreset(struct decon_context *ctx)
>>  {
>> -	unsigned int tries;
>>  	unsigned long flags;
>> +	u32 val;
>> +	int ret;
>>  
>>  	writel(0, ctx->addr + DECON_VIDCON0);
>> -	for (tries = 2000; tries; --tries) {
>> -		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_STOP_STATUS)
>> -			break;
>> -		udelay(10);
>> -	}
>> +	readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
>> +			   ~val & VIDCON0_STOP_STATUS, 12, 20000);
> Wouldn't it be more consistent to also check for a timeout here?

Timeout here is not an error, ie it happens for example in interlace mode.

Regards
Andrzej

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tobias Jakobi Aug. 25, 2017, 11:25 a.m. UTC | #3
Tobias Jakobi wrote:
> Hello Andrzej,
> 
> 
> Andrzej Hajda wrote:
>> Linux core provide helpers for polling with timeout, lets use them.
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>> ---
>>  drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 20 ++++++++------------
>>  1 file changed, 8 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
>> index 5792ca88..237b4c9 100644
>> --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
>> +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
>> @@ -13,6 +13,7 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/clk.h>
>>  #include <linux/component.h>
>> +#include <linux/iopoll.h>
>>  #include <linux/mfd/syscon.h>
>>  #include <linux/of_device.h>
>>  #include <linux/of_gpio.h>
>> @@ -407,24 +408,19 @@ static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
>>  
>>  static void decon_swreset(struct decon_context *ctx)
>>  {
>> -	unsigned int tries;
>>  	unsigned long flags;
>> +	u32 val;
>> +	int ret;
>>  
>>  	writel(0, ctx->addr + DECON_VIDCON0);
>> -	for (tries = 2000; tries; --tries) {
>> -		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_STOP_STATUS)
>> -			break;
>> -		udelay(10);
>> -	}
>> +	readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
>> +			   ~val & VIDCON0_STOP_STATUS, 12, 20000);
> Wouldn't it be more consistent to also check for a timeout here?
I see! Thanks for the clarification.

- Tobias


> With best wishes,
> Tobias
> 
> 
> 
>>  	writel(VIDCON0_SWRESET, ctx->addr + DECON_VIDCON0);
>> -	for (tries = 2000; tries; --tries) {
>> -		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_SWRESET)
>> -			break;
>> -		udelay(10);
>> -	}
>> +	ret = readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
>> +				 ~val & VIDCON0_SWRESET, 12, 20000);
>>  
>> -	WARN(tries == 0, "failed to software reset DECON\n");
>> +	WARN(ret < 0, "failed to software reset DECON\n");
>>  
>>  	spin_lock_irqsave(&ctx->vblank_lock, flags);
>>  	ctx->frame_id = 0;
>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 5792ca88..237b4c9 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -13,6 +13,7 @@ 
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/component.h>
+#include <linux/iopoll.h>
 #include <linux/mfd/syscon.h>
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
@@ -407,24 +408,19 @@  static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
 
 static void decon_swreset(struct decon_context *ctx)
 {
-	unsigned int tries;
 	unsigned long flags;
+	u32 val;
+	int ret;
 
 	writel(0, ctx->addr + DECON_VIDCON0);
-	for (tries = 2000; tries; --tries) {
-		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_STOP_STATUS)
-			break;
-		udelay(10);
-	}
+	readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
+			   ~val & VIDCON0_STOP_STATUS, 12, 20000);
 
 	writel(VIDCON0_SWRESET, ctx->addr + DECON_VIDCON0);
-	for (tries = 2000; tries; --tries) {
-		if (~readl(ctx->addr + DECON_VIDCON0) & VIDCON0_SWRESET)
-			break;
-		udelay(10);
-	}
+	ret = readl_poll_timeout(ctx->addr + DECON_VIDCON0, val,
+				 ~val & VIDCON0_SWRESET, 12, 20000);
 
-	WARN(tries == 0, "failed to software reset DECON\n");
+	WARN(ret < 0, "failed to software reset DECON\n");
 
 	spin_lock_irqsave(&ctx->vblank_lock, flags);
 	ctx->frame_id = 0;