Skip to content

Commit 3ac820f

Browse files
matnymangregkh
authored andcommitted
xhci: Add command completion parameter support
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1e0a199 commit 3ac820f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,12 +1650,13 @@ static void xhci_handle_cmd_nec_get_fw(struct xhci_hcd *xhci,
16501650
NEC_FW_MINOR(le32_to_cpu(event->status)));
16511651
}
16521652

1653-
static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 status)
1653+
static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 comp_code, u32 comp_param)
16541654
{
16551655
list_del(&cmd->cmd_list);
16561656

16571657
if (cmd->completion) {
1658-
cmd->status = status;
1658+
cmd->status = comp_code;
1659+
cmd->comp_param = comp_param;
16591660
complete(cmd->completion);
16601661
} else {
16611662
kfree(cmd);
@@ -1667,7 +1668,7 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
16671668
struct xhci_command *cur_cmd, *tmp_cmd;
16681669
xhci->current_cmd = NULL;
16691670
list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list)
1670-
xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED);
1671+
xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED, 0);
16711672
}
16721673

16731674
void xhci_handle_command_timeout(struct work_struct *work)
@@ -1752,6 +1753,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
17521753
struct xhci_event_cmd *event)
17531754
{
17541755
unsigned int slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
1756+
u32 status = le32_to_cpu(event->status);
17551757
u64 cmd_dma;
17561758
dma_addr_t cmd_dequeue_dma;
17571759
u32 cmd_comp_code;
@@ -1880,7 +1882,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
18801882
}
18811883

18821884
event_handled:
1883-
xhci_complete_del_and_free_cmd(cmd, cmd_comp_code);
1885+
xhci_complete_del_and_free_cmd(cmd, cmd_comp_code, COMP_PARAM(status));
18841886

18851887
inc_deq(xhci, xhci->cmd_ring);
18861888
}

drivers/usb/host/xhci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ struct xhci_command {
529529
/* Input context for changing device state */
530530
struct xhci_container_ctx *in_ctx;
531531
u32 status;
532+
u32 comp_param;
532533
int slot_id;
533534
/* If completion is null, no one is waiting on this command
534535
* and the structure can be freed after the command completes.
@@ -959,6 +960,9 @@ struct xhci_event_cmd {
959960
__le32 flags;
960961
};
961962

963+
/* status bitmasks */
964+
#define COMP_PARAM(p) ((p) & 0xffffff) /* Command Completion Parameter */
965+
962966
/* Address device - disable SetAddress */
963967
#define TRB_BSR (1<<9)
964968

0 commit comments

Comments
 (0)