DM USB: dynamically allocate block count for struct usb_xfer

The block count of the struct usb_xfer is hard coded by the macro
USB_MAX_XFER_BLOCKS (1024), it wastes memory if 1024 blocks are
allocated for low speed transfer such as control transfer or interrupt
transfer. This patch introduces a new method to allocate different
number of blocks according to different endpoint type.

Tracked-On: #3628
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-08-27 22:28:18 +08:00
committed by wenlingz
parent f1b142e6e0
commit 06781b37e9
6 changed files with 95 additions and 42 deletions

View File

@@ -42,8 +42,6 @@
* By default, the native xhci driver use two segments which contain 2 * 256
* trbs, so 1024 is enough currently.
*/
#define USB_MAX_XFER_BLOCKS 1024
#define USB_XFER_OUT 0
#define USB_XFER_IN 1
@@ -164,9 +162,8 @@ struct usb_block {
};
struct usb_xfer {
uint64_t magic;
struct usb_block data[USB_MAX_XFER_BLOCKS];
struct usb_dev_req *requests[USB_MAX_XFER_BLOCKS];
struct usb_block *data;
struct usb_dev_req **reqs;
struct usb_device_request *ureq; /* setup ctl request */
int ndata; /* # of data items */
int head;
@@ -174,6 +171,7 @@ struct usb_xfer {
void *dev; /* struct pci_xhci_dev_emu *dev */
int epid; /* related endpoint id */
int pid; /* token id */
int max_blk_cnt;
int status;
};

View File

@@ -190,6 +190,15 @@ struct xhci_endp_ctx {
volatile uint32_t dwEpCtx7;
};
#define XHCI_EPTYPE_INVALID 0
#define XHCI_EPTYPE_ISOC_OUT 1
#define XHCI_EPTYPE_BULK_OUT 2
#define XHCI_EPTYPE_INT_OUT 3
#define XHCI_EPTYPE_CTRL 4
#define XHCI_EPTYPE_ISOC_IN 5
#define XHCI_EPTYPE_BULK_IN 6
#define XHCI_EPTYPE_INT_IN 7
struct xhci_input_ctx {
#define XHCI_INCTX_NON_CTRL_MASK 0xFFFFFFFCU
volatile uint32_t dwInCtx0;