All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [bug report] drm/nouveau/fb/gf100-: rework ram detection
Date: Tue, 14 Mar 2017 10:50:01 +0300	[thread overview]
Message-ID: <20170314075001.GA5984@mwanda> (raw)

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

                 reply	other threads:[~2017-03-14  7:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170314075001.GA5984@mwanda \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.