Message ID | 20210408133134.6548-1-manivannan.sadhasivam@linaro.org |
---|---|
State | New |
Headers | show |
Series | [v2] bus: mhi: core: Fix shadow declarations | expand |
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@intel.com>
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@lists.01.org
diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index b0c8afe16e3a..47a8df550fe0 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -664,8 +664,6 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl, case MHI_EV_CC_OOB: case MHI_EV_CC_DB_MODE: { - unsigned long flags; - mhi_chan->db_cfg.db_mode = 1; read_lock_irqsave(&mhi_cntrl->pm_lock, flags); if (tre_ring->wp != tre_ring->rp && @@ -853,14 +851,14 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, break; case MHI_STATE_SYS_ERR: { - enum mhi_pm_state new_state; + enum mhi_pm_state pm_state; dev_dbg(dev, "System error detected\n"); write_lock_irq(&mhi_cntrl->pm_lock); - new_state = mhi_tryset_pm_state(mhi_cntrl, + pm_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_SYS_ERR_DETECT); write_unlock_irq(&mhi_cntrl->pm_lock); - if (new_state == MHI_PM_SYS_ERR_DETECT) + if (pm_state == MHI_PM_SYS_ERR_DETECT) mhi_pm_sys_err_handler(mhi_cntrl); break; }
This commit fixes below sparse warnings with W=2 about shadow declarations: drivers/bus/mhi/core/main.c: In function ‘parse_xfer_event’: drivers/bus/mhi/core/main.c:667:17: warning: declaration of ‘flags’ shadows a previous local [-Wshadow] 667 | unsigned long flags; | ^~~~~ drivers/bus/mhi/core/main.c:565:16: note: shadowed declaration is here 565 | unsigned long flags = 0; | ^~~~~ drivers/bus/mhi/core/main.c: In function ‘mhi_process_ctrl_ev_ring’: drivers/bus/mhi/core/main.c:856:23: warning: declaration of ‘new_state’ shadows a previous local [-Wshadow] 856 | enum mhi_pm_state new_state; | ^~~~~~~~~ drivers/bus/mhi/core/main.c:837:19: note: shadowed declaration is here 837 | enum mhi_state new_state; | ^~~~~~~~~ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> --- Changes in v2: * Used a separate "mhi_pm_state" variable drivers/bus/mhi/core/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.25.1