]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: xhci: Fix DMA address calculation in queue_trb
authorHector Martin <marcan@marcan.st>
Sun, 29 Oct 2023 06:37:44 +0000 (15:37 +0900)
committerMarek Vasut <marex@denx.de>
Fri, 1 Dec 2023 13:06:04 +0000 (14:06 +0100)
We need to get the DMA address before incrementing the pointer, as that
might move us onto another segment.

Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/usb/host/xhci-ring.c

index ae0ab5744df0d793fb1a1fb429fbf5c3c6562421..b60661fe05e7317978dfb757cbd292658f781c0a 100644 (file)
@@ -202,6 +202,7 @@ static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring,
                            bool more_trbs_coming, unsigned int *trb_fields)
 {
        struct xhci_generic_trb *trb;
+       dma_addr_t addr;
        int i;
 
        trb = &ring->enqueue->generic;
@@ -211,9 +212,11 @@ static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring,
 
        xhci_flush_cache((uintptr_t)trb, sizeof(struct xhci_generic_trb));
 
+       addr = xhci_trb_virt_to_dma(ring->enq_seg, (union xhci_trb *)trb);
+
        inc_enq(ctrl, ring, more_trbs_coming);
 
-       return xhci_trb_virt_to_dma(ring->enq_seg, (union xhci_trb *)trb);
+       return addr;
 }
 
 /**