xhci: allow TRACE to work with EVENT ring dequeue
Subsystems (2)
PATCH v2 1/1 xhci: allow TRACE to work with EVENT ring dequeue
inc_deq() currently bails earlier for EVENT rings than the common return point of the function, due to the fact that EVENT rings do not have link TRBs. The unfortunate side effect of this is that the very useful trace_xhci_inc_deq() function is not called/usable for EVENT ring debug.
This patch provides a refactor by removing the multiple return exit points into a single return which additionally allows for all rings to use the trace function.
---
Changes in v2: undo accidental line removal at end of patch
drivers/usb/host/xhci-ring.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/usb/host/xhci-ring.c +16 -16
@@ -171,23 +171,23 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring)if (ring->type ==TYPE_EVENT ) {if (!last_trb_on_seg (ring->deq_seg, ring->dequeue)) { ring->dequeue++; -return ; + }else { +if (last_trb_on_ring (ring, ring->deq_seg, + ring->dequeue)) + ring->cycle_state ^=1 ; + ring->deq_seg = ring->deq_seg->next; + ring->dequeue = ring->deq_seg->trbs; + } + }else { +/* All other rings have link trbs */ +if (!trb_is_link (ring->dequeue)) { + ring->dequeue++; + ring->num_trbs_free++; + } +while (trb_is_link (ring->dequeue)) { + ring->deq_seg = ring->deq_seg->next; + ring->dequeue = ring->deq_seg->trbs; } -if (last_trb_on_ring (ring, ring->deq_seg, ring->dequeue)) - ring->cycle_state ^=1 ; - ring->deq_seg = ring->deq_seg->next; - ring->dequeue = ring->deq_seg->trbs; -return ; - } - -/* All other rings have link trbs */ -if (!trb_is_link (ring->dequeue)) { - ring->dequeue++; - ring->num_trbs_free++; - } -while (trb_is_link (ring->dequeue)) { - ring->deq_seg = ring->deq_seg->next; - ring->dequeue = ring->deq_seg->trbs; }trace_xhci_inc_deq (ring);
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v2 1/1 xhci: allow TRACE to work with EVENT ring dequeue
Quoted 5 lines · Adam Wallis
inc_deq()currently bails earlier for EVENT rings than the common return point of the function, due to the fact that EVENT rings do not have link TRBs. The unfortunate side effect of this is that the very usefultrace_xhci_inc_deq()function is not called/usable for EVENT ring debug.
True, makes sense to trace the event ring deq ptr as well.
Quoted 27 lines
This patch provides a refactor by removing the multiple return exit points into a single return which additionally allows for all rings to use the trace function.
Signed-off-by Adam Wallis <[email protected]>---
Changes in v2: undo accidental line removal at end of patchdrivers/usb/host/xhci-ring.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)drivers/usb/host/xhci-ring.c +6
-1@@ -171,23 +171,23 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring)if (ring->type ==TYPE_EVENT ) {if (!last_trb_on_seg (ring->deq_seg, ring->dequeue)) { ring->dequeue++; -return ; + }else { +if (last_trb_on_ring (ring, ring->deq_seg, + ring->dequeue)) + ring->cycle_state ^=1 ; + ring->deq_seg = ring->deq_seg->next; + ring->dequeue = ring->deq_seg->trbs;
drivers/usb/host/xhci-ring.c static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring) · line 189
Quoted 10 lines
drivers/usb/host/xhci-ring.c +10
-0+ } + }else { +/* All other rings have link trbs */ +if (!trb_is_link (ring->dequeue)) { + ring->dequeue++; + ring->num_trbs_free++; + } +while (trb_is_link (ring->dequeue)) { + ring->deq_seg = ring->deq_seg->next; + ring->dequeue = ring->deq_seg->trbs;
The added level of indentation makes it a little bit messier. How about just using goto out; instead of return?
out:
trace_xhci_inc_deq(ring);
-Mathias
PATCH v2 1/1 xhci: allow TRACE to work with EVENT ring dequeue
Quoted 51 lines · Mathias Nyman
Quoted 5 lines · Adam Wallis
inc_deq()currently bails earlier for EVENT rings than the common return point of the function, due to the fact that EVENT rings do not have link TRBs. The unfortunate side effect of this is that the very usefultrace_xhci_inc_deq()function is not called/usable for EVENT ring debug.True, makes sense to trace the event ring deq ptr as well.
Quoted 28 lines
This patch provides a refactor by removing the multiple return exit points into a single return which additionally allows for all rings to use the trace function.
Signed-off-by Adam Wallis <[email protected]>---
Changes in v2: undo accidental line removal at end of patch?
drivers/usb/host/xhci-ring.c| 32 ++++++++++++++++---------------- ? 1 file changed, 16 insertions(+), 16 deletions(-)drivers/usb/host/xhci-ring.c +6
-1@@ -171,23 +171,23 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring) ????? if (ring->type == TYPE_EVENT) { ????????? if (!last_trb_on_seg(ring->deq_seg, ring->dequeue)) { ????????????? ring->dequeue++; -??????????? return; +??????? } else { +??????????? if (last_trb_on_ring(ring, ring->deq_seg, +??????????????? ring->dequeue)) +??????????????? ring->cycle_state ^= 1; +??????????? ring->deq_seg = ring->deq_seg->next; +??????????? ring->dequeue = ring->deq_seg->trbs;drivers/usb/host/xhci-ring.c static void inc_deq(struct xhci_hcd *xhci, struct · line 190
Quoted 10 lines
drivers/usb/host/xhci-ring.c +10
-0+??????? } +??? } else { +??????? /* All other rings have link trbs */ +??????? if (!trb_is_link(ring->dequeue)) { +??????????? ring->dequeue++; +??????????? ring->num_trbs_free++; +??????? } +??????? while (trb_is_link(ring->dequeue)) { +??????????? ring->deq_seg = ring->deq_seg->next; +??????????? ring->dequeue = ring->deq_seg->trbs;The added level of indentation makes it a little bit messier. How about just using goto out; instead of return?
Quoted 2 lines
out:
????trace_xhci_inc_deq(ring);
My first version of this patch (before submission) actually had gotos, but I wasn't sure if you would accept. I agree that this will be much cleaner. v3 patch en route!
Quoted 7 lines
-Mathias
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org More majordomo info at? http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Adam Wallis Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.