Modify address mapping in xhci_transfer

This commit is contained in:
xj 2024-08-06 23:33:57 -07:00
parent 98a64f616d
commit 22b137f92f
1 changed files with 6 additions and 5 deletions

View File

@ -2712,24 +2712,25 @@ static void xhci_transfer ( struct xhci_host *xhci,
struct xhci_trb_transfer *trb ) { struct xhci_trb_transfer *trb ) {
struct xhci_slot *slot; struct xhci_slot *slot;
struct xhci_endpoint *endpoint; struct xhci_endpoint *endpoint;
uintptr_t vir_addr; uintptr_t vir_addr, phy_addr;
union xhci_trb *trans_trb; union xhci_trb *trans_trb;
struct xhci_ring *trans_ring; struct xhci_ring *trans_ring;
union xhci_trb *pending; union xhci_trb *pending;
uint32_t eidx; uint32_t eidx;
int rc; int rc;
vir_addr = usb_mem_data_page_phy2vir(trb->transfer); phy_addr = (trb->transfer & ~(XHCI_RING_SIZE-1));
vir_addr = usb_mem_data_page_phy2vir(phy_addr);
#if 0 #if 0
if(!vir_addr) if(!vir_addr)
return; return;
#endif #endif
trans_trb = (void *)(uintptr_t)(vir_addr); // trans_trb = trb->transfer;
trans_ring = XHCI_RING(trans_trb); /* to align addr is ring base */ trans_ring = (struct xhci_ring *)(vir_addr); /* to align addr is ring base */
pending = &trans_ring->evt; /* preserve event trb pending to handle */ pending = &trans_ring->evt; /* preserve event trb pending to handle */
eidx = trans_trb - trans_ring->ring + 1; /* calculate current evt trb index */ eidx = (trb->transfer - phy_addr)/sizeof(union xhci_trb) + 1; /* calculate current evt trb index */
/* Identify slot */ /* Identify slot */
if ( ( trb->slot > xhci->slots ) || if ( ( trb->slot > xhci->slots ) ||