All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/nouveau/fb/gf100-: rework ram detection
@ 2017-03-14  7:50 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2017-03-14  7:50 UTC (permalink / raw)
  To: bskeggs-H+wXaHxf7aLQT0dZR+AlfA; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hello Ben Skeggs,

The patch 97e5268d57bb: "drm/nouveau/fb/gf100-: rework ram detection"
from Mar 2, 2017, leads to the following static checker warning:

	drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgf100.c:592 gf100_ram_ctor()
	warn: should 'size << 20' be a 64 bit type?

drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgf100.c
   572  gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
   573                 struct nvkm_ram *ram)
   574  {
   575          struct nvkm_subdev *subdev = &fb->subdev;
   576          struct nvkm_device *device = subdev->device;
   577          struct nvkm_bios *bios = device->bios;
   578          const u32 rsvd_head = ( 256 * 1024); /* vga memory */
   579          const u32 rsvd_tail = (1024 * 1024); /* vbios etc */
   580          enum nvkm_ram_type type = nvkm_fb_bios_memtype(bios);
   581          u32 fbps = nvkm_rd32(device, 0x022438);
   582          u64 total = 0, lcomm = ~0, lower, ubase, usize;
                ^^^^^^^^^^^^^
It's a u64.

   583          int ret, fbp, ltcs, ltcn = 0;
   584  
   585          nvkm_debug(subdev, "%d FBP(s)\n", fbps);
   586          for (fbp = 0; fbp < fbps; fbp++) {
   587                  u32 size = func->probe_fbp(func, device, fbp, &ltcs);
                        ^^^^^^^^
This is a u32.

   588                  if (size) {
   589                          nvkm_debug(subdev, "FBP %d: %4d MiB, %d LTC(s)\n",
   590                                     fbp, size, ltcs);
   591                          lcomm  = min(lcomm, (u64)(size / ltcs) << 20);
   592                          total += size << 20;
                                         ^^^^^^^^^^
I don't know if this shift can overflow or not?

   593                          ltcn  += ltcs;
   594                  } else {
   595                          nvkm_debug(subdev, "FBP %d: disabled\n", fbp);
   596                  }
   597          }
   598  
   599          lower = lcomm * ltcn;
   600          ubase = lcomm + func->upper;
   601          usize = total - lower;
   602  
   603          nvkm_debug(subdev, "Lower: %4lld MiB @ %010llx\n", lower >> 20, 0ULL);
   604          nvkm_debug(subdev, "Upper: %4lld MiB @ %010llx\n", usize >> 20, ubase);
   605          nvkm_debug(subdev, "Total: %4lld MiB\n", total >> 20);
   606  
   607          ret = nvkm_ram_ctor(func, fb, type, total, 0, ram);
   608          if (ret)
   609                  return ret;
   610  
   611          nvkm_mm_fini(&ram->vram);
   612  

regards,
dan carpenter
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-14  7:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-14  7:50 [bug report] drm/nouveau/fb/gf100-: rework ram detection Dan Carpenter

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.