linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
	USB list <linux-usb@vger.kernel.org>
Subject: Re: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 13
Date: Fri, 22 Nov 2019 23:10:55 +0800	[thread overview]
Message-ID: <F6AF08A8-8532-4A58-AE33-C1B02CBDC993@canonical.com> (raw)
In-Reply-To: <23a9798e-704f-3444-42e2-e583a6991950@linux.intel.com>



> On Nov 22, 2019, at 20:17, Mathias Nyman <mathias.nyman@linux.intel.com> wrote:

[snipped]

> 
> The event ring is already overwritten with new events when dumped.
> 
> Could you apply the code below, it will dump both the endpoint transfer ring
> and the event ring at the right moment:

The log is quite large so I pasted it here:
https://pastebin.ubuntu.com/p/wWpS8ctNrb/

Kai-Heng

> 
> Attached as a patch as well.
> 
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 620846f30b4f..a1a9a408c479 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -201,6 +201,31 @@ void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring)
>  * @more_trbs_coming:  Will you enqueue more TRBs before calling
>  *                     prepare_transfer()?
>  */
> +
> +static int xhci_dump_ring(struct xhci_hcd *xhci, struct xhci_ring *ring)
> +{
> +       struct xhci_segment     *seg;
> +       dma_addr_t              dma;
> +       union xhci_trb          *trb;
> +       int                     i, j;
> +
> +       seg = ring->first_seg;
> +
> +       for (i = 0; i < ring->num_segs; i++) {
> +               for (j = 0; j < TRBS_PER_SEGMENT; j++) {
> +                       trb = &seg->trbs[j];
> +                       dma = seg->dma + j * sizeof(*trb);
> +                       xhci_err(xhci, "%pad: %s\n", &dma,
> +                                xhci_decode_trb(le32_to_cpu(trb->generic.field[0]),
> +                                                le32_to_cpu(trb->generic.field[1]),
> +                                                le32_to_cpu(trb->generic.field[2]),
> +                                                le32_to_cpu(trb->generic.field[3])));
> +               }
> +               seg = seg->next;
> +       }
> +       return 0;
> +}
> +
> static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring,
>                        bool more_trbs_coming)
> {
> @@ -2318,6 +2343,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
>        u32 trb_comp_code;
>        int td_num = 0;
>        bool handling_skipped_tds = false;
> +       static unsigned int err_cnt;
>         slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
>        ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1;
> @@ -2579,6 +2605,12 @@ static int handle_tx_event(struct xhci_hcd *xhci,
>                                trb_in_td(xhci, ep_ring->deq_seg,
>                                          ep_ring->dequeue, td->last_trb,
>                                          ep_trb_dma, true);
> +                               if (err_cnt++ == 5) {
> +                                       xhci_err(xhci, "EVENT RING:\n");
> +                                       xhci_dump_ring(xhci, xhci->event_ring);
> +                                       xhci_err(xhci, "ENDPOINT RING:\n");
> +                                       xhci_dump_ring(xhci, ep_ring);
> +                               }
>                                return -ESHUTDOWN;
>                        }
> <0001-xhci-dump-event-ring-and-endpoint-ring-if-TRB-not-fo.patch>


  reply	other threads:[~2019-11-22 15:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21  7:38 ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 13 Kai-Heng Feng
2019-11-21 11:47 ` Greg KH
2019-11-21 16:44   ` Kai-Heng Feng
2019-11-21 11:48 ` Mathias Nyman
2019-11-21 16:43   ` Kai-Heng Feng
2019-11-22 12:17     ` Mathias Nyman
2019-11-22 15:10       ` Kai-Heng Feng [this message]
2019-11-22 16:35         ` Mathias Nyman
2019-11-26  9:44           ` Kai-Heng Feng
2019-11-26 10:54             ` Mathias Nyman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F6AF08A8-8532-4A58-AE33-C1B02CBDC993@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).