Re: [PATCH] dma-buf: fix and rework dma_buf_poll

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi "Christian,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20210616]
[cannot apply to tegra-drm/drm/tegra/for-next linus/master v5.13-rc6 v5.13-rc5 v5.13-rc4 v5.13-rc6]
[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]

url:    https://github.com/0day-ci/linux/commits/Christian-K-nig/dma-buf-fix-and-rework-dma_buf_poll/20210617-103036
base:    c7d4c1fd91ab4a6d2620497921a9c6bf54650ab8
config: x86_64-randconfig-r022-20210617 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401)
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
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/dfa9f2ec4c082b73e644e2c565e58e2291f94463
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christian-K-nig/dma-buf-fix-and-rework-dma_buf_poll/20210617-103036
        git checkout dfa9f2ec4c082b73e644e2c565e58e2291f94463
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/dma-buf/dma-buf.c:284:17: warning: variable 'fence_excl' is uninitialized when used here [-Wuninitialized]
                   dma_fence_put(fence_excl);
                                 ^~~~~~~~~~
   drivers/dma-buf/dma-buf.c:213:30: note: initialize the variable 'fence_excl' to silence this warning
           struct dma_fence *fence_excl;
                                       ^
                                        = NULL
   1 warning generated.


vim +/fence_excl +284 drivers/dma-buf/dma-buf.c

   206	
   207	static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
   208	{
   209		struct dma_buf_poll_cb_t *dcb;
   210		struct dma_buf *dmabuf;
   211		struct dma_resv *resv;
   212		struct dma_resv_list *fobj;
   213		struct dma_fence *fence_excl;
   214		unsigned shared_count, seq;
   215		struct dma_fence *fence;
   216		__poll_t events;
   217		int r, i;
   218	
   219		dmabuf = file->private_data;
   220		if (!dmabuf || !dmabuf->resv)
   221			return EPOLLERR;
   222	
   223		resv = dmabuf->resv;
   224	
   225		poll_wait(file, &dmabuf->poll, poll);
   226	
   227		events = poll_requested_events(poll) & (EPOLLIN | EPOLLOUT);
   228		if (!events)
   229			return 0;
   230	
   231		dcb = events & EPOLLOUT ? &dmabuf->cb_out : &dmabuf->cb_in;
   232	
   233		/* Only queue a new one if we are not still waiting for the old one */
   234		spin_lock_irq(&dmabuf->poll.lock);
   235		if (dcb->active)
   236			events = 0;
   237		else
   238			dcb->active = events;
   239		spin_unlock_irq(&dmabuf->poll.lock);
   240		if (!events)
   241			return 0;
   242	
   243	retry:
   244		seq = read_seqcount_begin(&resv->seq);
   245		rcu_read_lock();
   246	
   247		fobj = rcu_dereference(resv->fence);
   248		if (fobj && events & EPOLLOUT)
   249			shared_count = fobj->shared_count;
   250		else
   251			shared_count = 0;
   252	
   253		for (i = 0; i < shared_count; ++i) {
   254			fence = rcu_dereference(fobj->shared[i]);
   255			fence = dma_fence_get_rcu(fence);
   256			if (!fence || read_seqcount_retry(&resv->seq, seq)) {
   257				/* Concurrent modify detected, force re-check */
   258				dma_fence_put(fence);
   259				rcu_read_unlock();
   260				goto retry;
   261			}
   262	
   263			r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
   264			dma_fence_put(fence);
   265			if (!r) {
   266				/* Callback queued */
   267				events = 0;
   268				goto out;
   269			}
   270		}
   271	
   272		fence = dma_resv_excl_fence(resv);
   273		if (fence) {
   274			fence = dma_fence_get_rcu(fence);
   275			if (!fence || read_seqcount_retry(&resv->seq, seq)) {
   276				/* Concurrent modify detected, force re-check */
   277				dma_fence_put(fence);
   278				rcu_read_unlock();
   279				goto retry;
   280	
   281			}
   282	
   283			r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
 > 284			dma_fence_put(fence_excl);
   285			if (!r) {
   286				/* Callback queued */
   287				events = 0;
   288				goto out;
   289			}
   290		}
   291	
   292		/* No callback queued, wake up any additional waiters. */
   293		dma_buf_poll_cb(NULL, &dcb->cb);
   294	
   295	out:
   296		rcu_read_unlock();
   297		return events;
   298	}
   299	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux