* 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?
@ 2021-12-29 19:52 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-12-29 19:52 UTC (permalink / raw)
To: kbuild
[-- 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: e7c124bd04631973a3cc0df19ab881b56d8a2d50
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 7 months ago
:::::: branch date: 22 hours ago
:::::: commit date: 7 months ago
config: i386-randconfig-m021-20211229 (https://download.01.org/0day-ci/archive/20211230/202112300318.84tcFlXp-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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2022-02-28 8:31 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2022-02-28 8:31 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 7093 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
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: 7e57714cd0ad2d5bb90e50b5096a0e671dec1ef3
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 9 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 9 months ago
config: i386-randconfig-m021-20220228 (https://download.01.org/0day-ci/archive/20220228/202202281657.oED3FGfB-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
88be9a0a06b73ec Matthew Auld 2021-06-16 28
88be9a0a06b73ec Matthew Auld 2021-06-16 29 static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
88be9a0a06b73ec Matthew Auld 2021-06-16 30 struct ttm_buffer_object *bo,
88be9a0a06b73ec Matthew Auld 2021-06-16 31 const struct ttm_place *place,
88be9a0a06b73ec Matthew Auld 2021-06-16 32 struct ttm_resource **res)
88be9a0a06b73ec Matthew Auld 2021-06-16 33 {
88be9a0a06b73ec Matthew Auld 2021-06-16 34 struct i915_ttm_buddy_manager *bman = to_buddy_manager(man);
88be9a0a06b73ec Matthew Auld 2021-06-16 35 struct i915_ttm_buddy_resource *bman_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 36 struct i915_buddy_mm *mm = &bman->mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 37 unsigned long n_pages;
88be9a0a06b73ec Matthew Auld 2021-06-16 38 unsigned int min_order;
88be9a0a06b73ec Matthew Auld 2021-06-16 39 u64 min_page_size;
88be9a0a06b73ec Matthew Auld 2021-06-16 40 u64 size;
88be9a0a06b73ec Matthew Auld 2021-06-16 41 int err;
88be9a0a06b73ec Matthew Auld 2021-06-16 42
88be9a0a06b73ec Matthew Auld 2021-06-16 43 GEM_BUG_ON(place->fpfn || place->lpfn);
88be9a0a06b73ec Matthew Auld 2021-06-16 44
88be9a0a06b73ec Matthew Auld 2021-06-16 45 bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL);
88be9a0a06b73ec Matthew Auld 2021-06-16 46 if (!bman_res)
88be9a0a06b73ec Matthew Auld 2021-06-16 47 return -ENOMEM;
88be9a0a06b73ec Matthew Auld 2021-06-16 48
88be9a0a06b73ec Matthew Auld 2021-06-16 49 ttm_resource_init(bo, place, &bman_res->base);
88be9a0a06b73ec Matthew Auld 2021-06-16 50 INIT_LIST_HEAD(&bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 51 bman_res->mm = mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 52
88be9a0a06b73ec Matthew Auld 2021-06-16 53 GEM_BUG_ON(!bman_res->base.num_pages);
88be9a0a06b73ec Matthew Auld 2021-06-16 @54 size = bman_res->base.num_pages << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 55
88be9a0a06b73ec Matthew Auld 2021-06-16 56 min_page_size = bo->page_alignment << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 57 GEM_BUG_ON(min_page_size < mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 58 min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 59 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
88be9a0a06b73ec Matthew Auld 2021-06-16 60 size = roundup_pow_of_two(size);
88be9a0a06b73ec Matthew Auld 2021-06-16 61 min_order = ilog2(size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 62 }
88be9a0a06b73ec Matthew Auld 2021-06-16 63
88be9a0a06b73ec Matthew Auld 2021-06-16 64 if (size > mm->size) {
88be9a0a06b73ec Matthew Auld 2021-06-16 65 err = -E2BIG;
88be9a0a06b73ec Matthew Auld 2021-06-16 66 goto err_free_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 67 }
88be9a0a06b73ec Matthew Auld 2021-06-16 68
88be9a0a06b73ec Matthew Auld 2021-06-16 69 n_pages = size >> ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 70
88be9a0a06b73ec Matthew Auld 2021-06-16 71 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 72 struct i915_buddy_block *block;
88be9a0a06b73ec Matthew Auld 2021-06-16 73 unsigned int order;
88be9a0a06b73ec Matthew Auld 2021-06-16 74
88be9a0a06b73ec Matthew Auld 2021-06-16 75 order = fls(n_pages) - 1;
88be9a0a06b73ec Matthew Auld 2021-06-16 76 GEM_BUG_ON(order > mm->max_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 77 GEM_BUG_ON(order < min_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 78
88be9a0a06b73ec Matthew Auld 2021-06-16 79 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 80 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 81 block = i915_buddy_alloc(mm, order);
88be9a0a06b73ec Matthew Auld 2021-06-16 82 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 83 if (!IS_ERR(block))
88be9a0a06b73ec Matthew Auld 2021-06-16 84 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 85
88be9a0a06b73ec Matthew Auld 2021-06-16 86 if (order-- == min_order) {
88be9a0a06b73ec Matthew Auld 2021-06-16 87 err = -ENOSPC;
88be9a0a06b73ec Matthew Auld 2021-06-16 88 goto err_free_blocks;
88be9a0a06b73ec Matthew Auld 2021-06-16 89 }
88be9a0a06b73ec Matthew Auld 2021-06-16 90 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 91
88be9a0a06b73ec Matthew Auld 2021-06-16 92 n_pages -= BIT(order);
88be9a0a06b73ec Matthew Auld 2021-06-16 93
88be9a0a06b73ec Matthew Auld 2021-06-16 94 list_add_tail(&block->link, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 95
88be9a0a06b73ec Matthew Auld 2021-06-16 96 if (!n_pages)
88be9a0a06b73ec Matthew Auld 2021-06-16 97 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 98 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 99
88be9a0a06b73ec Matthew Auld 2021-06-16 100 *res = &bman_res->base;
88be9a0a06b73ec Matthew Auld 2021-06-16 101 return 0;
88be9a0a06b73ec Matthew Auld 2021-06-16 102
88be9a0a06b73ec Matthew Auld 2021-06-16 103 err_free_blocks:
88be9a0a06b73ec Matthew Auld 2021-06-16 104 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 105 i915_buddy_free_list(mm, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 106 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 107 err_free_res:
88be9a0a06b73ec Matthew Auld 2021-06-16 108 kfree(bman_res);
88be9a0a06b73ec Matthew Auld 2021-06-16 109 return err;
88be9a0a06b73ec Matthew Auld 2021-06-16 110 }
88be9a0a06b73ec 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2022-02-10 0:51 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2022-02-10 0:51 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 7070 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: f4bc5bbb5fef3cf421ba3485d6d383c27ec473ed
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 8 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 8 months ago
config: i386-randconfig-m031-20220207 (https://download.01.org/0day-ci/archive/20220210/202202100809.B1xPqVSn-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
88be9a0a06b73ec Matthew Auld 2021-06-16 28
88be9a0a06b73ec Matthew Auld 2021-06-16 29 static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
88be9a0a06b73ec Matthew Auld 2021-06-16 30 struct ttm_buffer_object *bo,
88be9a0a06b73ec Matthew Auld 2021-06-16 31 const struct ttm_place *place,
88be9a0a06b73ec Matthew Auld 2021-06-16 32 struct ttm_resource **res)
88be9a0a06b73ec Matthew Auld 2021-06-16 33 {
88be9a0a06b73ec Matthew Auld 2021-06-16 34 struct i915_ttm_buddy_manager *bman = to_buddy_manager(man);
88be9a0a06b73ec Matthew Auld 2021-06-16 35 struct i915_ttm_buddy_resource *bman_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 36 struct i915_buddy_mm *mm = &bman->mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 37 unsigned long n_pages;
88be9a0a06b73ec Matthew Auld 2021-06-16 38 unsigned int min_order;
88be9a0a06b73ec Matthew Auld 2021-06-16 39 u64 min_page_size;
88be9a0a06b73ec Matthew Auld 2021-06-16 40 u64 size;
88be9a0a06b73ec Matthew Auld 2021-06-16 41 int err;
88be9a0a06b73ec Matthew Auld 2021-06-16 42
88be9a0a06b73ec Matthew Auld 2021-06-16 43 GEM_BUG_ON(place->fpfn || place->lpfn);
88be9a0a06b73ec Matthew Auld 2021-06-16 44
88be9a0a06b73ec Matthew Auld 2021-06-16 45 bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL);
88be9a0a06b73ec Matthew Auld 2021-06-16 46 if (!bman_res)
88be9a0a06b73ec Matthew Auld 2021-06-16 47 return -ENOMEM;
88be9a0a06b73ec Matthew Auld 2021-06-16 48
88be9a0a06b73ec Matthew Auld 2021-06-16 49 ttm_resource_init(bo, place, &bman_res->base);
88be9a0a06b73ec Matthew Auld 2021-06-16 50 INIT_LIST_HEAD(&bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 51 bman_res->mm = mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 52
88be9a0a06b73ec Matthew Auld 2021-06-16 53 GEM_BUG_ON(!bman_res->base.num_pages);
88be9a0a06b73ec Matthew Auld 2021-06-16 @54 size = bman_res->base.num_pages << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 55
88be9a0a06b73ec Matthew Auld 2021-06-16 56 min_page_size = bo->page_alignment << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 57 GEM_BUG_ON(min_page_size < mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 58 min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 59 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
88be9a0a06b73ec Matthew Auld 2021-06-16 60 size = roundup_pow_of_two(size);
88be9a0a06b73ec Matthew Auld 2021-06-16 61 min_order = ilog2(size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 62 }
88be9a0a06b73ec Matthew Auld 2021-06-16 63
88be9a0a06b73ec Matthew Auld 2021-06-16 64 if (size > mm->size) {
88be9a0a06b73ec Matthew Auld 2021-06-16 65 err = -E2BIG;
88be9a0a06b73ec Matthew Auld 2021-06-16 66 goto err_free_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 67 }
88be9a0a06b73ec Matthew Auld 2021-06-16 68
88be9a0a06b73ec Matthew Auld 2021-06-16 69 n_pages = size >> ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 70
88be9a0a06b73ec Matthew Auld 2021-06-16 71 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 72 struct i915_buddy_block *block;
88be9a0a06b73ec Matthew Auld 2021-06-16 73 unsigned int order;
88be9a0a06b73ec Matthew Auld 2021-06-16 74
88be9a0a06b73ec Matthew Auld 2021-06-16 75 order = fls(n_pages) - 1;
88be9a0a06b73ec Matthew Auld 2021-06-16 76 GEM_BUG_ON(order > mm->max_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 77 GEM_BUG_ON(order < min_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 78
88be9a0a06b73ec Matthew Auld 2021-06-16 79 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 80 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 81 block = i915_buddy_alloc(mm, order);
88be9a0a06b73ec Matthew Auld 2021-06-16 82 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 83 if (!IS_ERR(block))
88be9a0a06b73ec Matthew Auld 2021-06-16 84 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 85
88be9a0a06b73ec Matthew Auld 2021-06-16 86 if (order-- == min_order) {
88be9a0a06b73ec Matthew Auld 2021-06-16 87 err = -ENOSPC;
88be9a0a06b73ec Matthew Auld 2021-06-16 88 goto err_free_blocks;
88be9a0a06b73ec Matthew Auld 2021-06-16 89 }
88be9a0a06b73ec Matthew Auld 2021-06-16 90 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 91
88be9a0a06b73ec Matthew Auld 2021-06-16 92 n_pages -= BIT(order);
88be9a0a06b73ec Matthew Auld 2021-06-16 93
88be9a0a06b73ec Matthew Auld 2021-06-16 94 list_add_tail(&block->link, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 95
88be9a0a06b73ec Matthew Auld 2021-06-16 96 if (!n_pages)
88be9a0a06b73ec Matthew Auld 2021-06-16 97 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 98 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 99
88be9a0a06b73ec Matthew Auld 2021-06-16 100 *res = &bman_res->base;
88be9a0a06b73ec Matthew Auld 2021-06-16 101 return 0;
88be9a0a06b73ec Matthew Auld 2021-06-16 102
88be9a0a06b73ec Matthew Auld 2021-06-16 103 err_free_blocks:
88be9a0a06b73ec Matthew Auld 2021-06-16 104 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 105 i915_buddy_free_list(mm, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 106 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 107 err_free_res:
88be9a0a06b73ec Matthew Auld 2021-06-16 108 kfree(bman_res);
88be9a0a06b73ec Matthew Auld 2021-06-16 109 return err;
88be9a0a06b73ec Matthew Auld 2021-06-16 110 }
88be9a0a06b73ec 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2022-02-09 2:27 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2022-02-09 2:27 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 7070 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: e6251ab4551f51fa4cee03523e08051898c3ce82
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 8 months ago
:::::: branch date: 6 hours ago
:::::: commit date: 8 months ago
config: i386-randconfig-m031-20220207 (https://download.01.org/0day-ci/archive/20220209/202202091049.73gntoTD-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
88be9a0a06b73ec Matthew Auld 2021-06-16 28
88be9a0a06b73ec Matthew Auld 2021-06-16 29 static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
88be9a0a06b73ec Matthew Auld 2021-06-16 30 struct ttm_buffer_object *bo,
88be9a0a06b73ec Matthew Auld 2021-06-16 31 const struct ttm_place *place,
88be9a0a06b73ec Matthew Auld 2021-06-16 32 struct ttm_resource **res)
88be9a0a06b73ec Matthew Auld 2021-06-16 33 {
88be9a0a06b73ec Matthew Auld 2021-06-16 34 struct i915_ttm_buddy_manager *bman = to_buddy_manager(man);
88be9a0a06b73ec Matthew Auld 2021-06-16 35 struct i915_ttm_buddy_resource *bman_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 36 struct i915_buddy_mm *mm = &bman->mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 37 unsigned long n_pages;
88be9a0a06b73ec Matthew Auld 2021-06-16 38 unsigned int min_order;
88be9a0a06b73ec Matthew Auld 2021-06-16 39 u64 min_page_size;
88be9a0a06b73ec Matthew Auld 2021-06-16 40 u64 size;
88be9a0a06b73ec Matthew Auld 2021-06-16 41 int err;
88be9a0a06b73ec Matthew Auld 2021-06-16 42
88be9a0a06b73ec Matthew Auld 2021-06-16 43 GEM_BUG_ON(place->fpfn || place->lpfn);
88be9a0a06b73ec Matthew Auld 2021-06-16 44
88be9a0a06b73ec Matthew Auld 2021-06-16 45 bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL);
88be9a0a06b73ec Matthew Auld 2021-06-16 46 if (!bman_res)
88be9a0a06b73ec Matthew Auld 2021-06-16 47 return -ENOMEM;
88be9a0a06b73ec Matthew Auld 2021-06-16 48
88be9a0a06b73ec Matthew Auld 2021-06-16 49 ttm_resource_init(bo, place, &bman_res->base);
88be9a0a06b73ec Matthew Auld 2021-06-16 50 INIT_LIST_HEAD(&bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 51 bman_res->mm = mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 52
88be9a0a06b73ec Matthew Auld 2021-06-16 53 GEM_BUG_ON(!bman_res->base.num_pages);
88be9a0a06b73ec Matthew Auld 2021-06-16 @54 size = bman_res->base.num_pages << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 55
88be9a0a06b73ec Matthew Auld 2021-06-16 56 min_page_size = bo->page_alignment << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 57 GEM_BUG_ON(min_page_size < mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 58 min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 59 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
88be9a0a06b73ec Matthew Auld 2021-06-16 60 size = roundup_pow_of_two(size);
88be9a0a06b73ec Matthew Auld 2021-06-16 61 min_order = ilog2(size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 62 }
88be9a0a06b73ec Matthew Auld 2021-06-16 63
88be9a0a06b73ec Matthew Auld 2021-06-16 64 if (size > mm->size) {
88be9a0a06b73ec Matthew Auld 2021-06-16 65 err = -E2BIG;
88be9a0a06b73ec Matthew Auld 2021-06-16 66 goto err_free_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 67 }
88be9a0a06b73ec Matthew Auld 2021-06-16 68
88be9a0a06b73ec Matthew Auld 2021-06-16 69 n_pages = size >> ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 70
88be9a0a06b73ec Matthew Auld 2021-06-16 71 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 72 struct i915_buddy_block *block;
88be9a0a06b73ec Matthew Auld 2021-06-16 73 unsigned int order;
88be9a0a06b73ec Matthew Auld 2021-06-16 74
88be9a0a06b73ec Matthew Auld 2021-06-16 75 order = fls(n_pages) - 1;
88be9a0a06b73ec Matthew Auld 2021-06-16 76 GEM_BUG_ON(order > mm->max_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 77 GEM_BUG_ON(order < min_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 78
88be9a0a06b73ec Matthew Auld 2021-06-16 79 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 80 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 81 block = i915_buddy_alloc(mm, order);
88be9a0a06b73ec Matthew Auld 2021-06-16 82 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 83 if (!IS_ERR(block))
88be9a0a06b73ec Matthew Auld 2021-06-16 84 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 85
88be9a0a06b73ec Matthew Auld 2021-06-16 86 if (order-- == min_order) {
88be9a0a06b73ec Matthew Auld 2021-06-16 87 err = -ENOSPC;
88be9a0a06b73ec Matthew Auld 2021-06-16 88 goto err_free_blocks;
88be9a0a06b73ec Matthew Auld 2021-06-16 89 }
88be9a0a06b73ec Matthew Auld 2021-06-16 90 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 91
88be9a0a06b73ec Matthew Auld 2021-06-16 92 n_pages -= BIT(order);
88be9a0a06b73ec Matthew Auld 2021-06-16 93
88be9a0a06b73ec Matthew Auld 2021-06-16 94 list_add_tail(&block->link, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 95
88be9a0a06b73ec Matthew Auld 2021-06-16 96 if (!n_pages)
88be9a0a06b73ec Matthew Auld 2021-06-16 97 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 98 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 99
88be9a0a06b73ec Matthew Auld 2021-06-16 100 *res = &bman_res->base;
88be9a0a06b73ec Matthew Auld 2021-06-16 101 return 0;
88be9a0a06b73ec Matthew Auld 2021-06-16 102
88be9a0a06b73ec Matthew Auld 2021-06-16 103 err_free_blocks:
88be9a0a06b73ec Matthew Auld 2021-06-16 104 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 105 i915_buddy_free_list(mm, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 106 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 107 err_free_res:
88be9a0a06b73ec Matthew Auld 2021-06-16 108 kfree(bman_res);
88be9a0a06b73ec Matthew Auld 2021-06-16 109 return err;
88be9a0a06b73ec Matthew Auld 2021-06-16 110 }
88be9a0a06b73ec 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2021-12-21 2:43 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-12-21 2:43 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 7070 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: 86085fe79e3c1a66e32f2acae0ae64f4cceb8d28
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 6 months ago
:::::: branch date: 8 hours ago
:::::: commit date: 6 months ago
config: i386-randconfig-m021-20211207 (https://download.01.org/0day-ci/archive/20211221/202112211043.zKe8dF7V-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
88be9a0a06b73ec Matthew Auld 2021-06-16 28
88be9a0a06b73ec Matthew Auld 2021-06-16 29 static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
88be9a0a06b73ec Matthew Auld 2021-06-16 30 struct ttm_buffer_object *bo,
88be9a0a06b73ec Matthew Auld 2021-06-16 31 const struct ttm_place *place,
88be9a0a06b73ec Matthew Auld 2021-06-16 32 struct ttm_resource **res)
88be9a0a06b73ec Matthew Auld 2021-06-16 33 {
88be9a0a06b73ec Matthew Auld 2021-06-16 34 struct i915_ttm_buddy_manager *bman = to_buddy_manager(man);
88be9a0a06b73ec Matthew Auld 2021-06-16 35 struct i915_ttm_buddy_resource *bman_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 36 struct i915_buddy_mm *mm = &bman->mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 37 unsigned long n_pages;
88be9a0a06b73ec Matthew Auld 2021-06-16 38 unsigned int min_order;
88be9a0a06b73ec Matthew Auld 2021-06-16 39 u64 min_page_size;
88be9a0a06b73ec Matthew Auld 2021-06-16 40 u64 size;
88be9a0a06b73ec Matthew Auld 2021-06-16 41 int err;
88be9a0a06b73ec Matthew Auld 2021-06-16 42
88be9a0a06b73ec Matthew Auld 2021-06-16 43 GEM_BUG_ON(place->fpfn || place->lpfn);
88be9a0a06b73ec Matthew Auld 2021-06-16 44
88be9a0a06b73ec Matthew Auld 2021-06-16 45 bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL);
88be9a0a06b73ec Matthew Auld 2021-06-16 46 if (!bman_res)
88be9a0a06b73ec Matthew Auld 2021-06-16 47 return -ENOMEM;
88be9a0a06b73ec Matthew Auld 2021-06-16 48
88be9a0a06b73ec Matthew Auld 2021-06-16 49 ttm_resource_init(bo, place, &bman_res->base);
88be9a0a06b73ec Matthew Auld 2021-06-16 50 INIT_LIST_HEAD(&bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 51 bman_res->mm = mm;
88be9a0a06b73ec Matthew Auld 2021-06-16 52
88be9a0a06b73ec Matthew Auld 2021-06-16 53 GEM_BUG_ON(!bman_res->base.num_pages);
88be9a0a06b73ec Matthew Auld 2021-06-16 @54 size = bman_res->base.num_pages << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 55
88be9a0a06b73ec Matthew Auld 2021-06-16 56 min_page_size = bo->page_alignment << PAGE_SHIFT;
88be9a0a06b73ec Matthew Auld 2021-06-16 57 GEM_BUG_ON(min_page_size < mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 58 min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 59 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
88be9a0a06b73ec Matthew Auld 2021-06-16 60 size = roundup_pow_of_two(size);
88be9a0a06b73ec Matthew Auld 2021-06-16 61 min_order = ilog2(size) - ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 62 }
88be9a0a06b73ec Matthew Auld 2021-06-16 63
88be9a0a06b73ec Matthew Auld 2021-06-16 64 if (size > mm->size) {
88be9a0a06b73ec Matthew Auld 2021-06-16 65 err = -E2BIG;
88be9a0a06b73ec Matthew Auld 2021-06-16 66 goto err_free_res;
88be9a0a06b73ec Matthew Auld 2021-06-16 67 }
88be9a0a06b73ec Matthew Auld 2021-06-16 68
88be9a0a06b73ec Matthew Auld 2021-06-16 69 n_pages = size >> ilog2(mm->chunk_size);
88be9a0a06b73ec Matthew Auld 2021-06-16 70
88be9a0a06b73ec Matthew Auld 2021-06-16 71 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 72 struct i915_buddy_block *block;
88be9a0a06b73ec Matthew Auld 2021-06-16 73 unsigned int order;
88be9a0a06b73ec Matthew Auld 2021-06-16 74
88be9a0a06b73ec Matthew Auld 2021-06-16 75 order = fls(n_pages) - 1;
88be9a0a06b73ec Matthew Auld 2021-06-16 76 GEM_BUG_ON(order > mm->max_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 77 GEM_BUG_ON(order < min_order);
88be9a0a06b73ec Matthew Auld 2021-06-16 78
88be9a0a06b73ec Matthew Auld 2021-06-16 79 do {
88be9a0a06b73ec Matthew Auld 2021-06-16 80 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 81 block = i915_buddy_alloc(mm, order);
88be9a0a06b73ec Matthew Auld 2021-06-16 82 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 83 if (!IS_ERR(block))
88be9a0a06b73ec Matthew Auld 2021-06-16 84 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 85
88be9a0a06b73ec Matthew Auld 2021-06-16 86 if (order-- == min_order) {
88be9a0a06b73ec Matthew Auld 2021-06-16 87 err = -ENOSPC;
88be9a0a06b73ec Matthew Auld 2021-06-16 88 goto err_free_blocks;
88be9a0a06b73ec Matthew Auld 2021-06-16 89 }
88be9a0a06b73ec Matthew Auld 2021-06-16 90 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 91
88be9a0a06b73ec Matthew Auld 2021-06-16 92 n_pages -= BIT(order);
88be9a0a06b73ec Matthew Auld 2021-06-16 93
88be9a0a06b73ec Matthew Auld 2021-06-16 94 list_add_tail(&block->link, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 95
88be9a0a06b73ec Matthew Auld 2021-06-16 96 if (!n_pages)
88be9a0a06b73ec Matthew Auld 2021-06-16 97 break;
88be9a0a06b73ec Matthew Auld 2021-06-16 98 } while (1);
88be9a0a06b73ec Matthew Auld 2021-06-16 99
88be9a0a06b73ec Matthew Auld 2021-06-16 100 *res = &bman_res->base;
88be9a0a06b73ec Matthew Auld 2021-06-16 101 return 0;
88be9a0a06b73ec Matthew Auld 2021-06-16 102
88be9a0a06b73ec Matthew Auld 2021-06-16 103 err_free_blocks:
88be9a0a06b73ec Matthew Auld 2021-06-16 104 mutex_lock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 105 i915_buddy_free_list(mm, &bman_res->blocks);
88be9a0a06b73ec Matthew Auld 2021-06-16 106 mutex_unlock(&bman->lock);
88be9a0a06b73ec Matthew Auld 2021-06-16 107 err_free_res:
88be9a0a06b73ec Matthew Auld 2021-06-16 108 kfree(bman_res);
88be9a0a06b73ec Matthew Auld 2021-06-16 109 return err;
88be9a0a06b73ec Matthew Auld 2021-06-16 110 }
88be9a0a06b73ec 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2021-12-17 6:07 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-12-17 6:07 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 6986 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: 6441998e2e37131b0a4c310af9156d79d3351c16
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 6 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 6 months ago
config: i386-randconfig-m021-20211207 (https://download.01.org/0day-ci/archive/20211217/202112171318.cviU6AwG-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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2021-12-09 13:09 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-12-09 13:09 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 6985 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: 2a987e65025e2b79c6d453b78cb5985ac6e5eb26
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 6 months ago
:::::: branch date: 2 days ago
:::::: commit date: 6 months ago
config: i386-randconfig-m021-20211207 (https://download.01.org/0day-ci/archive/20211209/202112092127.ZWUiCnER-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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2021-11-26 0:47 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-11-26 0:47 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 6986 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: 8ced7ca3570333998ad2088d5a6275701970e28e
commit: 88be9a0a06b73ecd85a688a7c174c941e9692e92 drm/i915/ttm: add ttm_buddy_man
date: 5 months ago
:::::: branch date: 6 hours ago
:::::: commit date: 5 months ago
config: i386-randconfig-m021-20211124 (https://download.01.org/0day-ci/archive/20211126/202111260820.IgS60h1h-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
^ permalink raw reply [flat|nested] 9+ messages in thread
* 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?
@ 2021-11-24 18:26 kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-11-24 18:26 UTC (permalink / raw)
To: kbuild
[-- 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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-02-28 8:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 19:52 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
-- strict thread matches above, loose matches on Subject: below --
2022-02-28 8:31 kernel test robot
2022-02-10 0:51 kernel test robot
2022-02-09 2:27 kernel test robot
2021-12-21 2:43 kernel test robot
2021-12-17 6:07 kernel test robot
2021-12-09 13:09 kernel test robot
2021-11-26 0:47 kernel test robot
2021-11-24 18:26 kernel test robot
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.