Hi Maxime, kernel test robot noticed the following build warnings:
[auto build test WARNING on a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6] url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Ripard/dma-buf-heaps-Introduce-a-new-heap-for-reserved-memory/20240515-215850 base: a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6 patch link: https://lore.kernel.org/r/20240515-dma-buf-ecc-heap-v1-7-54cbbd049511%40kernel.org patch subject: [PATCH 7/8] dma-buf: heaps: cma: Handle ECC flags config: mips-allmodconfig (https://download.01.org/0day-ci/archive/20240516/202405161341.xbeps2s0-...@intel.com/config) compiler: mips-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240516/202405161341.xbeps2s0-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <l...@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202405161341.xbeps2s0-...@intel.com/ All warnings (new ones prefixed by >>): drivers/dma-buf/heaps/cma_heap.c: In function 'cma_heap_allocate': >> drivers/dma-buf/heaps/cma_heap.c:293:24: warning: returning 'int' from a >> function with return type 'struct dma_buf *' makes pointer from integer >> without a cast [-Wint-conversion] 293 | return -EINVAL; | ^ drivers/dma-buf/heaps/cma_heap.c:296:24: warning: returning 'int' from a function with return type 'struct dma_buf *' makes pointer from integer without a cast [-Wint-conversion] 296 | return -EINVAL; | ^ drivers/dma-buf/heaps/cma_heap.c: In function '__add_cma_heap': drivers/dma-buf/heaps/cma_heap.c:386:13: error: implicit declaration of function 'of_memory_get_ecc_correction_bits' [-Werror=implicit-function-declaration] 386 | if (of_memory_get_ecc_correction_bits() > 0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +293 drivers/dma-buf/heaps/cma_heap.c 275 276 static struct dma_buf *cma_heap_allocate(struct dma_heap *heap, 277 unsigned long len, 278 unsigned long fd_flags, 279 unsigned long heap_flags) 280 { 281 struct cma_heap *cma_heap = dma_heap_get_drvdata(heap); 282 struct cma_heap_buffer *buffer; 283 DEFINE_DMA_BUF_EXPORT_INFO(exp_info); 284 size_t size = PAGE_ALIGN(len); 285 pgoff_t pagecount = size >> PAGE_SHIFT; 286 unsigned long align = get_order(size); 287 struct page *cma_pages; 288 struct dma_buf *dmabuf; 289 int ret = -ENOMEM; 290 pgoff_t pg; 291 292 if (!cma_heap->ecc_enabled && (heap_flags & DMA_HEAP_FLAG_ECC_PROTECTED)) > 293 return -EINVAL; 294 295 if (cma_heap->ecc_enabled && (heap_flags & DMA_HEAP_FLAG_ECC_UNPROTECTED)) 296 return -EINVAL; 297 298 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 299 if (!buffer) 300 return ERR_PTR(-ENOMEM); 301 302 INIT_LIST_HEAD(&buffer->attachments); 303 mutex_init(&buffer->lock); 304 buffer->len = size; 305 306 if (align > CONFIG_CMA_ALIGNMENT) 307 align = CONFIG_CMA_ALIGNMENT; 308 309 cma_pages = cma_alloc(cma_heap->cma, pagecount, align, false); 310 if (!cma_pages) 311 goto free_buffer; 312 313 /* Clear the cma pages */ 314 if (PageHighMem(cma_pages)) { 315 unsigned long nr_clear_pages = pagecount; 316 struct page *page = cma_pages; 317 318 while (nr_clear_pages > 0) { 319 void *vaddr = kmap_atomic(page); 320 321 memset(vaddr, 0, PAGE_SIZE); 322 kunmap_atomic(vaddr); 323 /* 324 * Avoid wasting time zeroing memory if the process 325 * has been killed by by SIGKILL 326 */ 327 if (fatal_signal_pending(current)) 328 goto free_cma; 329 page++; 330 nr_clear_pages--; 331 } 332 } else { 333 memset(page_address(cma_pages), 0, size); 334 } 335 336 buffer->pages = kmalloc_array(pagecount, sizeof(*buffer->pages), GFP_KERNEL); 337 if (!buffer->pages) { 338 ret = -ENOMEM; 339 goto free_cma; 340 } 341 342 for (pg = 0; pg < pagecount; pg++) 343 buffer->pages[pg] = &cma_pages[pg]; 344 345 buffer->cma_pages = cma_pages; 346 buffer->heap = cma_heap; 347 buffer->pagecount = pagecount; 348 349 /* create the dmabuf */ 350 exp_info.exp_name = dma_heap_get_name(heap); 351 exp_info.ops = &cma_heap_buf_ops; 352 exp_info.size = buffer->len; 353 exp_info.flags = fd_flags; 354 exp_info.priv = buffer; 355 dmabuf = dma_buf_export(&exp_info); 356 if (IS_ERR(dmabuf)) { 357 ret = PTR_ERR(dmabuf); 358 goto free_pages; 359 } 360 return dmabuf; 361 362 free_pages: 363 kfree(buffer->pages); 364 free_cma: 365 cma_release(cma_heap->cma, cma_pages, pagecount); 366 free_buffer: 367 kfree(buffer); 368 369 return ERR_PTR(ret); 370 } 371 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki