From: Niklas Neronin <niklas.neronin@linux.intel.com>
To: mathias.nyman@linux.intel.com
Cc: linux-usb@vger.kernel.org,
Niklas Neronin <niklas.neronin@linux.intel.com>
Subject: [PATCH 7/8] usb: xhci: add help function xhci_dequeue_td()
Date: Thu, 17 Oct 2024 16:05:07 +0300 [thread overview]
Message-ID: <20241017130508.1293021-8-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20241017130508.1293021-1-niklas.neronin@linux.intel.com>
Add xhci_dequeue_td() helper function to reduce code duplication.
Function xhci_dequeue_td() advances the dequeue pointer past the specified
Transfer Descriptor (TD) and releases the TD.
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
drivers/usb/host/xhci-ring.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 13eadee89839..7221547683d8 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -859,6 +859,16 @@ static void xhci_td_cleanup(struct xhci_hcd *xhci, struct xhci_td *td,
}
}
+/* Give back previous TD and move on to the next TD. */
+static void xhci_dequeue_td(struct xhci_hcd *xhci, struct xhci_td *td, struct xhci_ring *ring,
+ u32 status)
+{
+ ring->dequeue = td->end_trb;
+ ring->deq_seg = td->end_seg;
+ inc_deq(xhci, ring);
+
+ xhci_td_cleanup(xhci, td, ring, status);
+}
/* Complete the cancelled URBs we unlinked from td_list. */
static void xhci_giveback_invalidated_tds(struct xhci_virt_ep *ep)
@@ -2258,12 +2268,7 @@ static void finish_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
break;
}
- /* Update ring dequeue pointer */
- ep_ring->dequeue = td->end_trb;
- ep_ring->deq_seg = td->end_seg;
- inc_deq(xhci, ep_ring);
-
- xhci_td_cleanup(xhci, td, ep_ring, td->status);
+ xhci_dequeue_td(xhci, td, ep_ring, td->status);
}
/* sum trb lengths from the first trb up to stop_trb, _excluding_ stop_trb */
@@ -2496,12 +2501,7 @@ static void skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
/* calc actual length */
frame->actual_length = 0;
- /* Update ring dequeue pointer */
- ep->ring->dequeue = td->end_trb;
- ep->ring->deq_seg = td->end_seg;
- inc_deq(xhci, ep->ring);
-
- xhci_td_cleanup(xhci, td, ep->ring, status);
+ xhci_dequeue_td(xhci, td, ep->ring, status);
}
/*
@@ -2791,10 +2791,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
if (td && td->error_mid_td && !trb_in_td(xhci, td, ep_trb_dma, false)) {
xhci_dbg(xhci, "Missing TD completion event after mid TD error\n");
- ep_ring->dequeue = td->end_trb;
- ep_ring->deq_seg = td->end_seg;
- inc_deq(xhci, ep_ring);
- xhci_td_cleanup(xhci, td, ep_ring, td->status);
+ xhci_dequeue_td(xhci, td, ep_ring, td->status);
}
if (list_empty(&ep_ring->td_list)) {
--
2.45.2
next prev parent reply other threads:[~2024-10-17 13:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 13:05 [PATCH 0/8] usb: xhci: various xhci cleanups and improvements Niklas Neronin
2024-10-17 13:05 ` [PATCH 1/8] usb: xhci: simplify TDs start and end naming scheme in struct 'xhci_td' Niklas Neronin
2024-10-17 21:59 ` Michał Pecio
2024-10-17 13:05 ` [PATCH 2/8] usb: xhci: move link TRB quirk to xhci_gen_setup() Niklas Neronin
2024-10-17 13:05 ` [PATCH 3/8] usb: xhci: request MSI/-X according to requested amount Niklas Neronin
2024-10-17 13:05 ` [PATCH 4/8] usb: xhci: improve xhci_clear_command_ring() Niklas Neronin
2024-10-17 13:05 ` [PATCH 5/8] usb: xhci: remove unused arguments from td_to_noop() Niklas Neronin
2024-10-17 13:05 ` [PATCH 6/8] usb: xhci: refactor xhci_td_cleanup() to return void Niklas Neronin
2024-10-17 13:05 ` Niklas Neronin [this message]
2024-10-17 13:05 ` [PATCH 8/8] usb: xhci: remove irrelevant comment Niklas Neronin
2024-10-30 14:35 ` [PATCH 0/8] usb: xhci: various xhci cleanups and improvements 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=20241017130508.1293021-8-niklas.neronin@linux.intel.com \
--to=niklas.neronin@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.