diff mbox series

[05/10] drm/tidss: Return error value from from softreset

Message ID 20231101-tidss-probe-v1-5-45149e0f9415@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series drm/tidss: Probe related fixes and cleanups | expand

Commit Message

Tomi Valkeinen Nov. 1, 2023, 9:17 a.m. UTC
Return an error value from dispc_softreset() so that the caller can
handle the errors.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/tidss/tidss_dispc.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Comments

Laurent Pinchart Nov. 1, 2023, 1:59 p.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Wed, Nov 01, 2023 at 11:17:42AM +0200, Tomi Valkeinen wrote:
> Return an error value from dispc_softreset() so that the caller can
> handle the errors.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/gpu/drm/tidss/tidss_dispc.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c
> index 9430625e2d62..cdbb88289082 100644
> --- a/drivers/gpu/drm/tidss/tidss_dispc.c
> +++ b/drivers/gpu/drm/tidss/tidss_dispc.c
> @@ -2702,7 +2702,7 @@ static void dispc_init_errata(struct dispc_device *dispc)
>  	}
>  }
>  
> -static void dispc_softreset(struct dispc_device *dispc)
> +static int dispc_softreset(struct dispc_device *dispc)
>  {
>  	u32 val;
>  	int ret;
> @@ -2712,8 +2712,12 @@ static void dispc_softreset(struct dispc_device *dispc)
>  	/* Wait for reset to complete */
>  	ret = readl_poll_timeout(dispc->base_common + DSS_SYSSTATUS,
>  				 val, val & 1, 100, 5000);
> -	if (ret)
> -		dev_warn(dispc->dev, "failed to reset dispc\n");
> +	if (ret) {
> +		dev_err(dispc->dev, "failed to reset dispc\n");
> +		return ret;
> +	}
> +
> +	return 0;
>  }
>  
>  int dispc_init(struct tidss_device *tidss)
> @@ -2828,8 +2832,11 @@ int dispc_init(struct tidss_device *tidss)
>  	tidss->dispc = dispc;
>  
>  	/* K2G display controller does not support soft reset */
> -	if (feat->subrev != DISPC_K2G)
> -		dispc_softreset(dispc);
> +	if (feat->subrev != DISPC_K2G) {
> +		r = dispc_softreset(dispc);
> +		if (r)
> +			return r;

tidss->dispc will be set in this case. Could that cause problems ?

> +	}
>  
>  	return 0;
>  }
>
Tomi Valkeinen Nov. 2, 2023, 6:44 a.m. UTC | #2
On 01/11/2023 15:59, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Wed, Nov 01, 2023 at 11:17:42AM +0200, Tomi Valkeinen wrote:
>> Return an error value from dispc_softreset() so that the caller can
>> handle the errors.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> ---
>>   drivers/gpu/drm/tidss/tidss_dispc.c | 17 ++++++++++++-----
>>   1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c
>> index 9430625e2d62..cdbb88289082 100644
>> --- a/drivers/gpu/drm/tidss/tidss_dispc.c
>> +++ b/drivers/gpu/drm/tidss/tidss_dispc.c
>> @@ -2702,7 +2702,7 @@ static void dispc_init_errata(struct dispc_device *dispc)
>>   	}
>>   }
>>   
>> -static void dispc_softreset(struct dispc_device *dispc)
>> +static int dispc_softreset(struct dispc_device *dispc)
>>   {
>>   	u32 val;
>>   	int ret;
>> @@ -2712,8 +2712,12 @@ static void dispc_softreset(struct dispc_device *dispc)
>>   	/* Wait for reset to complete */
>>   	ret = readl_poll_timeout(dispc->base_common + DSS_SYSSTATUS,
>>   				 val, val & 1, 100, 5000);
>> -	if (ret)
>> -		dev_warn(dispc->dev, "failed to reset dispc\n");
>> +	if (ret) {
>> +		dev_err(dispc->dev, "failed to reset dispc\n");
>> +		return ret;
>> +	}
>> +
>> +	return 0;
>>   }
>>   
>>   int dispc_init(struct tidss_device *tidss)
>> @@ -2828,8 +2832,11 @@ int dispc_init(struct tidss_device *tidss)
>>   	tidss->dispc = dispc;
>>   
>>   	/* K2G display controller does not support soft reset */
>> -	if (feat->subrev != DISPC_K2G)
>> -		dispc_softreset(dispc);
>> +	if (feat->subrev != DISPC_K2G) {
>> +		r = dispc_softreset(dispc);
>> +		if (r)
>> +			return r;
> 
> tidss->dispc will be set in this case. Could that cause problems ?

Not at the moment, but better be safe. I'll move the reset a few lines 
higher.

  Tomi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c
index 9430625e2d62..cdbb88289082 100644
--- a/drivers/gpu/drm/tidss/tidss_dispc.c
+++ b/drivers/gpu/drm/tidss/tidss_dispc.c
@@ -2702,7 +2702,7 @@  static void dispc_init_errata(struct dispc_device *dispc)
 	}
 }
 
-static void dispc_softreset(struct dispc_device *dispc)
+static int dispc_softreset(struct dispc_device *dispc)
 {
 	u32 val;
 	int ret;
@@ -2712,8 +2712,12 @@  static void dispc_softreset(struct dispc_device *dispc)
 	/* Wait for reset to complete */
 	ret = readl_poll_timeout(dispc->base_common + DSS_SYSSTATUS,
 				 val, val & 1, 100, 5000);
-	if (ret)
-		dev_warn(dispc->dev, "failed to reset dispc\n");
+	if (ret) {
+		dev_err(dispc->dev, "failed to reset dispc\n");
+		return ret;
+	}
+
+	return 0;
 }
 
 int dispc_init(struct tidss_device *tidss)
@@ -2828,8 +2832,11 @@  int dispc_init(struct tidss_device *tidss)
 	tidss->dispc = dispc;
 
 	/* K2G display controller does not support soft reset */
-	if (feat->subrev != DISPC_K2G)
-		dispc_softreset(dispc);
+	if (feat->subrev != DISPC_K2G) {
+		r = dispc_softreset(dispc);
+		if (r)
+			return r;
+	}
 
 	return 0;
 }