[isilence:rw-dmabuf-v4 8/14] drivers/nvme/host/pci.c:2429:33: sparse: sparse: symbol 'nvme_dmabuf_importer_ops' was not declared. Should it be static?

kernel test robot <[email protected]> Wed, 29 Jul 2026 16:22:56 +0800
Newsgroups dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://github.com/isilence/linux rw-dmabuf-v4
head:   26dcd0ae5c87a3ada5710b14b6894ef343cec6fe
commit: 19e5c945ea8114320c10f7951d19197d48b59249 [8/14] nvme-pci: implement dma_token backed requests
config: arm-randconfig-r131-20260729 (https://download.01.org/0day-ci/archive/20260729/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.5.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260729/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)
>> drivers/nvme/host/pci.c:2429:33: sparse: sparse: symbol 'nvme_dmabuf_importer_ops' was not declared. Should it be static?
>> drivers/nvme/host/pci.c:2504:29: sparse: sparse: symbol 'nvme_dma_buf_io_ops' was not declared. Should it be static?

vim +/nvme_dmabuf_importer_ops +2429 drivers/nvme/host/pci.c

  2428	
> 2429	const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {
  2430		.invalidate_mappings	= nvme_dmabuf_invalidate_mappings,
  2431		.allow_peer2peer	= true,
  2432	};
  2433	
  2434	static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)
  2435	{
  2436		unsigned nr_entries = ctx->dmabuf->size / NVME_CTRL_PAGE_SIZE;
  2437		struct dma_buf_attachment *attach = ctx->dev_priv;
  2438		unsigned long tmp, i = 0;
  2439		struct nvme_dmabuf_map *map;
  2440		struct scatterlist *sg;
  2441		struct sg_table *sgt;
  2442		int ret;
  2443	
  2444		dma_resv_assert_held(ctx->dmabuf->resv);
  2445	
  2446		map = kmalloc_flex(*map, dma_list, nr_entries);
  2447		if (!map)
  2448			return ERR_PTR(-ENOMEM);
  2449	
  2450		sgt = dma_buf_map_attachment(attach, ctx->dir);
  2451		if (IS_ERR(sgt)) {
  2452			ret = PTR_ERR(sgt);
  2453			sgt = NULL;
  2454			goto err;
  2455		}
  2456	
  2457		for_each_sgtable_dma_sg(sgt, sg, tmp) {
  2458			dma_addr_t dma_addr = sg_dma_address(sg);
  2459			unsigned long sg_len = sg_dma_len(sg);
  2460	
  2461			if (sg_len % NVME_CTRL_PAGE_SIZE) {
  2462				ret = -EINVAL;
  2463				goto err;
  2464			}
  2465	
  2466			while (sg_len) {
  2467				map->dma_list[i++] = dma_addr;
  2468				dma_addr += NVME_CTRL_PAGE_SIZE;
  2469				sg_len -= NVME_CTRL_PAGE_SIZE;
  2470			}
  2471		}
  2472	
  2473		ret = dma_buf_io_init_map(ctx, &map->base);
  2474		if (ret)
  2475			goto err;
  2476		map->nr_entries = nr_entries;
  2477		map->sgt = sgt;
  2478		return &map->base;
  2479	err:
  2480		if (sgt)
  2481			dma_buf_unmap_attachment(attach, sgt, ctx->dir);
  2482		kfree(map);
  2483		return ERR_PTR(ret);
  2484	}
  2485	
  2486	static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,
  2487					  struct dma_buf_io_map *map_base)
  2488	{
  2489		struct dma_buf_attachment *attach = ctx->dev_priv;
  2490		struct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);
  2491	
  2492		dma_resv_assert_held(ctx->dmabuf->resv);
  2493	
  2494		dma_buf_unmap_attachment(attach, map->sgt, ctx->dir);
  2495	}
  2496	
  2497	static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *ctx)
  2498	{
  2499		struct dma_buf_attachment *attach = ctx->dev_priv;
  2500	
  2501		dma_buf_detach(ctx->dmabuf, attach);
  2502	}
  2503	
> 2504	const struct dma_buf_io_ops nvme_dma_buf_io_ops = {
  2505		.map		= nvme_dma_buf_io_map,
  2506		.unmap		= nvme_dma_buf_io_unmap,
  2507		.release	= nvme_dma_buf_io_release,
  2508	};
  2509	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki