Hi Christian,
I love your patch! Perhaps something to improve:
[auto build test WARNING on v6.1-rc8] [also build test WARNING on linus/master] [cannot apply to drm-misc/drm-misc-next next-20221206] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-K-nig/dma-buf-fix-d... patch link: https://lore.kernel.org/r/20221206151207.8801-1-christian.koenig%40amd.com patch subject: [PATCH] dma-buf: fix dma_buf_export init order config: m68k-allyesconfig compiler: m68k-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/aa1f28d40a4dc78408327baefb83ee... git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Christian-K-nig/dma-buf-fix-dma_buf_export-init-order/20221206-231311 git checkout aa1f28d40a4dc78408327baefb83ee8fd34b6ef9 # 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=m68k SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot lkp@intel.com
All warnings (new ones prefixed by >>):
drivers/dma-buf/dma-buf.c: In function 'dma_buf_export':
drivers/dma-buf/dma-buf.c:633:40: warning: passing argument 1 of 'dma_buf_getfile' makes pointer from integer without a cast [-Wint-conversion]
633 | file = dma_buf_getfile(exp_info->size, exp_info->flags); | ~~~~~~~~^~~~~~ | | | size_t {aka unsigned int} drivers/dma-buf/dma-buf.c:526:53: note: expected 'struct dma_buf *' but argument is of type 'size_t' {aka 'unsigned int'} 526 | static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags) | ~~~~~~~~~~~~~~~~^~~~~~
vim +/dma_buf_getfile +633 drivers/dma-buf/dma-buf.c
559 560 /** 561 * DOC: dma buf device access 562 * 563 * For device DMA access to a shared DMA buffer the usual sequence of operations 564 * is fairly simple: 565 * 566 * 1. The exporter defines his exporter instance using 567 * DEFINE_DMA_BUF_EXPORT_INFO() and calls dma_buf_export() to wrap a private 568 * buffer object into a &dma_buf. It then exports that &dma_buf to userspace 569 * as a file descriptor by calling dma_buf_fd(). 570 * 571 * 2. Userspace passes this file-descriptors to all drivers it wants this buffer 572 * to share with: First the file descriptor is converted to a &dma_buf using 573 * dma_buf_get(). Then the buffer is attached to the device using 574 * dma_buf_attach(). 575 * 576 * Up to this stage the exporter is still free to migrate or reallocate the 577 * backing storage. 578 * 579 * 3. Once the buffer is attached to all devices userspace can initiate DMA 580 * access to the shared buffer. In the kernel this is done by calling 581 * dma_buf_map_attachment() and dma_buf_unmap_attachment(). 582 * 583 * 4. Once a driver is done with a shared buffer it needs to call 584 * dma_buf_detach() (after cleaning up any mappings) and then release the 585 * reference acquired with dma_buf_get() by calling dma_buf_put(). 586 * 587 * For the detailed semantics exporters are expected to implement see 588 * &dma_buf_ops. 589 */ 590 591 /** 592 * dma_buf_export - Creates a new dma_buf, and associates an anon file 593 * with this buffer, so it can be exported. 594 * Also connect the allocator specific data and ops to the buffer. 595 * Additionally, provide a name string for exporter; useful in debugging. 596 * 597 * @exp_info: [in] holds all the export related information provided 598 * by the exporter. see &struct dma_buf_export_info 599 * for further details. 600 * 601 * Returns, on success, a newly created struct dma_buf object, which wraps the 602 * supplied private data and operations for struct dma_buf_ops. On either 603 * missing ops, or error in allocating struct dma_buf, will return negative 604 * error. 605 * 606 * For most cases the easiest way to create @exp_info is through the 607 * %DEFINE_DMA_BUF_EXPORT_INFO macro. 608 */ 609 struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info) 610 { 611 struct dma_buf *dmabuf; 612 struct dma_resv *resv = exp_info->resv; 613 struct file *file; 614 size_t alloc_size = sizeof(struct dma_buf); 615 int ret; 616 617 if (WARN_ON(!exp_info->priv || !exp_info->ops 618 || !exp_info->ops->map_dma_buf 619 || !exp_info->ops->unmap_dma_buf 620 || !exp_info->ops->release)) 621 return ERR_PTR(-EINVAL); 622 623 if (WARN_ON(exp_info->ops->cache_sgt_mapping && 624 (exp_info->ops->pin || exp_info->ops->unpin))) 625 return ERR_PTR(-EINVAL); 626 627 if (WARN_ON(!exp_info->ops->pin != !exp_info->ops->unpin)) 628 return ERR_PTR(-EINVAL); 629 630 if (!try_module_get(exp_info->owner)) 631 return ERR_PTR(-ENOENT); 632
633 file = dma_buf_getfile(exp_info->size, exp_info->flags);
634 if (IS_ERR(file)) { 635 ret = PTR_ERR(file); 636 goto err_module; 637 } 638 639 if (!exp_info->resv) 640 alloc_size += sizeof(struct dma_resv); 641 else 642 /* prevent &dma_buf[1] == dma_buf->resv */ 643 alloc_size += 1; 644 dmabuf = kzalloc(alloc_size, GFP_KERNEL); 645 if (!dmabuf) { 646 ret = -ENOMEM; 647 goto err_file; 648 } 649 650 dmabuf->priv = exp_info->priv; 651 dmabuf->ops = exp_info->ops; 652 dmabuf->size = exp_info->size; 653 dmabuf->exp_name = exp_info->exp_name; 654 dmabuf->owner = exp_info->owner; 655 spin_lock_init(&dmabuf->name_lock); 656 init_waitqueue_head(&dmabuf->poll); 657 dmabuf->cb_in.poll = dmabuf->cb_out.poll = &dmabuf->poll; 658 dmabuf->cb_in.active = dmabuf->cb_out.active = 0; 659 mutex_init(&dmabuf->lock); 660 INIT_LIST_HEAD(&dmabuf->attachments); 661 662 if (!resv) { 663 dmabuf->resv = (struct dma_resv *)&dmabuf[1]; 664 dma_resv_init(dmabuf->resv); 665 } else { 666 dmabuf->resv = resv; 667 } 668 669 ret = dma_buf_stats_setup(dmabuf, file); 670 if (ret) 671 goto err_dmabuf; 672 673 file->private_data = dmabuf; 674 file->f_path.dentry->d_fsdata = dmabuf; 675 dmabuf->file = file; 676 677 mutex_lock(&db_list.lock); 678 list_add(&dmabuf->list_node, &db_list.head); 679 mutex_unlock(&db_list.lock); 680 681 return dmabuf; 682 683 err_dmabuf: 684 if (!resv) 685 dma_resv_fini(dmabuf->resv); 686 kfree(dmabuf); 687 err_file: 688 fput(file); 689 err_module: 690 module_put(exp_info->owner); 691 return ERR_PTR(ret); 692 } 693 EXPORT_SYMBOL_NS_GPL(dma_buf_export, DMA_BUF); 694