linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix error code on failure to set brightness
@ 2021-06-08  4:32 Anand K Mistry
  2021-06-08 13:59 ` Harry Wentland
  0 siblings, 1 reply; 3+ messages in thread
From: Anand K Mistry @ 2021-06-08  4:32 UTC (permalink / raw)
  To: amd-gfx
  Cc: Anand K Mistry, Alex Deucher, Aurabindo Pillai,
	Bas Nieuwenhuizen, Christian König, Daniel Vetter,
	David Airlie, Eryk Brol, Harry Wentland, Leo Li,
	Nicholas Kazlauskas, Nikola Cornij, Qingqing Zhuo,
	Rodrigo Siqueira, Wayne Lin, dri-devel, linux-kernel

The backlight_ops.update_status function is required to return a
negative error code on failure. Returning a positive code may be
interpreted as a success. This is true for the 'brightness' sysfs file,
which passes through a non-zero value as the return value of the write()
syscall. This is interpreted in user-space as a successful write of 1
character, which is obviously wrong.

It's not clear exactly what error code to use, but EINVAL should be
reasonable.

Signed-off-by: Anand K Mistry <amistry@google.com>
---

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 652cc1a0e450..ad322613390d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3431,7 +3431,7 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
 	else
 		rc = dc_link_set_backlight_level(dm->backlight_link, brightness, 0);
 
-	return rc ? 0 : 1;
+	return rc ? 0 : -EINVAL;
 }
 
 static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
-- 
2.32.0.rc1.229.g3e70b5a671-goog


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

* Re: [PATCH] drm/amd/display: Fix error code on failure to set brightness
  2021-06-08  4:32 [PATCH] drm/amd/display: Fix error code on failure to set brightness Anand K Mistry
@ 2021-06-08 13:59 ` Harry Wentland
  2021-06-09  0:55   ` Anand K. Mistry
  0 siblings, 1 reply; 3+ messages in thread
From: Harry Wentland @ 2021-06-08 13:59 UTC (permalink / raw)
  To: Anand K Mistry, amd-gfx
  Cc: Alex Deucher, Aurabindo Pillai, Bas Nieuwenhuizen,
	Christian König, Daniel Vetter, David Airlie, Eryk Brol,
	Leo Li, Nicholas Kazlauskas, Nikola Cornij, Qingqing Zhuo,
	Rodrigo Siqueira, Wayne Lin, dri-devel, linux-kernel

On 2021-06-08 12:32 a.m., Anand K Mistry wrote:
> The backlight_ops.update_status function is required to return a
> negative error code on failure. Returning a positive code may be
> interpreted as a success. This is true for the 'brightness' sysfs file,
> which passes through a non-zero value as the return value of the write()
> syscall. This is interpreted in user-space as a successful write of 1
> character, which is obviously wrong.
> 
> It's not clear exactly what error code to use, but EINVAL should be
> reasonable.
> 
> Signed-off-by: Anand K Mistry <amistry@google.com>

Thanks for your patch but this code has changed on amd-staging-drm-next.

Can you try with the latest? The new backlight_update_status will always
return 0 now.

Harry

> ---
> 
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 652cc1a0e450..ad322613390d 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3431,7 +3431,7 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
>  	else
>  		rc = dc_link_set_backlight_level(dm->backlight_link, brightness, 0);
>  
> -	return rc ? 0 : 1;
> +	return rc ? 0 : -EINVAL;
>  }
>  
>  static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
> 


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

* Re: [PATCH] drm/amd/display: Fix error code on failure to set brightness
  2021-06-08 13:59 ` Harry Wentland
@ 2021-06-09  0:55   ` Anand K. Mistry
  0 siblings, 0 replies; 3+ messages in thread
From: Anand K. Mistry @ 2021-06-09  0:55 UTC (permalink / raw)
  To: Harry Wentland
  Cc: amd-gfx, Alex Deucher, Aurabindo Pillai, Bas Nieuwenhuizen,
	Christian König, Daniel Vetter, David Airlie, Eryk Brol,
	Leo Li, Nicholas Kazlauskas, Nikola Cornij, Qingqing Zhuo,
	Rodrigo Siqueira, Wayne Lin, DRI Development,
	Linux Kernel Mailing List

>
> Thanks for your patch but this code has changed on amd-staging-drm-next.
>
> Can you try with the latest? The new backlight_update_status will always
> return 0 now.

Perfect! This solves my actual issue which is that restoring the
backlight level is failing on my device. Thank you.


-- 
Anand K. Mistry
Software Engineer
Google Australia

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

end of thread, other threads:[~2021-06-09  0:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  4:32 [PATCH] drm/amd/display: Fix error code on failure to set brightness Anand K Mistry
2021-06-08 13:59 ` Harry Wentland
2021-06-09  0:55   ` Anand K. Mistry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).