* [sbates130272-p2pmem:dev/amd-dma-buf 4/4] drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c:402:5: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int')
@ 2025-06-17 10:54 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-06-17 10:54 UTC (permalink / raw)
To: Harish Kasiviswanathan; +Cc: llvm, oe-kbuild-all, Stephen Bates
tree: https://github.com/sbates130272/linux-p2pmem.git dev/amd-dma-buf
head: 9dd4127ada3f673941734289f7a8a949e16332d8
commit: 9dd4127ada3f673941734289f7a8a949e16332d8 [4/4] drm/amdgpu: Use MEMORY_DEVICE_PCI_P2PDMA pages
config: arm-randconfig-004-20250617 (https://download.01.org/0day-ci/archive/20250617/202506171832.9tEmIvR1-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250617/202506171832.9tEmIvR1-lkp@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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506171832.9tEmIvR1-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c:402:5: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
401 | dev_info(amdgpu_ttm_adev(bo->tbo.bdev)->dev, "DMA-BUF bo->tbo.base.size:%lx\n",
| ~~~
| %zx
402 | bo->tbo.base.size);
| ^~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:160:67: note: expanded from macro 'dev_info'
160 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ~~~ ^~~~~~~~~~~
1 warning generated.
vim +402 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
345
346 static int amdgpu_rw_file(struct dma_buf *dmabuf, bool is_read,
347 bool direct_io, struct file *filp, loff_t file_offset,
348 size_t buf_offset, size_t len)
349 {
350 struct sg_table *sgt;
351 struct dma_buf_attachment attach;
352 struct dma_buf_attach_ops ops;
353 struct amdgpu_bo *bo;
354
355 struct bio_vec *bvec;
356 int nr_segs = 0;
357 struct iov_iter iter;
358 struct kiocb kiocb;
359 int ret = 0;
360 struct pci_dev *pdev;
361
362 printk(KERN_INFO "is_read = %d!\n", is_read);
363 printk(KERN_INFO "file_offset = %lld!\n", file_offset);
364 printk(KERN_INFO "buf_offset = %zd!\n", buf_offset);
365 printk(KERN_INFO "len = %zd!\n", len);
366
367 if (direct_io) {
368 if (!(filp->f_mode & FMODE_CAN_ODIRECT))
369 return -EINVAL;
370 }
371
372 memset(&attach, 0, sizeof(attach));
373 ops.allow_peer2peer = true;
374 attach.dmabuf = dmabuf;
375 attach.peer2peer = true;
376 attach.importer_ops = &ops;
377 /*
378 * SUPER HACK. Need to find the correct way to locate the
379 * DMA-capable parent of file based on either struct file or the
380 * file descriptor.
381 */
382 attach.dev = filp->f_path.mnt->mnt_sb->s_bdev->bd_device.parent->parent;
383 if (!attach.dev->dma_mask) {
384 /* The above hack didn't work. So hard code it for now */
385 pdev = pci_get_domain_bus_and_slot(0, 0x41, PCI_DEVFN(0, 0));
386 attach.dev = &pdev->dev;
387 }
388
389 sgt = dma_buf_map_attachment_unlocked(&attach, DMA_BIDIRECTIONAL);
390 if (IS_ERR(sgt)) {
391 ret = PTR_ERR(sgt);
392 goto out;
393 }
394
395 bo = gem_to_amdgpu_bo(dmabuf->priv);
396 if (!bo) {
397 ret = -EINVAL;
398 goto out;
399 } else {
400 /* Show BO domain to cross-check if it is in VRAM */
401 dev_info(amdgpu_ttm_adev(bo->tbo.bdev)->dev, "DMA-BUF bo->tbo.base.size:%lx\n",
> 402 bo->tbo.base.size);
403 dev_info(amdgpu_ttm_adev(bo->tbo.bdev)->dev, "mem_type:%x start:%lx size:%zx placement:%x\n",
404 bo->tbo.resource->mem_type, bo->tbo.resource->start,
405 bo->tbo.resource->size, bo->tbo.resource->placement);
406 }
407
408 if (pci_p2pdma_distance(pdev, amdgpu_ttm_adev(bo->tbo.bdev)->dev, false) < 0) {
409 dev_info(amdgpu_ttm_adev(bo->tbo.bdev)->dev,
410 "DMA-BUF p2p not accessible!\n");
411 ret = -ENODEV;
412 goto out;
413 }
414
415 bvec = amdgpu_init_bvec(sgt, buf_offset, len, &nr_segs);
416 if (!bvec) {
417 ret = -ENOMEM;
418 goto out;
419 }
420
421 iov_iter_bvec(&iter, is_read ? ITER_DEST : ITER_SOURCE, bvec, nr_segs, len);
422 init_sync_kiocb(&kiocb, filp);
423 kiocb.ki_pos = file_offset;
424 if (direct_io)
425 kiocb.ki_flags |= IOCB_DIRECT;
426
427 while (kiocb.ki_pos < file_offset + len) {
428
429 if (is_read)
430 ret = vfs_iocb_iter_read(filp, &kiocb, &iter);
431 else
432 ret = vfs_iocb_iter_write(filp, &kiocb, &iter);
433 if (ret <= 0)
434 break;
435 }
436
437 kvfree(bvec);
438 dma_buf_unmap_attachment_unlocked(&attach, sgt,
439 DMA_BIDIRECTIONAL);
440 out:
441 return ret < 0 ? ret : 0;
442 }
443
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-17 10:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 10:54 [sbates130272-p2pmem:dev/amd-dma-buf 4/4] drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c:402:5: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox