Re: [PATCH 1/4] Move event_ring into xhci_erst

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

 



On Wed, Jun 1, 2011 at 5:40 AM, Matthew Wilcox <willy@xxxxxxxxxxxxxxx> wrote:
>
> Start consolidating event-ring related data into a single structure
>

(Sorry for the mail address since I'm not in office)

Hi Matthew,

Have you ever compiled and tested the patchset with MSI-X/MSI/Legacy irq?
I found that there is still a event_ring usage in xhci_irq() and the
compilation fails,
can you check that?

Thanks,
Andiry

> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>
> ---
>  drivers/usb/host/xhci-mem.c  |   86 +++++++++++++++++++++---------------------
>  drivers/usb/host/xhci-ring.c |   30 +++++++-------
>  drivers/usb/host/xhci.c      |   10 ++--
>  drivers/usb/host/xhci.h      |    4 +-
>  4 files changed, 65 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 26caba4..a1ca531 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1496,9 +1496,9 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>                                xhci->erst.entries, xhci->erst.erst_dma_addr);
>        xhci->erst.entries = NULL;
>        xhci_dbg(xhci, "Freed ERST\n");
> -       if (xhci->event_ring)
> -               xhci_ring_free(xhci, xhci->event_ring);
> -       xhci->event_ring = NULL;
> +       if (xhci->erst.ring)
> +               xhci_ring_free(xhci, xhci->erst.ring);
> +       xhci->erst.ring = NULL;
>        xhci_dbg(xhci, "Freed event ring\n");
>
>        xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring);
> @@ -1594,18 +1594,18 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags)
>                /* A zeroed DMA field should fail */
>                { 0, NULL },
>                /* One TRB before the ring start should fail */
> -               { xhci->event_ring->first_seg->dma - 16, NULL },
> +               { xhci->erst.ring->first_seg->dma - 16, NULL },
>                /* One byte before the ring start should fail */
> -               { xhci->event_ring->first_seg->dma - 1, NULL },
> +               { xhci->erst.ring->first_seg->dma - 1, NULL },
>                /* Starting TRB should succeed */
> -               { xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg },
> +               { xhci->erst.ring->first_seg->dma, xhci->erst.ring->first_seg },
>                /* Ending TRB should succeed */
> -               { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16,
> -                       xhci->event_ring->first_seg },
> +               { xhci->erst.ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16,
> +                       xhci->erst.ring->first_seg },
>                /* One byte after the ring end should fail */
> -               { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16 + 1, NULL },
> +               { xhci->erst.ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16 + 1, NULL },
>                /* One TRB after the ring end should fail */
> -               { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT)*16, NULL },
> +               { xhci->erst.ring->first_seg->dma + (TRBS_PER_SEGMENT)*16, NULL },
>                /* An address of all ones should fail */
>                { (dma_addr_t) (~0), NULL },
>        };
> @@ -1617,58 +1617,58 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags)
>                struct xhci_segment     *result_seg;
>        } complex_test_vector [] = {
>                /* Test feeding a valid DMA address from a different ring */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = xhci->event_ring->first_seg->trbs,
> -                       .end_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = xhci->erst.ring->first_seg->trbs,
> +                       .end_trb = &xhci->erst.ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
>                        .input_dma = xhci->cmd_ring->first_seg->dma,
>                        .result_seg = NULL,
>                },
>                /* Test feeding a valid end TRB from a different ring */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = xhci->event_ring->first_seg->trbs,
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = xhci->erst.ring->first_seg->trbs,
>                        .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
>                        .input_dma = xhci->cmd_ring->first_seg->dma,
>                        .result_seg = NULL,
>                },
>                /* Test feeding a valid start and end TRB from a different ring */
> -               {       .input_seg = xhci->event_ring->first_seg,
> +               {       .input_seg = xhci->erst.ring->first_seg,
>                        .start_trb = xhci->cmd_ring->first_seg->trbs,
>                        .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
>                        .input_dma = xhci->cmd_ring->first_seg->dma,
>                        .result_seg = NULL,
>                },
>                /* TRB in this ring, but after this TD */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = &xhci->event_ring->first_seg->trbs[0],
> -                       .end_trb = &xhci->event_ring->first_seg->trbs[3],
> -                       .input_dma = xhci->event_ring->first_seg->dma + 4*16,
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = &xhci->erst.ring->first_seg->trbs[0],
> +                       .end_trb = &xhci->erst.ring->first_seg->trbs[3],
> +                       .input_dma = xhci->erst.ring->first_seg->dma + 4*16,
>                        .result_seg = NULL,
>                },
>                /* TRB in this ring, but before this TD */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = &xhci->event_ring->first_seg->trbs[3],
> -                       .end_trb = &xhci->event_ring->first_seg->trbs[6],
> -                       .input_dma = xhci->event_ring->first_seg->dma + 2*16,
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = &xhci->erst.ring->first_seg->trbs[3],
> +                       .end_trb = &xhci->erst.ring->first_seg->trbs[6],
> +                       .input_dma = xhci->erst.ring->first_seg->dma + 2*16,
>                        .result_seg = NULL,
>                },
>                /* TRB in this ring, but after this wrapped TD */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
> -                       .end_trb = &xhci->event_ring->first_seg->trbs[1],
> -                       .input_dma = xhci->event_ring->first_seg->dma + 2*16,
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = &xhci->erst.ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
> +                       .end_trb = &xhci->erst.ring->first_seg->trbs[1],
> +                       .input_dma = xhci->erst.ring->first_seg->dma + 2*16,
>                        .result_seg = NULL,
>                },
>                /* TRB in this ring, but before this wrapped TD */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
> -                       .end_trb = &xhci->event_ring->first_seg->trbs[1],
> -                       .input_dma = xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 4)*16,
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = &xhci->erst.ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
> +                       .end_trb = &xhci->erst.ring->first_seg->trbs[1],
> +                       .input_dma = xhci->erst.ring->first_seg->dma + (TRBS_PER_SEGMENT - 4)*16,
>                        .result_seg = NULL,
>                },
>                /* TRB not in this ring, and we have a wrapped TD */
> -               {       .input_seg = xhci->event_ring->first_seg,
> -                       .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
> -                       .end_trb = &xhci->event_ring->first_seg->trbs[1],
> +               {       .input_seg = xhci->erst.ring->first_seg,
> +                       .start_trb = &xhci->erst.ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
> +                       .end_trb = &xhci->erst.ring->first_seg->trbs[1],
>                        .input_dma = xhci->cmd_ring->first_seg->dma + 2*16,
>                        .result_seg = NULL,
>                },
> @@ -1680,9 +1680,9 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags)
>        num_tests = ARRAY_SIZE(simple_test_vector);
>        for (i = 0; i < num_tests; i++) {
>                ret = xhci_test_trb_in_td(xhci,
> -                               xhci->event_ring->first_seg,
> -                               xhci->event_ring->first_seg->trbs,
> -                               &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
> +                               xhci->erst.ring->first_seg,
> +                               xhci->erst.ring->first_seg->trbs,
> +                               &xhci->erst.ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
>                                simple_test_vector[i].input_dma,
>                                simple_test_vector[i].result_seg,
>                                "Simple", i);
> @@ -1711,8 +1711,8 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
>        u64 temp;
>        dma_addr_t deq;
>
> -       deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg,
> -                       xhci->event_ring->dequeue);
> +       deq = xhci_trb_virt_to_dma(xhci->erst.ring->deq_seg,
> +                       xhci->erst.ring->dequeue);
>        if (deq == 0 && !in_interrupt())
>                xhci_warn(xhci, "WARN something wrong with SW event ring "
>                                "dequeue ptr.\n");
> @@ -2024,8 +2024,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
>         * the event ring segment table (ERST).  Section 4.9.3.
>         */
>        xhci_dbg(xhci, "// Allocating event ring\n");
> -       xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, false, flags);
> -       if (!xhci->event_ring)
> +       xhci->erst.ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, false, flags);
> +       if (!xhci->erst.ring)
>                goto fail;
>        if (xhci_check_trb_in_td_math(xhci, flags) < 0)
>                goto fail;
> @@ -2046,7 +2046,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
>                        (unsigned long long)xhci->erst.erst_dma_addr);
>
>        /* set ring base address and size for each segment table entry */
> -       for (val = 0, seg = xhci->event_ring->first_seg; val < ERST_NUM_SEGS; val++) {
> +       for (val = 0, seg = xhci->erst.ring->first_seg; val < ERST_NUM_SEGS; val++) {
>                struct xhci_erst_entry *entry = &xhci->erst.entries[val];
>                entry->seg_addr = cpu_to_le64(seg->dma);
>                entry->seg_size = cpu_to_le32(TRBS_PER_SEGMENT);
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index a49061e..05dfdfa 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -96,9 +96,9 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg,
>  static bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring,
>                struct xhci_segment *seg, union xhci_trb *trb)
>  {
> -       if (ring == xhci->event_ring)
> +       if (ring == xhci->erst.ring)
>                return (trb == &seg->trbs[TRBS_PER_SEGMENT]) &&
> -                       (seg->next == xhci->event_ring->first_seg);
> +                       (seg->next == xhci->erst.ring->first_seg);
>        else
>                return le32_to_cpu(trb->link.control) & LINK_TOGGLE;
>  }
> @@ -110,7 +110,7 @@ static bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring,
>  static int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
>                struct xhci_segment *seg, union xhci_trb *trb)
>  {
> -       if (ring == xhci->event_ring)
> +       if (ring == xhci->erst.ring)
>                return trb == &seg->trbs[TRBS_PER_SEGMENT];
>        else
>                return (le32_to_cpu(trb->link.control) & TRB_TYPE_BITMASK)
> @@ -202,7 +202,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring,
>         */
>        while (last_trb(xhci, ring, ring->enq_seg, next)) {
>                if (!consumer) {
> -                       if (ring != xhci->event_ring) {
> +                       if (ring != xhci->erst.ring) {
>                                /*
>                                 * If the caller doesn't plan on enqueueing more
>                                 * TDs before ringing the doorbell, then we
> @@ -1346,7 +1346,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
>
>  cleanup:
>        /* Update event ring dequeue pointer before dropping the lock */
> -       inc_deq(xhci, xhci->event_ring, true);
> +       inc_deq(xhci, xhci->erst.ring, true);
>
>        /* Don't make the USB core poll the roothub if we got a bad port status
>         * change event.  Besides, at that point we can't tell which roothub
> @@ -1611,7 +1611,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
>        ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index);
>        trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len));
>
> -       xhci_debug_trb(xhci, xhci->event_ring->dequeue);
> +       xhci_debug_trb(xhci, xhci->erst.ring->dequeue);
>        switch (trb_comp_code) {
>        case COMP_SUCCESS:
>                if (event_trb == ep_ring->dequeue) {
> @@ -2131,7 +2131,7 @@ cleanup:
>                 * Will roll back to continue process missed tds.
>                 */
>                if (trb_comp_code == COMP_MISSED_INT || !ep->skip) {
> -                       inc_deq(xhci, xhci->event_ring, true);
> +                       inc_deq(xhci, xhci->erst.ring, true);
>                }
>
>                if (ret) {
> @@ -2185,15 +2185,15 @@ static int xhci_handle_event(struct xhci_hcd *xhci)
>        int update_ptrs = 1;
>        int ret;
>
> -       if (!xhci->event_ring || !xhci->event_ring->dequeue) {
> +       if (!xhci->erst.ring || !xhci->erst.ring->dequeue) {
>                xhci->error_bitmask |= 1 << 1;
>                return 0;
>        }
>
> -       event = xhci->event_ring->dequeue;
> +       event = xhci->erst.ring->dequeue;
>        /* Does the HC or OS own the TRB? */
>        if ((le32_to_cpu(event->event_cmd.flags) & TRB_CYCLE) !=
> -           xhci->event_ring->cycle_state) {
> +           xhci->erst.ring->cycle_state) {
>                xhci->error_bitmask |= 1 << 2;
>                return 0;
>        }
> @@ -2237,7 +2237,7 @@ static int xhci_handle_event(struct xhci_hcd *xhci)
>
>        if (update_ptrs)
>                /* Update SW event ring dequeue pointer */
> -               inc_deq(xhci, xhci->event_ring, true);
> +               inc_deq(xhci, xhci->erst.ring, true);
>
>        /* Are there more items on the event ring?  Caller will call us again to
>         * check.
> @@ -2308,7 +2308,7 @@ hw_died:
>                return IRQ_HANDLED;
>        }
>
> -       event_ring_deq = xhci->event_ring->dequeue;
> +       event_ring_deq = xhci->erst.ring->dequeue;
>        /* FIXME this should be a delayed service routine
>         * that clears the EHB.
>         */
> @@ -2316,9 +2316,9 @@ hw_died:
>
>        temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
>        /* If necessary, update the HW's version of the event ring deq ptr. */
> -       if (event_ring_deq != xhci->event_ring->dequeue) {
> -               deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg,
> -                               xhci->event_ring->dequeue);
> +       if (event_ring_deq != xhci->erst.ring->dequeue) {
> +               deq = xhci_trb_virt_to_dma(xhci->erst.ring->deq_seg,
> +                               xhci->erst.ring->dequeue);
>                if (deq == 0)
>                        xhci_warn(xhci, "WARN something wrong with SW event "
>                                        "ring dequeue ptr.\n");
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index d9660eb..7035797 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -356,8 +356,8 @@ static void xhci_event_ring_work(unsigned long arg)
>        xhci_dbg(xhci, "HC error bitmask = 0x%x\n", xhci->error_bitmask);
>        xhci->error_bitmask = 0;
>        xhci_dbg(xhci, "Event ring:\n");
> -       xhci_debug_segment(xhci, xhci->event_ring->deq_seg);
> -       xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
> +       xhci_debug_segment(xhci, xhci->erst.ring->deq_seg);
> +       xhci_dbg_ring_ptrs(xhci, xhci->erst.ring);
>        temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
>        temp_64 &= ~ERST_PTR_MASK;
>        xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
> @@ -466,8 +466,8 @@ int xhci_run(struct usb_hcd *hcd)
>        xhci_dbg(xhci, "ERST memory map follows:\n");
>        xhci_dbg_erst(xhci, &xhci->erst);
>        xhci_dbg(xhci, "Event ring:\n");
> -       xhci_debug_ring(xhci, xhci->event_ring);
> -       xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
> +       xhci_debug_ring(xhci, xhci->erst.ring);
> +       xhci_dbg_ring_ptrs(xhci, xhci->erst.ring);
>        temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
>        temp_64 &= ~ERST_PTR_MASK;
>        xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
> @@ -1247,7 +1247,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
>
>        xhci_dbg(xhci, "Cancel URB %p\n", urb);
>        xhci_dbg(xhci, "Event ring:\n");
> -       xhci_debug_ring(xhci, xhci->event_ring);
> +       xhci_debug_ring(xhci, xhci->erst.ring);
>        ep_index = xhci_get_endpoint_index(&urb->ep->desc);
>        ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index];
>        ep_ring = xhci_urb_to_transfer_ring(xhci, urb);
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index ac0196e..86e16d2 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1135,9 +1135,10 @@ struct xhci_erst_entry {
>  };
>
>  struct xhci_erst {
> +       struct xhci_ring        *ring;
>        struct xhci_erst_entry  *entries;
>        unsigned int            num_entries;
> -       /* xhci->event_ring keeps track of segment dma addresses */
> +       /* ring keeps track of segment dma addresses */
>        dma_addr_t              erst_dma_addr;
>        /* Num entries the ERST can contain */
>        unsigned int            erst_size;
> @@ -1243,7 +1244,6 @@ struct xhci_hcd {
>        struct xhci_device_context_array *dcbaa;
>        struct xhci_ring        *cmd_ring;
>        unsigned int            cmd_ring_reserved_trbs;
> -       struct xhci_ring        *event_ring;
>        struct xhci_erst        erst;
>        /* Scratchpad */
>        struct xhci_scratchpad  *scratchpad;
> --
> 1.7.4.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux