[bug report] drm/amd/display : add high part address calculation for underlay

Dan Carpenter dan.carpenter at oracle.com
Mon Nov 6 09:41:05 UTC 2017


Hello Shirish S,

The patch 4d3e00dad80a: "drm/amd/display : add high part address
calculation for underlay" from Oct 19, 2017, leads to the following
static checker warning:

	drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:1838 fill_plane_attributes_from_fb()
	warn: cast after binop

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c
  1831          } else {
  1832                  awidth = ALIGN(fb->width, 64);
  1833                  plane_state->address.type = PLN_ADDR_TYPE_VIDEO_PROGRESSIVE;
  1834                  plane_state->address.video_progressive.luma_addr.low_part
  1835                                                  = lower_32_bits(fb_location);
  1836                  plane_state->address.video_progressive.luma_addr.high_part
  1837                                                  = upper_32_bits(fb_location);
  1838                  chroma_addr = fb_location + (u64)(awidth * fb->height);
                                                    ^^^^^
This cast is a no-op.  fb_location is a u64.  awidth and fb->height are
both unsigned int.  Perhaps you meant to do:

		chroma_addr = fb_location + ((u64)awidth * fb->height);

Or maybe just remove the cast?  It doesn't help readability, because if
it did I wouldn't be so confused.

  1839                  plane_state->address.video_progressive.chroma_addr.low_part
  1840                                                  = lower_32_bits(chroma_addr);
  1841                  plane_state->address.video_progressive.chroma_addr.high_part
  1842                                                  = upper_32_bits(chroma_addr);
  1843                  plane_state->plane_size.video.luma_size.x = 0;
  1844                  plane_state->plane_size.video.luma_size.y = 0;
  1845                  plane_state->plane_size.video.luma_size.width = awidth;
  1846                  plane_state->plane_size.video.luma_size.height = fb->height;
  1847                  /* TODO: unhardcode */
  1848                  plane_state->plane_size.video.luma_pitch = awidth;

regards,
dan carpenter


More information about the amd-gfx mailing list