tree:
https://github.com/HabanaAI/linux.git habanalabs-next
head: 8397964b6986225daf410b3d6b36a8ffc3691d94
commit: f6a86ac0c29702622774e63f41d5bcdebdf4a300 [41/42] habanalabs: Add an option to map
CB to device MMU
config: powerpc-randconfig-r011-20200909 (attached as .config)
compiler: clang version 12.0.0 (
https://github.com/llvm/llvm-project
0a5dc7effb191eff740e0e7ae7bd8e1f6bdb3ad9)
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
git checkout f6a86ac0c29702622774e63f41d5bcdebdf4a300
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> drivers/misc/habanalabs/common/command_buffer.c:77:22: warning:
format specifies type 'unsigned long long' but the argument has type
'dma_addr_t' (aka 'unsigned int') [-Wformat]
va_block->start, bus_addr);
^~~~~~~~
include/linux/dev_printk.h:104:32: note: expanded from macro 'dev_err'
_dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
1 warning generated.
#
https://github.com/HabanaAI/linux/commit/f6a86ac0c29702622774e63f41d5bcde...
git remote add habanaai
https://github.com/HabanaAI/linux.git
git fetch --no-tags habanaai habanalabs-next
git checkout f6a86ac0c29702622774e63f41d5bcdebdf4a300
vim +77 drivers/misc/habanalabs/common/command_buffer.c
15
16 static int cb_map_mem(struct hl_ctx *ctx, struct hl_cb *cb)
17 {
18 struct hl_device *hdev = ctx->hdev;
19 struct asic_fixed_properties *prop = &hdev->asic_prop;
20 struct hl_vm_va_block *va_block, *tmp;
21 dma_addr_t bus_addr;
22 u64 virt_addr;
23 u32 page_size = prop->pmmu.page_size;
24 s32 offset;
25 int rc;
26
27 if (!hdev->supports_cb_mapping) {
28 dev_err_ratelimited(hdev->dev,
29 "Cannot map CB because no VA range is allocated for CB mapping\n");
30 return -EINVAL;
31 }
32
33 if (!hdev->mmu_enable) {
34 dev_err_ratelimited(hdev->dev,
35 "Cannot map CB because MMU is disabled\n");
36 return -EINVAL;
37 }
38
39 INIT_LIST_HEAD(&cb->va_block_list);
40
41 for (bus_addr = cb->bus_address;
42 bus_addr < cb->bus_address + cb->size;
43 bus_addr += page_size) {
44
45 virt_addr = (u64) gen_pool_alloc(ctx->cb_va_pool, page_size);
46 if (!virt_addr) {
47 dev_err(hdev->dev,
48 "Failed to allocate device virtual address for CB\n");
49 rc = -ENOMEM;
50 goto err_va_pool_free;
51 }
52
53 va_block = kzalloc(sizeof(*va_block), GFP_KERNEL);
54 if (!va_block) {
55 rc = -ENOMEM;
56 gen_pool_free(ctx->cb_va_pool, virt_addr, page_size);
57 goto err_va_pool_free;
58 }
59
60 va_block->start = virt_addr;
61 va_block->end = virt_addr + page_size;
62 va_block->size = page_size;
63 list_add_tail(&va_block->node, &cb->va_block_list);
64 }
65
66 mutex_lock(&ctx->mmu_lock);
67
68 bus_addr = cb->bus_address;
69 offset = 0;
70 list_for_each_entry(va_block, &cb->va_block_list, node) {
71 rc = hl_mmu_map(ctx, va_block->start, bus_addr, va_block->size,
72 list_is_last(&va_block->node,
73 &cb->va_block_list));
74 if (rc) {
75 dev_err(hdev->dev,
76 "Failed to map va %#llx to CB's pa %#llx\n",
77 va_block->start, bus_addr);
78 goto
err_va_umap;
79 }
80
81 bus_addr += va_block->size;
82 offset += va_block->size;
83 }
84
85 hdev->asic_funcs->mmu_invalidate_cache(hdev, false, VM_TYPE_USERPTR);
86
87 mutex_unlock(&ctx->mmu_lock);
88
89 cb->is_mmu_mapped = true;
90
91 return 0;
92
93 err_va_umap:
94 list_for_each_entry(va_block, &cb->va_block_list, node) {
95 if (offset <= 0)
96 break;
97 hl_mmu_unmap(ctx, va_block->start, va_block->size,
98 offset <= va_block->size);
99 offset -= va_block->size;
100 }
101
102 hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
103
104 mutex_unlock(&ctx->mmu_lock);
105
106 err_va_pool_free:
107 list_for_each_entry_safe(va_block, tmp, &cb->va_block_list, node) {
108 gen_pool_free(ctx->cb_va_pool, va_block->start, va_block->size);
109 list_del(&va_block->node);
110 kfree(va_block);
111 }
112
113 return rc;
114 }
115
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org