Message ID | 20240524-xhci-deadcode-v1-1-a4453a756e0f@marcan.st (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xhci: Remove dead code in xhci_move_dequeue_past_td() | expand |
On 24.5.2024 10.07, Hector Martin wrote: > This codepath is trivially dead, since the function is never called with > a non-NULL td (the only callsite is immediately preceded by a NULL guard). > Yes, thanks, adding to queue. Comment below tells this was destined to be removed earlier. > - * We shouldn't hit this anymore as cached cancelled TRBs are given back > - * after clearing the cache, but be on the safe side and keep it anyway > - */ > - if (!td) { ... Thanks Mathias
Hi Hector,
kernel test robot noticed the following build warnings:
[auto build test WARNING on a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6]
url: https://github.com/intel-lab-lkp/linux/commits/Hector-Martin/xhci-Remove-dead-code-in-xhci_move_dequeue_past_td/20240524-151544
base: a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6
patch link: https://lore.kernel.org/r/20240524-xhci-deadcode-v1-1-a4453a756e0f%40marcan.st
patch subject: [PATCH] xhci: Remove dead code in xhci_move_dequeue_past_td()
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20240524/202405241753.Idenkg7C-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 7aa382fd7257d9bd4f7fc50bb7078a3c26a1628c)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405241753.Idenkg7C-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/202405241753.Idenkg7C-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/usb/host/xhci-ring.c:55:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2210:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
>> drivers/usb/host/xhci-ring.c:695:1: warning: unused label 'deq_found' [-Wunused-label]
695 | deq_found:
| ^~~~~~~~~~
2 warnings generated.
vim +/deq_found +695 drivers/usb/host/xhci-ring.c
e6b20121c6d5d1 Mathias Nyman 2017-06-02 633
d1dbfb942c33bf Mathias Nyman 2021-01-29 634 static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
d1dbfb942c33bf Mathias Nyman 2021-01-29 635 unsigned int slot_id, unsigned int ep_index,
d1dbfb942c33bf Mathias Nyman 2021-01-29 636 unsigned int stream_id, struct xhci_td *td)
d1dbfb942c33bf Mathias Nyman 2021-01-29 637 {
d1dbfb942c33bf Mathias Nyman 2021-01-29 638 struct xhci_virt_device *dev = xhci->devs[slot_id];
d1dbfb942c33bf Mathias Nyman 2021-01-29 639 struct xhci_virt_ep *ep = &dev->eps[ep_index];
d1dbfb942c33bf Mathias Nyman 2021-01-29 640 struct xhci_ring *ep_ring;
d1dbfb942c33bf Mathias Nyman 2021-01-29 641 struct xhci_command *cmd;
d1dbfb942c33bf Mathias Nyman 2021-01-29 642 struct xhci_segment *new_seg;
d1dbfb942c33bf Mathias Nyman 2021-01-29 643 union xhci_trb *new_deq;
d1dbfb942c33bf Mathias Nyman 2021-01-29 644 int new_cycle;
d1dbfb942c33bf Mathias Nyman 2021-01-29 645 dma_addr_t addr;
d1dbfb942c33bf Mathias Nyman 2021-01-29 646 u64 hw_dequeue;
d1dbfb942c33bf Mathias Nyman 2021-01-29 647 bool cycle_found = false;
d1dbfb942c33bf Mathias Nyman 2021-01-29 648 bool td_last_trb_found = false;
d1dbfb942c33bf Mathias Nyman 2021-01-29 649 u32 trb_sct = 0;
d1dbfb942c33bf Mathias Nyman 2021-01-29 650 int ret;
d1dbfb942c33bf Mathias Nyman 2021-01-29 651
d1dbfb942c33bf Mathias Nyman 2021-01-29 652 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
d1dbfb942c33bf Mathias Nyman 2021-01-29 653 ep_index, stream_id);
d1dbfb942c33bf Mathias Nyman 2021-01-29 654 if (!ep_ring) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 655 xhci_warn(xhci, "WARN can't find new dequeue, invalid stream ID %u\n",
d1dbfb942c33bf Mathias Nyman 2021-01-29 656 stream_id);
d1dbfb942c33bf Mathias Nyman 2021-01-29 657 return -ENODEV;
d1dbfb942c33bf Mathias Nyman 2021-01-29 658 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 659
d1dbfb942c33bf Mathias Nyman 2021-01-29 660 hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id);
d1dbfb942c33bf Mathias Nyman 2021-01-29 661 new_seg = ep_ring->deq_seg;
d1dbfb942c33bf Mathias Nyman 2021-01-29 662 new_deq = ep_ring->dequeue;
d1dbfb942c33bf Mathias Nyman 2021-01-29 663 new_cycle = hw_dequeue & 0x1;
d1dbfb942c33bf Mathias Nyman 2021-01-29 664
d1dbfb942c33bf Mathias Nyman 2021-01-29 665 /*
d1dbfb942c33bf Mathias Nyman 2021-01-29 666 * We want to find the pointer, segment and cycle state of the new trb
d1dbfb942c33bf Mathias Nyman 2021-01-29 667 * (the one after current TD's last_trb). We know the cycle state at
d1dbfb942c33bf Mathias Nyman 2021-01-29 668 * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
d1dbfb942c33bf Mathias Nyman 2021-01-29 669 * found.
d1dbfb942c33bf Mathias Nyman 2021-01-29 670 */
d1dbfb942c33bf Mathias Nyman 2021-01-29 671 do {
d1dbfb942c33bf Mathias Nyman 2021-01-29 672 if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
d1dbfb942c33bf Mathias Nyman 2021-01-29 673 == (dma_addr_t)(hw_dequeue & ~0xf)) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 674 cycle_found = true;
d1dbfb942c33bf Mathias Nyman 2021-01-29 675 if (td_last_trb_found)
d1dbfb942c33bf Mathias Nyman 2021-01-29 676 break;
d1dbfb942c33bf Mathias Nyman 2021-01-29 677 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 678 if (new_deq == td->last_trb)
d1dbfb942c33bf Mathias Nyman 2021-01-29 679 td_last_trb_found = true;
d1dbfb942c33bf Mathias Nyman 2021-01-29 680
d1dbfb942c33bf Mathias Nyman 2021-01-29 681 if (cycle_found && trb_is_link(new_deq) &&
d1dbfb942c33bf Mathias Nyman 2021-01-29 682 link_trb_toggles_cycle(new_deq))
d1dbfb942c33bf Mathias Nyman 2021-01-29 683 new_cycle ^= 0x1;
d1dbfb942c33bf Mathias Nyman 2021-01-29 684
d1dbfb942c33bf Mathias Nyman 2021-01-29 685 next_trb(xhci, ep_ring, &new_seg, &new_deq);
d1dbfb942c33bf Mathias Nyman 2021-01-29 686
d1dbfb942c33bf Mathias Nyman 2021-01-29 687 /* Search wrapped around, bail out */
d1dbfb942c33bf Mathias Nyman 2021-01-29 688 if (new_deq == ep->ring->dequeue) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 689 xhci_err(xhci, "Error: Failed finding new dequeue state\n");
d1dbfb942c33bf Mathias Nyman 2021-01-29 690 return -EINVAL;
d1dbfb942c33bf Mathias Nyman 2021-01-29 691 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 692
d1dbfb942c33bf Mathias Nyman 2021-01-29 693 } while (!cycle_found || !td_last_trb_found);
d1dbfb942c33bf Mathias Nyman 2021-01-29 694
d1dbfb942c33bf Mathias Nyman 2021-01-29 @695 deq_found:
d1dbfb942c33bf Mathias Nyman 2021-01-29 696
d1dbfb942c33bf Mathias Nyman 2021-01-29 697 /* Don't update the ring cycle state for the producer (us). */
d1dbfb942c33bf Mathias Nyman 2021-01-29 698 addr = xhci_trb_virt_to_dma(new_seg, new_deq);
d1dbfb942c33bf Mathias Nyman 2021-01-29 699 if (addr == 0) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 700 xhci_warn(xhci, "Can't find dma of new dequeue ptr\n");
d1dbfb942c33bf Mathias Nyman 2021-01-29 701 xhci_warn(xhci, "deq seg = %p, deq ptr = %p\n", new_seg, new_deq);
d1dbfb942c33bf Mathias Nyman 2021-01-29 702 return -EINVAL;
d1dbfb942c33bf Mathias Nyman 2021-01-29 703 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 704
d1dbfb942c33bf Mathias Nyman 2021-01-29 705 if ((ep->ep_state & SET_DEQ_PENDING)) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 706 xhci_warn(xhci, "Set TR Deq already pending, don't submit for 0x%pad\n",
d1dbfb942c33bf Mathias Nyman 2021-01-29 707 &addr);
d1dbfb942c33bf Mathias Nyman 2021-01-29 708 return -EBUSY;
d1dbfb942c33bf Mathias Nyman 2021-01-29 709 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 710
d1dbfb942c33bf Mathias Nyman 2021-01-29 711 /* This function gets called from contexts where it cannot sleep */
d1dbfb942c33bf Mathias Nyman 2021-01-29 712 cmd = xhci_alloc_command(xhci, false, GFP_ATOMIC);
d1dbfb942c33bf Mathias Nyman 2021-01-29 713 if (!cmd) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 714 xhci_warn(xhci, "Can't alloc Set TR Deq cmd 0x%pad\n", &addr);
d1dbfb942c33bf Mathias Nyman 2021-01-29 715 return -ENOMEM;
d1dbfb942c33bf Mathias Nyman 2021-01-29 716 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 717
d1dbfb942c33bf Mathias Nyman 2021-01-29 718 if (stream_id)
d1dbfb942c33bf Mathias Nyman 2021-01-29 719 trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
d1dbfb942c33bf Mathias Nyman 2021-01-29 720 ret = queue_command(xhci, cmd,
d1dbfb942c33bf Mathias Nyman 2021-01-29 721 lower_32_bits(addr) | trb_sct | new_cycle,
d1dbfb942c33bf Mathias Nyman 2021-01-29 722 upper_32_bits(addr),
d1dbfb942c33bf Mathias Nyman 2021-01-29 723 STREAM_ID_FOR_TRB(stream_id), SLOT_ID_FOR_TRB(slot_id) |
d1dbfb942c33bf Mathias Nyman 2021-01-29 724 EP_ID_FOR_TRB(ep_index) | TRB_TYPE(TRB_SET_DEQ), false);
d1dbfb942c33bf Mathias Nyman 2021-01-29 725 if (ret < 0) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 726 xhci_free_command(xhci, cmd);
d1dbfb942c33bf Mathias Nyman 2021-01-29 727 return ret;
d1dbfb942c33bf Mathias Nyman 2021-01-29 728 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 729 ep->queued_deq_seg = new_seg;
d1dbfb942c33bf Mathias Nyman 2021-01-29 730 ep->queued_deq_ptr = new_deq;
d1dbfb942c33bf Mathias Nyman 2021-01-29 731
d1dbfb942c33bf Mathias Nyman 2021-01-29 732 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
d1dbfb942c33bf Mathias Nyman 2021-01-29 733 "Set TR Deq ptr 0x%llx, cycle %u\n", addr, new_cycle);
d1dbfb942c33bf Mathias Nyman 2021-01-29 734
d1dbfb942c33bf Mathias Nyman 2021-01-29 735 /* Stop the TD queueing code from ringing the doorbell until
d1dbfb942c33bf Mathias Nyman 2021-01-29 736 * this command completes. The HC won't set the dequeue pointer
d1dbfb942c33bf Mathias Nyman 2021-01-29 737 * if the ring is running, and ringing the doorbell starts the
d1dbfb942c33bf Mathias Nyman 2021-01-29 738 * ring running.
d1dbfb942c33bf Mathias Nyman 2021-01-29 739 */
d1dbfb942c33bf Mathias Nyman 2021-01-29 740 ep->ep_state |= SET_DEQ_PENDING;
d1dbfb942c33bf Mathias Nyman 2021-01-29 741 xhci_ring_cmd_db(xhci);
d1dbfb942c33bf Mathias Nyman 2021-01-29 742 return 0;
d1dbfb942c33bf Mathias Nyman 2021-01-29 743 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 744
Hi Hector,
kernel test robot noticed the following build warnings:
[auto build test WARNING on a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6]
url: https://github.com/intel-lab-lkp/linux/commits/Hector-Martin/xhci-Remove-dead-code-in-xhci_move_dequeue_past_td/20240524-151544
base: a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6
patch link: https://lore.kernel.org/r/20240524-xhci-deadcode-v1-1-a4453a756e0f%40marcan.st
patch subject: [PATCH] xhci: Remove dead code in xhci_move_dequeue_past_td()
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20240524/202405241706.h0PyUQfL-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405241706.h0PyUQfL-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/202405241706.h0PyUQfL-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/usb/host/xhci-ring.c: In function 'xhci_move_dequeue_past_td':
>> drivers/usb/host/xhci-ring.c:695:1: warning: label 'deq_found' defined but not used [-Wunused-label]
695 | deq_found:
| ^~~~~~~~~
vim +/deq_found +695 drivers/usb/host/xhci-ring.c
e6b20121c6d5d1 Mathias Nyman 2017-06-02 633
d1dbfb942c33bf Mathias Nyman 2021-01-29 634 static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
d1dbfb942c33bf Mathias Nyman 2021-01-29 635 unsigned int slot_id, unsigned int ep_index,
d1dbfb942c33bf Mathias Nyman 2021-01-29 636 unsigned int stream_id, struct xhci_td *td)
d1dbfb942c33bf Mathias Nyman 2021-01-29 637 {
d1dbfb942c33bf Mathias Nyman 2021-01-29 638 struct xhci_virt_device *dev = xhci->devs[slot_id];
d1dbfb942c33bf Mathias Nyman 2021-01-29 639 struct xhci_virt_ep *ep = &dev->eps[ep_index];
d1dbfb942c33bf Mathias Nyman 2021-01-29 640 struct xhci_ring *ep_ring;
d1dbfb942c33bf Mathias Nyman 2021-01-29 641 struct xhci_command *cmd;
d1dbfb942c33bf Mathias Nyman 2021-01-29 642 struct xhci_segment *new_seg;
d1dbfb942c33bf Mathias Nyman 2021-01-29 643 union xhci_trb *new_deq;
d1dbfb942c33bf Mathias Nyman 2021-01-29 644 int new_cycle;
d1dbfb942c33bf Mathias Nyman 2021-01-29 645 dma_addr_t addr;
d1dbfb942c33bf Mathias Nyman 2021-01-29 646 u64 hw_dequeue;
d1dbfb942c33bf Mathias Nyman 2021-01-29 647 bool cycle_found = false;
d1dbfb942c33bf Mathias Nyman 2021-01-29 648 bool td_last_trb_found = false;
d1dbfb942c33bf Mathias Nyman 2021-01-29 649 u32 trb_sct = 0;
d1dbfb942c33bf Mathias Nyman 2021-01-29 650 int ret;
d1dbfb942c33bf Mathias Nyman 2021-01-29 651
d1dbfb942c33bf Mathias Nyman 2021-01-29 652 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
d1dbfb942c33bf Mathias Nyman 2021-01-29 653 ep_index, stream_id);
d1dbfb942c33bf Mathias Nyman 2021-01-29 654 if (!ep_ring) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 655 xhci_warn(xhci, "WARN can't find new dequeue, invalid stream ID %u\n",
d1dbfb942c33bf Mathias Nyman 2021-01-29 656 stream_id);
d1dbfb942c33bf Mathias Nyman 2021-01-29 657 return -ENODEV;
d1dbfb942c33bf Mathias Nyman 2021-01-29 658 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 659
d1dbfb942c33bf Mathias Nyman 2021-01-29 660 hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id);
d1dbfb942c33bf Mathias Nyman 2021-01-29 661 new_seg = ep_ring->deq_seg;
d1dbfb942c33bf Mathias Nyman 2021-01-29 662 new_deq = ep_ring->dequeue;
d1dbfb942c33bf Mathias Nyman 2021-01-29 663 new_cycle = hw_dequeue & 0x1;
d1dbfb942c33bf Mathias Nyman 2021-01-29 664
d1dbfb942c33bf Mathias Nyman 2021-01-29 665 /*
d1dbfb942c33bf Mathias Nyman 2021-01-29 666 * We want to find the pointer, segment and cycle state of the new trb
d1dbfb942c33bf Mathias Nyman 2021-01-29 667 * (the one after current TD's last_trb). We know the cycle state at
d1dbfb942c33bf Mathias Nyman 2021-01-29 668 * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
d1dbfb942c33bf Mathias Nyman 2021-01-29 669 * found.
d1dbfb942c33bf Mathias Nyman 2021-01-29 670 */
d1dbfb942c33bf Mathias Nyman 2021-01-29 671 do {
d1dbfb942c33bf Mathias Nyman 2021-01-29 672 if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
d1dbfb942c33bf Mathias Nyman 2021-01-29 673 == (dma_addr_t)(hw_dequeue & ~0xf)) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 674 cycle_found = true;
d1dbfb942c33bf Mathias Nyman 2021-01-29 675 if (td_last_trb_found)
d1dbfb942c33bf Mathias Nyman 2021-01-29 676 break;
d1dbfb942c33bf Mathias Nyman 2021-01-29 677 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 678 if (new_deq == td->last_trb)
d1dbfb942c33bf Mathias Nyman 2021-01-29 679 td_last_trb_found = true;
d1dbfb942c33bf Mathias Nyman 2021-01-29 680
d1dbfb942c33bf Mathias Nyman 2021-01-29 681 if (cycle_found && trb_is_link(new_deq) &&
d1dbfb942c33bf Mathias Nyman 2021-01-29 682 link_trb_toggles_cycle(new_deq))
d1dbfb942c33bf Mathias Nyman 2021-01-29 683 new_cycle ^= 0x1;
d1dbfb942c33bf Mathias Nyman 2021-01-29 684
d1dbfb942c33bf Mathias Nyman 2021-01-29 685 next_trb(xhci, ep_ring, &new_seg, &new_deq);
d1dbfb942c33bf Mathias Nyman 2021-01-29 686
d1dbfb942c33bf Mathias Nyman 2021-01-29 687 /* Search wrapped around, bail out */
d1dbfb942c33bf Mathias Nyman 2021-01-29 688 if (new_deq == ep->ring->dequeue) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 689 xhci_err(xhci, "Error: Failed finding new dequeue state\n");
d1dbfb942c33bf Mathias Nyman 2021-01-29 690 return -EINVAL;
d1dbfb942c33bf Mathias Nyman 2021-01-29 691 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 692
d1dbfb942c33bf Mathias Nyman 2021-01-29 693 } while (!cycle_found || !td_last_trb_found);
d1dbfb942c33bf Mathias Nyman 2021-01-29 694
d1dbfb942c33bf Mathias Nyman 2021-01-29 @695 deq_found:
d1dbfb942c33bf Mathias Nyman 2021-01-29 696
d1dbfb942c33bf Mathias Nyman 2021-01-29 697 /* Don't update the ring cycle state for the producer (us). */
d1dbfb942c33bf Mathias Nyman 2021-01-29 698 addr = xhci_trb_virt_to_dma(new_seg, new_deq);
d1dbfb942c33bf Mathias Nyman 2021-01-29 699 if (addr == 0) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 700 xhci_warn(xhci, "Can't find dma of new dequeue ptr\n");
d1dbfb942c33bf Mathias Nyman 2021-01-29 701 xhci_warn(xhci, "deq seg = %p, deq ptr = %p\n", new_seg, new_deq);
d1dbfb942c33bf Mathias Nyman 2021-01-29 702 return -EINVAL;
d1dbfb942c33bf Mathias Nyman 2021-01-29 703 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 704
d1dbfb942c33bf Mathias Nyman 2021-01-29 705 if ((ep->ep_state & SET_DEQ_PENDING)) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 706 xhci_warn(xhci, "Set TR Deq already pending, don't submit for 0x%pad\n",
d1dbfb942c33bf Mathias Nyman 2021-01-29 707 &addr);
d1dbfb942c33bf Mathias Nyman 2021-01-29 708 return -EBUSY;
d1dbfb942c33bf Mathias Nyman 2021-01-29 709 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 710
d1dbfb942c33bf Mathias Nyman 2021-01-29 711 /* This function gets called from contexts where it cannot sleep */
d1dbfb942c33bf Mathias Nyman 2021-01-29 712 cmd = xhci_alloc_command(xhci, false, GFP_ATOMIC);
d1dbfb942c33bf Mathias Nyman 2021-01-29 713 if (!cmd) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 714 xhci_warn(xhci, "Can't alloc Set TR Deq cmd 0x%pad\n", &addr);
d1dbfb942c33bf Mathias Nyman 2021-01-29 715 return -ENOMEM;
d1dbfb942c33bf Mathias Nyman 2021-01-29 716 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 717
d1dbfb942c33bf Mathias Nyman 2021-01-29 718 if (stream_id)
d1dbfb942c33bf Mathias Nyman 2021-01-29 719 trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
d1dbfb942c33bf Mathias Nyman 2021-01-29 720 ret = queue_command(xhci, cmd,
d1dbfb942c33bf Mathias Nyman 2021-01-29 721 lower_32_bits(addr) | trb_sct | new_cycle,
d1dbfb942c33bf Mathias Nyman 2021-01-29 722 upper_32_bits(addr),
d1dbfb942c33bf Mathias Nyman 2021-01-29 723 STREAM_ID_FOR_TRB(stream_id), SLOT_ID_FOR_TRB(slot_id) |
d1dbfb942c33bf Mathias Nyman 2021-01-29 724 EP_ID_FOR_TRB(ep_index) | TRB_TYPE(TRB_SET_DEQ), false);
d1dbfb942c33bf Mathias Nyman 2021-01-29 725 if (ret < 0) {
d1dbfb942c33bf Mathias Nyman 2021-01-29 726 xhci_free_command(xhci, cmd);
d1dbfb942c33bf Mathias Nyman 2021-01-29 727 return ret;
d1dbfb942c33bf Mathias Nyman 2021-01-29 728 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 729 ep->queued_deq_seg = new_seg;
d1dbfb942c33bf Mathias Nyman 2021-01-29 730 ep->queued_deq_ptr = new_deq;
d1dbfb942c33bf Mathias Nyman 2021-01-29 731
d1dbfb942c33bf Mathias Nyman 2021-01-29 732 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
d1dbfb942c33bf Mathias Nyman 2021-01-29 733 "Set TR Deq ptr 0x%llx, cycle %u\n", addr, new_cycle);
d1dbfb942c33bf Mathias Nyman 2021-01-29 734
d1dbfb942c33bf Mathias Nyman 2021-01-29 735 /* Stop the TD queueing code from ringing the doorbell until
d1dbfb942c33bf Mathias Nyman 2021-01-29 736 * this command completes. The HC won't set the dequeue pointer
d1dbfb942c33bf Mathias Nyman 2021-01-29 737 * if the ring is running, and ringing the doorbell starts the
d1dbfb942c33bf Mathias Nyman 2021-01-29 738 * ring running.
d1dbfb942c33bf Mathias Nyman 2021-01-29 739 */
d1dbfb942c33bf Mathias Nyman 2021-01-29 740 ep->ep_state |= SET_DEQ_PENDING;
d1dbfb942c33bf Mathias Nyman 2021-01-29 741 xhci_ring_cmd_db(xhci);
d1dbfb942c33bf Mathias Nyman 2021-01-29 742 return 0;
d1dbfb942c33bf Mathias Nyman 2021-01-29 743 }
d1dbfb942c33bf Mathias Nyman 2021-01-29 744
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 575f0fd9c9f1..f1ed728d9f8c 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -656,25 +656,6 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci, stream_id); return -ENODEV; } - /* - * A cancelled TD can complete with a stall if HW cached the trb. - * In this case driver can't find td, but if the ring is empty we - * can move the dequeue pointer to the current enqueue position. - * We shouldn't hit this anymore as cached cancelled TRBs are given back - * after clearing the cache, but be on the safe side and keep it anyway - */ - if (!td) { - if (list_empty(&ep_ring->td_list)) { - new_seg = ep_ring->enq_seg; - new_deq = ep_ring->enqueue; - new_cycle = ep_ring->cycle_state; - xhci_dbg(xhci, "ep ring empty, Set new dequeue = enqueue"); - goto deq_found; - } else { - xhci_warn(xhci, "Can't find new dequeue state, missing td\n"); - return -EINVAL; - } - } hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id); new_seg = ep_ring->deq_seg;
This codepath is trivially dead, since the function is never called with a non-NULL td (the only callsite is immediately preceded by a NULL guard). Signed-off-by: Hector Martin <marcan@marcan.st> --- drivers/usb/host/xhci-ring.c | 19 ------------------- 1 file changed, 19 deletions(-) --- base-commit: a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6 change-id: 20240524-xhci-deadcode-8bf2ebe7609d Best regards,