DM USB: xHCI: refine the emulation of Stop Endpoint Command

Old implementation does nothing when Stop Endpoint cmd is received,
it is not right. The new implementation will cancel all the libusb
requests in processing.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Xiaoguang Wu
2019-05-08 22:43:26 +08:00
committed by ACRN System Integration
parent 1be719c630
commit 5a9627ced8
4 changed files with 117 additions and 61 deletions

View File

@@ -163,6 +163,7 @@ struct usb_data_xfer_block {
struct usb_data_xfer {
uint64_t magic;
struct usb_data_xfer_block data[USB_MAX_XFER_BLOCKS];
struct usb_dev_req *requests[USB_MAX_XFER_BLOCKS];
struct usb_device_request *ureq; /* setup ctl request */
int ndata; /* # of data items */
int head;
@@ -171,7 +172,6 @@ struct usb_data_xfer {
int epid; /* related endpoint id */
int pid; /* token id */
int status;
pthread_mutex_t mtx;
};
struct usb_devpath {
@@ -207,28 +207,6 @@ enum USB_ERRCODE {
#define USB_DATA_OK(x, i) ((x)->data[(i)].buf != NULL)
#define USB_DATA_XFER_INIT(x) do { \
pthread_mutexattr_t attr; \
pthread_mutexattr_init(&attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
memset((x), 0, sizeof(*(x))); \
pthread_mutex_init(&((x)->mtx), &attr); \
} while (0)
#define USB_DATA_XFER_RESET(x) do { \
pthread_mutex_lock(&((x)->mtx)); \
memset((x)->data, 0, sizeof((x)->data)); \
(x)->ndata = 0; \
(x)->head = (x)->tail = 0; \
pthread_mutex_unlock((&(x)->mtx)); \
} while (0)
#define USB_DATA_XFER_LOCK(x) \
pthread_mutex_lock(&((x)->mtx))
#define USB_DATA_XFER_UNLOCK(x) \
pthread_mutex_unlock(&((x)->mtx))
#define LOG_TAG "USB: "
#define LFTL 0
#define LWRN 1

View File

@@ -106,6 +106,8 @@ struct usb_dev_sys_ctx_info {
usb_dev_sys_cb disconn_cb;
usb_dev_sys_cb notify_cb;
usb_dev_sys_cb intr_cb;
usb_dev_sys_cb lock_ep_cb;
usb_dev_sys_cb unlock_ep_cb;
libusb_device **devlist;
@@ -118,6 +120,8 @@ struct usb_dev_sys_ctx_info {
/* intialize the usb_dev subsystem and register callbacks for HCD layer */
int usb_dev_sys_init(usb_dev_sys_cb conn_cb, usb_dev_sys_cb disconn_cb,
usb_dev_sys_cb notify_cb, usb_dev_sys_cb intr_cb,
usb_dev_sys_cb lock_ep_cb,
usb_dev_sys_cb unlock_ep_cb,
void *hci_data, int log_level);
void usb_dev_sys_deinit(void);
void *usb_dev_init(void *pdata, char *opt);