From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/gpu/drm/i915/i915_ttm_buddy_manager.c:54 i915_ttm_buddy_man_alloc() warn: should 'bman_res->base.num_pages << 12' be a 64 bit type?
Date: Thu, 25 Nov 2021 02:26:14 +0800 [thread overview]
Message-ID: <202111250241.5OyL9552-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 6987 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Matthew Auld <matthew.auld@intel.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5d9f4cf36721aba199975a9be7863a3ff5cd4b59
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 5 months ago
:::::: branch date: 20 hours ago
:::::: commit date: 5 months ago
config: i386-randconfig-m021-20211124 (https://download.01.org/0day-ci/archive/20211125/202111250241.5OyL9552-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c:54 i915_ttm_buddy_man_alloc() warn: should 'bman_res->base.num_pages << 12' be a 64 bit type?
Old smatch warnings:
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c:56 i915_ttm_buddy_man_alloc() warn: should 'bo->page_alignment << 12' be a 64 bit type?
vim +54 drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
88be9a0a06b73e Matthew Auld 2021-06-16 28
88be9a0a06b73e Matthew Auld 2021-06-16 29 static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
88be9a0a06b73e Matthew Auld 2021-06-16 30 struct ttm_buffer_object *bo,
88be9a0a06b73e Matthew Auld 2021-06-16 31 const struct ttm_place *place,
88be9a0a06b73e Matthew Auld 2021-06-16 32 struct ttm_resource **res)
88be9a0a06b73e Matthew Auld 2021-06-16 33 {
88be9a0a06b73e Matthew Auld 2021-06-16 34 struct i915_ttm_buddy_manager *bman = to_buddy_manager(man);
88be9a0a06b73e Matthew Auld 2021-06-16 35 struct i915_ttm_buddy_resource *bman_res;
88be9a0a06b73e Matthew Auld 2021-06-16 36 struct i915_buddy_mm *mm = &bman->mm;
88be9a0a06b73e Matthew Auld 2021-06-16 37 unsigned long n_pages;
88be9a0a06b73e Matthew Auld 2021-06-16 38 unsigned int min_order;
88be9a0a06b73e Matthew Auld 2021-06-16 39 u64 min_page_size;
88be9a0a06b73e Matthew Auld 2021-06-16 40 u64 size;
88be9a0a06b73e Matthew Auld 2021-06-16 41 int err;
88be9a0a06b73e Matthew Auld 2021-06-16 42
88be9a0a06b73e Matthew Auld 2021-06-16 43 GEM_BUG_ON(place->fpfn || place->lpfn);
88be9a0a06b73e Matthew Auld 2021-06-16 44
88be9a0a06b73e Matthew Auld 2021-06-16 45 bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL);
88be9a0a06b73e Matthew Auld 2021-06-16 46 if (!bman_res)
88be9a0a06b73e Matthew Auld 2021-06-16 47 return -ENOMEM;
88be9a0a06b73e Matthew Auld 2021-06-16 48
88be9a0a06b73e Matthew Auld 2021-06-16 49 ttm_resource_init(bo, place, &bman_res->base);
88be9a0a06b73e Matthew Auld 2021-06-16 50 INIT_LIST_HEAD(&bman_res->blocks);
88be9a0a06b73e Matthew Auld 2021-06-16 51 bman_res->mm = mm;
88be9a0a06b73e Matthew Auld 2021-06-16 52
88be9a0a06b73e Matthew Auld 2021-06-16 53 GEM_BUG_ON(!bman_res->base.num_pages);
88be9a0a06b73e Matthew Auld 2021-06-16 @54 size = bman_res->base.num_pages << PAGE_SHIFT;
88be9a0a06b73e Matthew Auld 2021-06-16 55
88be9a0a06b73e Matthew Auld 2021-06-16 56 min_page_size = bo->page_alignment << PAGE_SHIFT;
88be9a0a06b73e Matthew Auld 2021-06-16 57 GEM_BUG_ON(min_page_size < mm->chunk_size);
88be9a0a06b73e Matthew Auld 2021-06-16 58 min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);
88be9a0a06b73e Matthew Auld 2021-06-16 59 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
88be9a0a06b73e Matthew Auld 2021-06-16 60 size = roundup_pow_of_two(size);
88be9a0a06b73e Matthew Auld 2021-06-16 61 min_order = ilog2(size) - ilog2(mm->chunk_size);
88be9a0a06b73e Matthew Auld 2021-06-16 62 }
88be9a0a06b73e Matthew Auld 2021-06-16 63
88be9a0a06b73e Matthew Auld 2021-06-16 64 if (size > mm->size) {
88be9a0a06b73e Matthew Auld 2021-06-16 65 err = -E2BIG;
88be9a0a06b73e Matthew Auld 2021-06-16 66 goto err_free_res;
88be9a0a06b73e Matthew Auld 2021-06-16 67 }
88be9a0a06b73e Matthew Auld 2021-06-16 68
88be9a0a06b73e Matthew Auld 2021-06-16 69 n_pages = size >> ilog2(mm->chunk_size);
88be9a0a06b73e Matthew Auld 2021-06-16 70
88be9a0a06b73e Matthew Auld 2021-06-16 71 do {
88be9a0a06b73e Matthew Auld 2021-06-16 72 struct i915_buddy_block *block;
88be9a0a06b73e Matthew Auld 2021-06-16 73 unsigned int order;
88be9a0a06b73e Matthew Auld 2021-06-16 74
88be9a0a06b73e Matthew Auld 2021-06-16 75 order = fls(n_pages) - 1;
88be9a0a06b73e Matthew Auld 2021-06-16 76 GEM_BUG_ON(order > mm->max_order);
88be9a0a06b73e Matthew Auld 2021-06-16 77 GEM_BUG_ON(order < min_order);
88be9a0a06b73e Matthew Auld 2021-06-16 78
88be9a0a06b73e Matthew Auld 2021-06-16 79 do {
88be9a0a06b73e Matthew Auld 2021-06-16 80 mutex_lock(&bman->lock);
88be9a0a06b73e Matthew Auld 2021-06-16 81 block = i915_buddy_alloc(mm, order);
88be9a0a06b73e Matthew Auld 2021-06-16 82 mutex_unlock(&bman->lock);
88be9a0a06b73e Matthew Auld 2021-06-16 83 if (!IS_ERR(block))
88be9a0a06b73e Matthew Auld 2021-06-16 84 break;
88be9a0a06b73e Matthew Auld 2021-06-16 85
88be9a0a06b73e Matthew Auld 2021-06-16 86 if (order-- == min_order) {
88be9a0a06b73e Matthew Auld 2021-06-16 87 err = -ENOSPC;
88be9a0a06b73e Matthew Auld 2021-06-16 88 goto err_free_blocks;
88be9a0a06b73e Matthew Auld 2021-06-16 89 }
88be9a0a06b73e Matthew Auld 2021-06-16 90 } while (1);
88be9a0a06b73e Matthew Auld 2021-06-16 91
88be9a0a06b73e Matthew Auld 2021-06-16 92 n_pages -= BIT(order);
88be9a0a06b73e Matthew Auld 2021-06-16 93
88be9a0a06b73e Matthew Auld 2021-06-16 94 list_add_tail(&block->link, &bman_res->blocks);
88be9a0a06b73e Matthew Auld 2021-06-16 95
88be9a0a06b73e Matthew Auld 2021-06-16 96 if (!n_pages)
88be9a0a06b73e Matthew Auld 2021-06-16 97 break;
88be9a0a06b73e Matthew Auld 2021-06-16 98 } while (1);
88be9a0a06b73e Matthew Auld 2021-06-16 99
88be9a0a06b73e Matthew Auld 2021-06-16 100 *res = &bman_res->base;
88be9a0a06b73e Matthew Auld 2021-06-16 101 return 0;
88be9a0a06b73e Matthew Auld 2021-06-16 102
88be9a0a06b73e Matthew Auld 2021-06-16 103 err_free_blocks:
88be9a0a06b73e Matthew Auld 2021-06-16 104 mutex_lock(&bman->lock);
88be9a0a06b73e Matthew Auld 2021-06-16 105 i915_buddy_free_list(mm, &bman_res->blocks);
88be9a0a06b73e Matthew Auld 2021-06-16 106 mutex_unlock(&bman->lock);
88be9a0a06b73e Matthew Auld 2021-06-16 107 err_free_res:
88be9a0a06b73e Matthew Auld 2021-06-16 108 kfree(bman_res);
88be9a0a06b73e Matthew Auld 2021-06-16 109 return err;
88be9a0a06b73e Matthew Auld 2021-06-16 110 }
88be9a0a06b73e Matthew Auld 2021-06-16 111
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
next reply other threads:[~2021-11-24 18:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 18:26 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-11-26 0:47 drivers/gpu/drm/i915/i915_ttm_buddy_manager.c:54 i915_ttm_buddy_man_alloc() warn: should 'bman_res->base.num_pages << 12' be a 64 bit type? kernel test robot
2021-12-09 13:09 kernel test robot
2021-12-17 6:07 kernel test robot
2021-12-21 2:43 kernel test robot
2021-12-29 19:52 kernel test robot
2022-02-09 2:27 kernel test robot
2022-02-10 0:51 kernel test robot
2022-02-28 8:31 kernel test robot
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=202111250241.5OyL9552-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.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.