Subject: Re: [PATCH 6/7] nouveau/dmem: Evict device private memory during release

From: kernel test robot <[email-masked]>
Date: Mon, 26 Sep 2022 21:28:28 +0800

Hi Alistair,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on 088b8aa537c2c767765f1c19b555f21ffe555786]

url:    https://github.com/intel-lab-lkp/linux/commits/Alistair-Popple/Fix-several-device-private-page-reference-counting-issues/20220926-140640
base:   088b8aa537c2c767765f1c19b555f21ffe555786
config: arm64-allyesconfig
compiler: aarch64-linux-gcc (GCC) 12.1.0
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
        # https://github.com/intel-lab-lkp/linux/commit/e99dcd1c3eb07d0787b26d7df178659aec9e3c74
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Alistair-Popple/Fix-several-device-private-page-reference-counting-issues/20220926-140640
        git checkout e99dcd1c3eb07d0787b26d7df178659aec9e3c74
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/nouveau/nouveau_dmem.c:376:1: warning: no previous prototype for 'nouveau_dmem_evict_chunk' [-Wmissing-prototypes]
     376 | nouveau_dmem_evict_chunk(struct nouveau_dmem_chunk *chunk)
         | ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/nouveau_dmem_evict_chunk +376 drivers/gpu/drm/nouveau/nouveau_dmem.c

   371	
   372	/*
   373	 * Evict all pages mapping a chunk.
   374	 */
   375	void
 > 376	nouveau_dmem_evict_chunk(struct nouveau_dmem_chunk *chunk)
   377	{
   378		unsigned long i, npages = range_len(&chunk->pagemap.range) >> PAGE_SHIFT;
   379		unsigned long *src_pfns, *dst_pfns;
   380		dma_addr_t *dma_addrs;
   381		struct nouveau_fence *fence;
   382	
   383		src_pfns = kcalloc(npages, sizeof(*src_pfns), GFP_KERNEL);
   384		dst_pfns = kcalloc(npages, sizeof(*dst_pfns), GFP_KERNEL);
   385		dma_addrs = kcalloc(npages, sizeof(*dma_addrs), GFP_KERNEL);
   386	
   387		migrate_device_range(src_pfns, chunk->pagemap.range.start >> PAGE_SHIFT,
   388				npages);
   389	
   390		for (i = 0; i < npages; i++) {
   391			if (src_pfns[i] & MIGRATE_PFN_MIGRATE) {
   392				struct page *dpage;
   393	
   394				/*
   395				 * _GFP_NOFAIL because the GPU is going away and there
   396				 * is nothing sensible we can do if we can't copy the
   397				 * data back.
   398				 */
   399				dpage = alloc_page(GFP_HIGHUSER | __GFP_NOFAIL);
   400				dst_pfns[i] = migrate_pfn(page_to_pfn(dpage));
   401				nouveau_dmem_copy_one(chunk->drm,
   402						migrate_pfn_to_page(src_pfns[i]), dpage,
   403						&dma_addrs[i]);
   404			}
   405		}
   406	
   407		nouveau_fence_new(chunk->drm->dmem->migrate.chan, false, &fence);
   408		migrate_device_pages(src_pfns, dst_pfns, npages);
   409		nouveau_dmem_fence_done(&fence);
   410		migrate_device_finalize(src_pfns, dst_pfns, npages);
   411		kfree(src_pfns);
   412		kfree(dst_pfns);
   413		for (i = 0; i < npages; i++)
   414			dma_unmap_page(chunk->drm->dev->dev, dma_addrs[i], PAGE_SIZE, DMA_BIDIRECTIONAL);
   415		kfree(dma_addrs);
   416	}
   417	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp