Linux USB
 help / color / mirror / Atom feed
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 2/7] usb: xhci: add xhci_queue_set_deq() helper
Date: Tue,  1 Dec 2026 20:41:29 +0100	[thread overview]
Message-ID: <20261201194134.265480-3-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20261201194134.265480-1-niklas.neronin@linux.intel.com>

Most xHCI commands have dedicated xhci_queue_*() helper functions that
encapsulate TRB construction and command queueing.

The Set TR Dequeue Pointer command is currently assembled directly in
xhci_move_deq_to_next_td(), making it the only command that bypasses
this pattern.

Add an xhci_queue_set_deq() helper and convert the existing user to it.
This improves consistency with the other command queue helpers and keeps
Set TR Dequeue Pointer TRB construction in a single location.

No functional change intended.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
 drivers/usb/host/xhci-ring.c | 21 +++++++++++++--------
 drivers/usb/host/xhci.h      |  3 +++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 53e1e9a59f14..7f983e8d4697 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -62,9 +62,6 @@
 #include "xhci.h"
 #include "xhci-trace.h"
 
-static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
-			 u32 field1, u32 field2,
-			 u32 field3, u32 field4, bool command_must_succeed);
 static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci, int slot_id, int ep_index);
 
 /*
@@ -755,11 +752,9 @@ static int xhci_move_deq_to_next_td(struct xhci_hcd *xhci,
 
 	if (stream_id)
 		trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
-	ret = queue_command(xhci, cmd,
-		lower_32_bits(addr) | trb_sct | new_cycle,
-		upper_32_bits(addr),
-		STREAM_ID_FOR_TRB(stream_id), SLOT_ID_FOR_TRB(ep->vdev->slot_id) |
-		EP_INDEX_FOR_TRB(ep->ep_index) | TRB_TYPE(TRB_SET_DEQ), false);
+
+	ret = xhci_queue_set_deq(xhci, cmd, addr, ep->vdev->slot_id, ep->ep_index, stream_id,
+				 new_cycle, trb_sct);
 	if (ret < 0)
 		goto err_out;
 
@@ -4541,3 +4536,13 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd,
 	return queue_command(xhci, cmd, 0, 0, 0,
 			trb_slot_id | trb_ep_index | type, false);
 }
+
+int xhci_queue_set_deq(struct xhci_hcd *xhci, struct xhci_command *cmd, dma_addr_t addr,
+		       u32 slot_id, unsigned int ep_index, unsigned int stream_id, int new_cycle,
+		       u32 trb_sct)
+{
+	return queue_command(xhci, cmd, lower_32_bits(addr) | trb_sct | new_cycle,
+			     upper_32_bits(addr), STREAM_ID_FOR_TRB(stream_id),
+			     SLOT_ID_FOR_TRB(slot_id) | EP_INDEX_FOR_TRB(ep_index) |
+			     TRB_TYPE(TRB_SET_DEQ), false);
+}
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index ec4bfeb4887c..852a6b537a60 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1950,6 +1950,9 @@ int xhci_queue_evaluate_context(struct xhci_hcd *xhci, struct xhci_command *cmd,
 int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd,
 		int slot_id, unsigned int ep_index,
 		enum xhci_ep_reset_type reset_type);
+int xhci_queue_set_deq(struct xhci_hcd *xhci, struct xhci_command *cmd, dma_addr_t addr,
+		       u32 slot_id, unsigned int ep_index, unsigned int stream_id, int new_cycle,
+		       u32 trb_sct);
 int xhci_queue_reset_device(struct xhci_hcd *xhci, struct xhci_command *cmd,
 		u32 slot_id);
 void xhci_handle_command_timeout(struct work_struct *work);
-- 
2.50.1


  parent reply	other threads:[~2026-12-01 19:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 19:41 [PATCH 0/7] usb: xhci: command queueing cleanups Niklas Neronin
2026-12-01 19:41 ` [PATCH 1/7] usb: xhci: simplify xhci_get_input_control_ctx() Niklas Neronin
2026-12-01 19:47   ` sashiko-bot
2026-12-01 19:41 ` Niklas Neronin [this message]
2026-12-01 19:41 ` [PATCH 3/7] usb: xhci: simplify prepare_ring() Niklas Neronin
2026-12-01 19:41 ` [PATCH 4/7] usb: xhci: split Configure Endpoint and Evaluate Context handling Niklas Neronin
2026-12-01 19:41 ` [PATCH 5/7] usb: xhci: clear EP_GETTING_NO_STREAMS when freeing streams fails Niklas Neronin
2026-12-01 19:52   ` sashiko-bot
2026-12-01 19:41 ` [PATCH 6/7] usb: xhci: remove pre-allocated free streams command Niklas Neronin
2026-12-01 19:41 ` [PATCH 7/7] usb: xhci: remove command ring TRB reservation Niklas Neronin
2026-12-01 19:52 ` [PATCH 0/7] usb: xhci: command queueing cleanups sashiko-bot

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=20261201194134.265480-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox