xhci ring memory is fetched from the memory resource pool.

This commit is contained in:
songyanguang 2024-08-07 09:32:21 +08:00
parent f8768d29a2
commit 98a64f616d
1 changed files with 7 additions and 8 deletions

View File

@ -859,9 +859,8 @@ int xhci_usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_c
struct usbh_hubport *hport = ep_cfg->hport;
struct xhci_endpoint *ppipe = usb_align(XHCI_RING_SIZE, sizeof(struct xhci_endpoint));
struct xhci_slot *slot;
uintptr_t ring_vir;
uintptr_t ring_phy;
size_t len;
struct usb_mem_page ring_page;
if (NULL == ppipe) {
return -ENOMEM;
@ -882,15 +881,15 @@ int xhci_usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_c
/* Allocate xHCI ring */
len = sizeof(*ppipe->ep_reqs);
rc = naive_mmap(&ring_vir, &ring_phy, len, false);
rc = usb_alloc_mem_data_page(&ring_page);
if(rc != 0){
USB_LOG_ERR("XHCI %s could not allocate xhci device context\n", xhci->name );
USB_LOG_ERR("XHCI %s could not allocate xhci ring\n", xhci->name );
rc = -ENOMEM;
goto failed;
}
ppipe->ep_reqs_vir = ring_vir;
ppipe->ep_reqs_phy = ring_phy;
ppipe->ep_reqs = (struct xhci_ring *)ring_vir;
ppipe->ep_reqs_vir = ring_page.vir_addr;
ppipe->ep_reqs_phy = ring_page.phy_addr;
ppipe->ep_reqs = (struct xhci_ring *)ppipe->ep_reqs_vir;
memset ( ppipe->ep_reqs, 0, len );
if (ppipe->address == 0) { /* if try to allocate ctrl ep, open device first */