dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/amd/display: Fix unused-but-set-variable warning
@ 2022-03-24 13:40 Aashish Sharma
  2022-04-01 15:28 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Aashish Sharma @ 2022-03-24 13:40 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
	Pan Xinhui, David Airlie, Nicholas Kazlauskas,
	Meenakshikumar Somasundaram, Jake Wang, Anson Jacob,
	Guenter Roeck
  Cc: Aashish Sharma, kernel test robot, linux-kernel, dri-devel,
	amd-gfx, Wayne Lin, Anthony Koo

Fix the kernel test robot warning below:

drivers/gpu/drm/amd/amdgpu/../display/dmub/inc/dmub_cmd.h:2893:12:
warning: variable 'temp' set but not used [-Wunused-but-set-variable]

Replaced the assignment to the unused temp variable with READ_ONCE()
macro to flush the writes. READ_ONCE() helps avoid the use of
volatile and makes it obvious from the code that the read here is
intentional. Also verified on x86 that the generated code is exactly the
same as before.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Aashish Sharma <shraash@google.com>
---
v2: Removed unnecessary volatile qualifier in the typecast and an unnecessary comment. Also reworded the commit message.
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index 873ecd04e01d..a58f460f431d 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -2913,13 +2913,11 @@ static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)
 	uint32_t wptr = rb->wrpt;
 
 	while (rptr != wptr) {
-		uint64_t volatile *data = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rptr);
-		//uint64_t volatile *p = (uint64_t volatile *)data;
-		uint64_t temp;
+		uint64_t *data = (uint64_t *)((uint8_t *)(rb->base_address) + rptr);
 		uint8_t i;
 
 		for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
-			temp = *data++;
+			(void)READ_ONCE(*data++);
 
 		rptr += DMUB_RB_CMD_SIZE;
 		if (rptr >= rb->capacity)
-- 
2.35.1.894.gb6a874cedc-goog


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

* Re: [PATCH v2] drm/amd/display: Fix unused-but-set-variable warning
  2022-03-24 13:40 [PATCH v2] drm/amd/display: Fix unused-but-set-variable warning Aashish Sharma
@ 2022-04-01 15:28 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2022-04-01 15:28 UTC (permalink / raw)
  To: Aashish Sharma
  Cc: Anson Jacob, kernel test robot, Jake Wang, Leo Li, Anthony Koo,
	Pan Xinhui, Rodrigo Siqueira, LKML, Maling list - DRI developers,
	Meenakshikumar Somasundaram, David Airlie, amd-gfx list,
	Wayne Lin, Alex Deucher, Guenter Roeck, Nicholas Kazlauskas

Applied.  Thanks!

Alex

On Thu, Mar 24, 2022 at 9:46 AM Aashish Sharma <shraash@google.com> wrote:
>
> Fix the kernel test robot warning below:
>
> drivers/gpu/drm/amd/amdgpu/../display/dmub/inc/dmub_cmd.h:2893:12:
> warning: variable 'temp' set but not used [-Wunused-but-set-variable]
>
> Replaced the assignment to the unused temp variable with READ_ONCE()
> macro to flush the writes. READ_ONCE() helps avoid the use of
> volatile and makes it obvious from the code that the read here is
> intentional. Also verified on x86 that the generated code is exactly the
> same as before.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Aashish Sharma <shraash@google.com>
> ---
> v2: Removed unnecessary volatile qualifier in the typecast and an unnecessary comment. Also reworded the commit message.
> ---
>  drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
> index 873ecd04e01d..a58f460f431d 100644
> --- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
> +++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
> @@ -2913,13 +2913,11 @@ static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)
>         uint32_t wptr = rb->wrpt;
>
>         while (rptr != wptr) {
> -               uint64_t volatile *data = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rptr);
> -               //uint64_t volatile *p = (uint64_t volatile *)data;
> -               uint64_t temp;
> +               uint64_t *data = (uint64_t *)((uint8_t *)(rb->base_address) + rptr);
>                 uint8_t i;
>
>                 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
> -                       temp = *data++;
> +                       (void)READ_ONCE(*data++);
>
>                 rptr += DMUB_RB_CMD_SIZE;
>                 if (rptr >= rb->capacity)
> --
> 2.35.1.894.gb6a874cedc-goog
>

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

end of thread, other threads:[~2022-04-01 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 13:40 [PATCH v2] drm/amd/display: Fix unused-but-set-variable warning Aashish Sharma
2022-04-01 15:28 ` Alex Deucher

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).