Re: [PATCH v2] bus: mhi: core: Fix shadow declarations

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

 



Hi Manivannan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.12-rc6 next-20210408]
[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/Manivannan-Sadhasivam/bus-mhi-core-Fix-shadow-declarations/20210408-213242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 454859c552da78b0f587205d308401922b56863e
config: um-randconfig-c024-20210408 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

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


cocci warnings: (new ones prefixed by >>)
>> drivers/bus/mhi/core/main.c:599:2-19: ERROR: nested lock+irqsave that reuses flags from line 521.

vim +599 drivers/bus/mhi/core/main.c

1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  496  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  497  static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  498  			    struct mhi_tre *event,
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  499  			    struct mhi_chan *mhi_chan)
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  500  {
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  501  	struct mhi_ring *buf_ring, *tre_ring;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  502  	struct device *dev = &mhi_cntrl->mhi_dev->dev;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  503  	struct mhi_result result;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  504  	unsigned long flags = 0;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  505  	u32 ev_code;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  506  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  507  	ev_code = MHI_TRE_GET_EV_CODE(event);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  508  	buf_ring = &mhi_chan->buf_ring;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  509  	tre_ring = &mhi_chan->tre_ring;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  510  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  511  	result.transaction_status = (ev_code == MHI_EV_CC_OVERFLOW) ?
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  512  		-EOVERFLOW : 0;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  513  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  514  	/*
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  515  	 * If it's a DB Event then we need to grab the lock
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  516  	 * with preemption disabled and as a write because we
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  517  	 * have to update db register and there are chances that
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  518  	 * another thread could be doing the same.
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  519  	 */
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  520  	if (ev_code >= MHI_EV_CC_OOB)
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20 @521  		write_lock_irqsave(&mhi_chan->lock, flags);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  522  	else
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  523  		read_lock_bh(&mhi_chan->lock);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  524  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  525  	if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED)
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  526  		goto end_process_tx_event;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  527  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  528  	switch (ev_code) {
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  529  	case MHI_EV_CC_OVERFLOW:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  530  	case MHI_EV_CC_EOB:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  531  	case MHI_EV_CC_EOT:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  532  	{
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  533  		dma_addr_t ptr = MHI_TRE_GET_EV_PTR(event);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  534  		struct mhi_tre *local_rp, *ev_tre;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  535  		void *dev_rp;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  536  		struct mhi_buf_info *buf_info;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  537  		u16 xfer_len;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  538  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  539  		/* Get the TRB this event points to */
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  540  		ev_tre = mhi_to_virtual(tre_ring, ptr);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  541  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  542  		dev_rp = ev_tre + 1;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  543  		if (dev_rp >= (tre_ring->base + tre_ring->len))
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  544  			dev_rp = tre_ring->base;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  545  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  546  		result.dir = mhi_chan->dir;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  547  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  548  		local_rp = tre_ring->rp;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  549  		while (local_rp != dev_rp) {
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  550  			buf_info = buf_ring->rp;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  551  			/* If it's the last TRE, get length from the event */
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  552  			if (local_rp == ev_tre)
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  553  				xfer_len = MHI_TRE_GET_EV_LEN(event);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  554  			else
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  555  				xfer_len = buf_info->len;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  556  
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  557  			/* Unmap if it's not pre-mapped by client */
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  558  			if (likely(!buf_info->pre_mapped))
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  559  				mhi_cntrl->unmap_single(mhi_cntrl, buf_info);
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  560  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  561  			result.buf_addr = buf_info->cb_buf;
ee75cedf82d832 Hemant Kumar          2020-05-21  562  
ee75cedf82d832 Hemant Kumar          2020-05-21  563  			/* truncate to buf len if xfer_len is larger */
ee75cedf82d832 Hemant Kumar          2020-05-21  564  			result.bytes_xferd =
ee75cedf82d832 Hemant Kumar          2020-05-21  565  				min_t(u16, xfer_len, buf_info->len);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  566  			mhi_del_ring_element(mhi_cntrl, buf_ring);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  567  			mhi_del_ring_element(mhi_cntrl, tre_ring);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  568  			local_rp = tre_ring->rp;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  569  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  570  			/* notify client */
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  571  			mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  572  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  573  			if (mhi_chan->dir == DMA_TO_DEVICE)
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  574  				atomic_dec(&mhi_cntrl->pending_pkts);
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  575  
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  576  			/*
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  577  			 * Recycle the buffer if buffer is pre-allocated,
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  578  			 * if there is an error, not much we can do apart
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  579  			 * from dropping the packet
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  580  			 */
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  581  			if (mhi_chan->pre_alloc) {
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  582  				if (mhi_queue_buf(mhi_chan->mhi_dev,
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  583  						  mhi_chan->dir,
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  584  						  buf_info->cb_buf,
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  585  						  buf_info->len, MHI_EOT)) {
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  586  					dev_err(dev,
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  587  						"Error recycling buffer for chan:%d\n",
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  588  						mhi_chan->chan);
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  589  					kfree(buf_info->cb_buf);
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  590  				}
189ff97cca53e3 Manivannan Sadhasivam 2020-02-20  591  			}
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  592  		}
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  593  		break;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  594  	} /* CC_EOT */
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  595  	case MHI_EV_CC_OOB:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  596  	case MHI_EV_CC_DB_MODE:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  597  	{
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  598  		mhi_chan->db_cfg.db_mode = 1;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20 @599  		read_lock_irqsave(&mhi_cntrl->pm_lock, flags);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  600  		if (tre_ring->wp != tre_ring->rp &&
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  601  		    MHI_DB_ACCESS_VALID(mhi_cntrl)) {
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  602  			mhi_ring_chan_db(mhi_cntrl, mhi_chan);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  603  		}
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  604  		read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  605  		break;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  606  	}
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  607  	case MHI_EV_CC_BAD_TRE:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  608  	default:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  609  		dev_err(dev, "Unknown event 0x%x\n", ev_code);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  610  		break;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  611  	} /* switch(MHI_EV_READ_CODE(EV_TRB_CODE,event)) */
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  612  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  613  end_process_tx_event:
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  614  	if (ev_code >= MHI_EV_CC_OOB)
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  615  		write_unlock_irqrestore(&mhi_chan->lock, flags);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  616  	else
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  617  		read_unlock_bh(&mhi_chan->lock);
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  618  
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  619  	return 0;
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  620  }
1d3173a3bae703 Manivannan Sadhasivam 2020-02-20  621  

---
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 ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux