Skip to content

Commit

Permalink
drm/amd/display: Fix unused-but-set-variable warning
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Aashish Sharma authored and Alex Deucher committed Apr 5, 2022
1 parent a68bec2 commit 7da7b02
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -2962,17 +2962,15 @@ 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;

/* Don't remove this.
* The contents need to actually be read from the ring buffer
* for this function to be effective.
*/
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)
Expand Down

0 comments on commit 7da7b02

Please sign in to comment.