All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: avoid passing enum as NULL pointer
@ 2019-03-07 10:34 Arnd Bergmann
       [not found] ` <20190307103454.1637485-1-arnd-r2nGTMty4D4@public.gmane.org>
  2019-03-07 15:34 ` Nathan Chancellor
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-07 10:34 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou
  Cc: Nick Desaulniers, Arnd Bergmann, David Airlie, Daniel Vetter,
	Anthony Koo, Aric Cyr, Harmanprit Tatla, Ken Chalmers,
	SivapiriyanKumarasamy, Kees Cook, Bayan Zabihiyan, Tony Cheng,
	amd-gfx, dri-devel, linux-kernel

The mod_freesync_build_vrr_infopacket() function uses rather obscure
calling conventions, where an enum is passed in through a pointer,
and a NULL pointer is expected to behave the same way as the zero-value
(TRANSFER_FUNC_UNKNOWN).

Trying to build this with clang results in a warning:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4601:3: error: expression which evaluates to zero treated
      as a null pointer constant of type 'const enum color_transfer_func *' [-Werror,-Wnon-literal-null-conversion]

Passing it by value instead of by reference makes the code simpler
and more conventional but should not change the behavior at all.

Fixes: c2791297013e ("drm/amd/display: Add color bit info to freesync infoframe")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 7 +++----
 drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h  | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 94a84bc57c7a..6f32fe129880 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -724,7 +724,7 @@ static void build_vrr_infopacket_v1(enum signal_type signal,
 
 static void build_vrr_infopacket_v2(enum signal_type signal,
 		const struct mod_vrr_params *vrr,
-		const enum color_transfer_func *app_tf,
+		const enum color_transfer_func app_tf,
 		struct dc_info_packet *infopacket)
 {
 	unsigned int payload_size = 0;
@@ -732,8 +732,7 @@ static void build_vrr_infopacket_v2(enum signal_type signal,
 	build_vrr_infopacket_header_v2(signal, infopacket, &payload_size);
 	build_vrr_infopacket_data(vrr, infopacket);
 
-	if (app_tf != NULL)
-		build_vrr_infopacket_fs2_data(*app_tf, infopacket);
+	build_vrr_infopacket_fs2_data(app_tf, infopacket);
 
 	build_vrr_infopacket_checksum(&payload_size, infopacket);
 
@@ -757,7 +756,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
 		const struct dc_stream_state *stream,
 		const struct mod_vrr_params *vrr,
 		enum vrr_packet_type packet_type,
-		const enum color_transfer_func *app_tf,
+		const enum color_transfer_func app_tf,
 		struct dc_info_packet *infopacket)
 {
 	/* SPD info packet for FreeSync
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
index 4222e403b151..645793b924cf 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
@@ -145,7 +145,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
 		const struct dc_stream_state *stream,
 		const struct mod_vrr_params *vrr,
 		enum vrr_packet_type packet_type,
-		const enum color_transfer_func *app_tf,
+		const enum color_transfer_func app_tf,
 		struct dc_info_packet *infopacket);
 
 void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
-- 
2.20.0


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

* Re: [PATCH] drm/amd/display: avoid passing enum as NULL pointer
       [not found] ` <20190307103454.1637485-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2019-03-07 13:43   ` Deucher, Alexander
  0 siblings, 0 replies; 3+ messages in thread
From: Deucher, Alexander @ 2019-03-07 13:43 UTC (permalink / raw)
  To: Arnd Bergmann, Wentland, Harry, Li, Sun peng (Leo),
	Koenig, Christian, Zhou, David(ChunMing)
  Cc: Cyr, Aric, Kees Cook, David Airlie, Bayan Zabihiyan,
	Nick Desaulniers, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Tatla, Harmanprit,
	Cheng, Tony, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Daniel Vetter, Koo, Anthony, Kumarasamy, Sivapiriyan, Chalmers,
	Kenneth


[-- Attachment #1.1: Type: text/plain, Size: 4282 bytes --]

Thanks for the patch.  We already have the fix queued:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=drm-next-5.2-wip&id=672e78cab819ebe31e3b9b8abac367be8a110472

Alex
________________________________
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Sent: Thursday, March 7, 2019 5:34 AM
To: Wentland, Harry; Li, Sun peng (Leo); Deucher, Alexander; Koenig, Christian; Zhou, David(ChunMing)
Cc: Nick Desaulniers; Arnd Bergmann; David Airlie; Daniel Vetter; Koo, Anthony; Cyr, Aric; Tatla, Harmanprit; Chalmers, Kenneth; Kumarasamy, Sivapiriyan; Kees Cook; Bayan Zabihiyan; Cheng, Tony; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] drm/amd/display: avoid passing enum as NULL pointer

The mod_freesync_build_vrr_infopacket() function uses rather obscure
calling conventions, where an enum is passed in through a pointer,
and a NULL pointer is expected to behave the same way as the zero-value
(TRANSFER_FUNC_UNKNOWN).

Trying to build this with clang results in a warning:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4601:3: error: expression which evaluates to zero treated
      as a null pointer constant of type 'const enum color_transfer_func *' [-Werror,-Wnon-literal-null-conversion]

Passing it by value instead of by reference makes the code simpler
and more conventional but should not change the behavior at all.

Fixes: c2791297013e ("drm/amd/display: Add color bit info to freesync infoframe")
Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
---
 drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 7 +++----
 drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h  | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 94a84bc57c7a..6f32fe129880 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -724,7 +724,7 @@ static void build_vrr_infopacket_v1(enum signal_type signal,

 static void build_vrr_infopacket_v2(enum signal_type signal,
                 const struct mod_vrr_params *vrr,
-               const enum color_transfer_func *app_tf,
+               const enum color_transfer_func app_tf,
                 struct dc_info_packet *infopacket)
 {
         unsigned int payload_size = 0;
@@ -732,8 +732,7 @@ static void build_vrr_infopacket_v2(enum signal_type signal,
         build_vrr_infopacket_header_v2(signal, infopacket, &payload_size);
         build_vrr_infopacket_data(vrr, infopacket);

-       if (app_tf != NULL)
-               build_vrr_infopacket_fs2_data(*app_tf, infopacket);
+       build_vrr_infopacket_fs2_data(app_tf, infopacket);

         build_vrr_infopacket_checksum(&payload_size, infopacket);

@@ -757,7 +756,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
                 const struct dc_stream_state *stream,
                 const struct mod_vrr_params *vrr,
                 enum vrr_packet_type packet_type,
-               const enum color_transfer_func *app_tf,
+               const enum color_transfer_func app_tf,
                 struct dc_info_packet *infopacket)
 {
         /* SPD info packet for FreeSync
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
index 4222e403b151..645793b924cf 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
@@ -145,7 +145,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
                 const struct dc_stream_state *stream,
                 const struct mod_vrr_params *vrr,
                 enum vrr_packet_type packet_type,
-               const enum color_transfer_func *app_tf,
+               const enum color_transfer_func app_tf,
                 struct dc_info_packet *infopacket);

 void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
--
2.20.0


[-- Attachment #1.2: Type: text/html, Size: 7491 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amd/display: avoid passing enum as NULL pointer
  2019-03-07 10:34 [PATCH] drm/amd/display: avoid passing enum as NULL pointer Arnd Bergmann
       [not found] ` <20190307103454.1637485-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2019-03-07 15:34 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-03-07 15:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, Nick Desaulniers, David Airlie,
	Daniel Vetter, Anthony Koo, Aric Cyr, Harmanprit Tatla,
	Ken Chalmers, SivapiriyanKumarasamy, Kees Cook, Bayan Zabihiyan,
	Tony Cheng, amd-gfx, dri-devel, linux-kernel

On Thu, Mar 07, 2019 at 11:34:29AM +0100, Arnd Bergmann wrote:
> The mod_freesync_build_vrr_infopacket() function uses rather obscure
> calling conventions, where an enum is passed in through a pointer,
> and a NULL pointer is expected to behave the same way as the zero-value
> (TRANSFER_FUNC_UNKNOWN).
> 
> Trying to build this with clang results in a warning:
> 
> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4601:3: error: expression which evaluates to zero treated
>       as a null pointer constant of type 'const enum color_transfer_func *' [-Werror,-Wnon-literal-null-conversion]
> 
> Passing it by value instead of by reference makes the code simpler
> and more conventional but should not change the behavior at all.
> 
> Fixes: c2791297013e ("drm/amd/display: Add color bit info to freesync infoframe")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 7 +++----
>  drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h  | 2 +-
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
> index 94a84bc57c7a..6f32fe129880 100644
> --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
> +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
> @@ -724,7 +724,7 @@ static void build_vrr_infopacket_v1(enum signal_type signal,
>  
>  static void build_vrr_infopacket_v2(enum signal_type signal,
>  		const struct mod_vrr_params *vrr,
> -		const enum color_transfer_func *app_tf,
> +		const enum color_transfer_func app_tf,
>  		struct dc_info_packet *infopacket)
>  {
>  	unsigned int payload_size = 0;
> @@ -732,8 +732,7 @@ static void build_vrr_infopacket_v2(enum signal_type signal,
>  	build_vrr_infopacket_header_v2(signal, infopacket, &payload_size);
>  	build_vrr_infopacket_data(vrr, infopacket);
>  
> -	if (app_tf != NULL)
> -		build_vrr_infopacket_fs2_data(*app_tf, infopacket);
> +	build_vrr_infopacket_fs2_data(app_tf, infopacket);
>  
>  	build_vrr_infopacket_checksum(&payload_size, infopacket);
>  
> @@ -757,7 +756,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
>  		const struct dc_stream_state *stream,
>  		const struct mod_vrr_params *vrr,
>  		enum vrr_packet_type packet_type,
> -		const enum color_transfer_func *app_tf,
> +		const enum color_transfer_func app_tf,
>  		struct dc_info_packet *infopacket)
>  {
>  	/* SPD info packet for FreeSync
> diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
> index 4222e403b151..645793b924cf 100644
> --- a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
> +++ b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
> @@ -145,7 +145,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
>  		const struct dc_stream_state *stream,
>  		const struct mod_vrr_params *vrr,
>  		enum vrr_packet_type packet_type,
> -		const enum color_transfer_func *app_tf,
> +		const enum color_transfer_func app_tf,
>  		struct dc_info_packet *infopacket);
>  
>  void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
> -- 
> 2.20.0
> 

Just as an FYI, I sent the same fix when the warning first hit which was
recently accepted:

https://cgit.freedesktop.org/~agd5f/linux/commit/?id=672e78cab819ebe31e3b9b8abac367be8a110472

Just waiting for it to hit mainline.

Cheers,
Nathan

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

end of thread, other threads:[~2019-03-07 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:34 [PATCH] drm/amd/display: avoid passing enum as NULL pointer Arnd Bergmann
     [not found] ` <20190307103454.1637485-1-arnd-r2nGTMty4D4@public.gmane.org>
2019-03-07 13:43   ` Deucher, Alexander
2019-03-07 15:34 ` Nathan Chancellor

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.