]> www.infradead.org Git - users/hch/misc.git/commitdiff
xhci: Add command completion parameter support
authorMathias Nyman <mathias.nyman@linux.intel.com>
Fri, 27 Dec 2024 12:01:41 +0000 (14:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Dec 2024 12:06:10 +0000 (13:06 +0100)
xHC hosts can pass 24 bits of data with a command completion event TRB
as the completion code only uses 8 bits of the 32 bit status field.

Only Configure Endpoint, and Get Extended Property commands utilize
this "command completion parameter" 24 bit field.
For other command completion events the xHC should keep it RsvdZ.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20241227120142.1035206-5-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.h

index dfe1a676d487c7f5342419c0d1624b99ccbe1dfa..3d66ed240dc375af3d51a7c6bcb1970efc7ecd49 100644 (file)
@@ -1650,12 +1650,13 @@ static void xhci_handle_cmd_nec_get_fw(struct xhci_hcd *xhci,
                        NEC_FW_MINOR(le32_to_cpu(event->status)));
 }
 
-static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 status)
+static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 comp_code, u32 comp_param)
 {
        list_del(&cmd->cmd_list);
 
        if (cmd->completion) {
-               cmd->status = status;
+               cmd->status = comp_code;
+               cmd->comp_param = comp_param;
                complete(cmd->completion);
        } else {
                kfree(cmd);
@@ -1667,7 +1668,7 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
        struct xhci_command *cur_cmd, *tmp_cmd;
        xhci->current_cmd = NULL;
        list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list)
-               xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED);
+               xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED, 0);
 }
 
 void xhci_handle_command_timeout(struct work_struct *work)
@@ -1752,6 +1753,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
                struct xhci_event_cmd *event)
 {
        unsigned int slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
+       u32 status = le32_to_cpu(event->status);
        u64 cmd_dma;
        dma_addr_t cmd_dequeue_dma;
        u32 cmd_comp_code;
@@ -1880,7 +1882,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
        }
 
 event_handled:
-       xhci_complete_del_and_free_cmd(cmd, cmd_comp_code);
+       xhci_complete_del_and_free_cmd(cmd, cmd_comp_code, COMP_PARAM(status));
 
        inc_deq(xhci, xhci->cmd_ring);
 }
index 4914f0a10cff42dbc1448dcf7908534d582c848e..8c164340a2c35099cedd081558236df3b1b5d14c 100644 (file)
@@ -529,6 +529,7 @@ struct xhci_command {
        /* Input context for changing device state */
        struct xhci_container_ctx       *in_ctx;
        u32                             status;
+       u32                             comp_param;
        int                             slot_id;
        /* If completion is null, no one is waiting on this command
         * and the structure can be freed after the command completes.
@@ -959,6 +960,9 @@ struct xhci_event_cmd {
        __le32 flags;
 };
 
+/* status bitmasks */
+#define COMP_PARAM(p)  ((p) & 0xffffff) /* Command Completion Parameter */
+
 /* Address device - disable SetAddress */
 #define TRB_BSR                (1<<9)