Changeset 889146e in mainline for uspace/drv/bus/usb/xhci/commands.h


Ignore:
Timestamp:
2017-12-10T21:49:12Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
53db806
Parents:
6ef407b
git-author:
Ondřej Hlavatý <aearsis@…> (2017-12-10 21:43:47)
git-committer:
Ondřej Hlavatý <aearsis@…> (2017-12-10 21:49:12)
Message:

xhci: commands shall not just timeout

Previous behavior was breaking semantic: if a command was successful,
but just took too long to complete, we returned an error, and the caller
had no way to know if the command's effect has taken place.

This commit implements command aborting. The wait_for_command now cannot
just timeout - instead it aborts currently running (probably blocked)
command, and then gets back to waiting. So now, if command_sync returns
an error, it means the command was really unsuccessful.

If aborting the command takes too long, we should reset the whole HC.
This is not yet implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/commands.h

    r6ef407b r889146e  
    4242#include <usb/host/dma_buffer.h>
    4343#include "hw_struct/trb.h"
     44#include "trb_ring.h"
    4445
    45 #define XHCI_DEFAULT_TIMEOUT       1000000
    46 #define XHCI_BLOCK_INDEFINITELY    0
     46#define XHCI_COMMAND_TIMEOUT       10000
     47#define XHCI_CR_ABORT_TIMEOUT       5000
    4748
    4849typedef struct xhci_hc xhci_hc_t;
     
    6869} xhci_cmd_type_t;
    6970
     71typedef enum {
     72        XHCI_CR_STATE_CLOSED,           /**< Commands are rejected with ENAK. */
     73        XHCI_CR_STATE_OPEN,             /**< Commands are enqueued normally. */
     74        XHCI_CR_STATE_CHANGING,         /**< Commands wait until state changes. */
     75} xhci_cr_state;
     76
     77typedef struct xhci_command_ring {
     78        xhci_trb_ring_t trb_ring;
     79
     80        fibril_mutex_t guard;           /**< Guard access to this structure. */
     81        list_t cmd_list;
     82
     83        xhci_cr_state state;            /**< Whether commands are allowed to be
     84                                             added. */
     85        fibril_condvar_t state_cv;      /**< For waiting on CR state change. */
     86
     87        fibril_condvar_t stopped_cv;    /**< For waiting on CR stopped event. */
     88} xhci_cmd_ring_t;
     89
    7090typedef struct xhci_command {
    7191        /** Internal fields used for bookkeeping. Need not worry about these. */
     
    7494
    7595                xhci_cmd_type_t cmd;
    76                 suseconds_t timeout;
    7796
    7897                xhci_trb_t trb;
     
    130149        fibril_condvar_initialize(&cmd._header.completed_cv);
    131150
    132         if (!cmd._header.timeout) {
    133                 cmd._header.timeout = XHCI_DEFAULT_TIMEOUT;
    134         }
    135 
    136151        /* Issue the command */
    137152        const int err = xhci_cmd_sync(hc, &cmd);
Note: See TracChangeset for help on using the changeset viewer.