tree:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git
rewrite_invalid_context_at_stop_endpoint
head: eae681e2e11a3d370aedbafd618422b0f57c3600
commit: c60e0cbd4157a3742834fb57a2cb5bf9d9fc42c1 [6/7] xhci: introduce a new
move_dequeue_past_td() function to replace old code.
config: arm-randconfig-r031-20201019 (attached as .config)
compiler: clang version 12.0.0 (
https://github.com/llvm/llvm-project
094e9f4779eb9b5c6a49014f2f80b8cbb833572f)
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 arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
#
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/commit/?i...
git remote add xhci
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git
git fetch --no-tags xhci rewrite_invalid_context_at_stop_endpoint
git checkout c60e0cbd4157a3742834fb57a2cb5bf9d9fc42c1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> drivers/usb/host/xhci-ring.c:727:60: warning: format specifies
type 'unsigned long long' but the argument has type 'dma_addr_t' (aka
'unsigned int') [-Wformat]
xhci_warn(xhci, "WARN
Can't submit Set TR Deq 0x%llx\n", addr);
~~~~ ^~~~
%x
drivers/usb/host/xhci.h:1950:57: note: expanded from macro 'xhci_warn'
dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
~~~ ^~~~
include/linux/dev_printk.h:106:33: note: expanded from macro 'dev_warn'
_dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
drivers/usb/host/xhci-ring.c:735:68: warning: format specifies type 'unsigned long
long' but the argument has type 'dma_addr_t' (aka 'unsigned int')
[-Wformat]
xhci_warn(xhci, "WARN Fail to allocate Set TR Deq cmd
0x%llx\n", addr);
~~~~ ^~~~
%x
drivers/usb/host/xhci.h:1950:57: note: expanded from macro 'xhci_warn'
dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
~~~ ^~~~
include/linux/dev_printk.h:106:33: note: expanded from macro 'dev_warn'
_dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
drivers/usb/host/xhci-ring.c:635:5: warning: no previous prototype for function
'xhci_move_dequeue_past_td' [-Wmissing-prototypes]
int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
^
drivers/usb/host/xhci-ring.c:635:1: note: declare 'static' if the function is
not intended to be used outside of this translation unit
int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
^
static
3 warnings generated.
vim +727 drivers/usb/host/xhci-ring.c
634
635 int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
636 unsigned int slot_id, unsigned int ep_index,
637 unsigned int stream_id, struct xhci_td *td)
638 {
639 struct xhci_virt_device *dev = xhci->devs[slot_id];
640 struct xhci_virt_ep *ep = &dev->eps[ep_index];
641 struct xhci_ring *ep_ring;
642 struct xhci_command *cmd;
643 struct xhci_segment *new_seg;
644 union xhci_trb *new_deq;
645 int new_cycle;
646 dma_addr_t addr;
647 u64 hw_dequeue;
648 bool cycle_found = false;
649 bool td_last_trb_found = false;
650 u32 trb_sct = 0;
651 int ret;
652
653 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
654 ep_index, stream_id);
655 if (!ep_ring) {
656 xhci_warn(xhci, "WARN can't find new dequeue state "
657 "for invalid stream ID %u.\n",
658 stream_id);
659 return -ENODEV;
660 }
661 /*
662 * A cancelled TD can complete with a stall if HW cached the trb.
663 * In this case driver can't find td, but if the ring is empty we
664 * can move the dequeue pointer to the current enqueue position.
665 * FIXMA MATTU is this still the case?
666 */
667 if (!td) {
668 if (list_empty(&ep_ring->td_list)) {
669 new_seg = ep_ring->enq_seg;
670 new_deq = ep_ring->enqueue;
671 new_cycle = ep_ring->cycle_state;
672 xhci_dbg(xhci, "ep ring empty, Set new dequeue = enqueue");
673 goto deq_found;
674 } else {
675 xhci_warn(xhci, "Can't find new dequeue state, missing td\n");
676 return -EINVAL;
677 }
678 }
679
680 hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id);
681 new_seg = ep_ring->deq_seg;
682 new_deq = ep_ring->dequeue;
683 new_cycle = hw_dequeue & 0x1;
684
685 /*
686 * We want to find the pointer, segment and cycle state of the new trb
687 * (the one after current TD's last_trb). We know the cycle state at
688 * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
689 * found.
690 */
691 do {
692 if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
693 == (dma_addr_t)(hw_dequeue & ~0xf)) {
694 cycle_found = true;
695 if (td_last_trb_found)
696 break;
697 }
698 if (new_deq == td->last_trb)
699 td_last_trb_found = true;
700
701 if (cycle_found && trb_is_link(new_deq) &&
702 link_trb_toggles_cycle(new_deq))
703 new_cycle ^= 0x1;
704
705 next_trb(xhci, ep_ring, &new_seg, &new_deq);
706
707 /* Search wrapped around, bail out */
708 if (new_deq == ep->ring->dequeue) {
709 xhci_err(xhci, "Error: Failed finding new dequeue state\n");
710 return -EINVAL;
711 }
712
713 } while (!cycle_found || !td_last_trb_found);
714
715 deq_found:
716
717 /* Don't update the ring cycle state for the producer (us). */
718 addr = xhci_trb_virt_to_dma(new_seg, new_deq);
719 if (addr == 0) {
720 xhci_warn(xhci, "WARN Cannot find dma of new dequeue ptr\n");
721 xhci_warn(xhci, "deq seg = %p, deq ptr = %p\n", new_seg, new_deq);
722 return -EINVAL;
723 }
724
725 /* MATTU fixme do we want this PENDING flag at all?*/
726 if ((ep->ep_state & SET_DEQ_PENDING)) {
727 xhci_warn(xhci, "WARN Can't submit Set TR Deq
0x%llx\n", addr);
728 xhci_warn(xhci, "Another Set TR Deq command is
pending.\n");
729 return -EBUSY; //MATTU FIXME
730 }
731
732 /* This function gets called from contexts where it cannot sleep */
733 cmd = xhci_alloc_command(xhci, false, GFP_ATOMIC);
734 if (!cmd) {
735 xhci_warn(xhci, "WARN Fail to allocate Set TR Deq cmd 0x%llx\n",
addr);
736 return -ENOMEM;
737 }
738
739 if (stream_id)
740 trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
741 ret = queue_command(xhci, cmd,
742 lower_32_bits(addr) | trb_sct | new_cycle,
743 upper_32_bits(addr),
744 STREAM_ID_FOR_TRB(stream_id), SLOT_ID_FOR_TRB(slot_id) |
745 EP_ID_FOR_TRB(ep_index) | TRB_TYPE(TRB_SET_DEQ), false);
746 if (ret < 0) {
747 xhci_free_command(xhci, cmd);
748 return ret;
749 }
750
751 ep->queued_deq_seg = new_seg;
752 ep->queued_deq_ptr = new_deq;
753
754 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
755 "Set TR Deq ptr 0x%llx, cycle %u\n", addr, new_cycle);
756
757 /* Stop the TD queueing code from ringing the doorbell until
758 * this command completes. The HC won't set the dequeue pointer
759 * if the ring is running, and ringing the doorbell starts the
760 * ring running.
761 */
762 ep->ep_state |= SET_DEQ_PENDING;
763 return 0;
764 }
765
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org