usb: ehci: tegra: Fence read in unmap urb
Krishna Yarlagadda [Wed, 11 Apr 2012 18:25:07 +0000 (23:25 +0530)]
There is a chance that we might read an TD request which
has just arrived after fence read in a interrupt handler.
Added fence read in unmap urb to avoid this issue.

Bug 964879

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/95916
(cherry picked from commit 8d8415820014710052eef088ed2d579d0531cd52)

Change-Id: Ia682654a25c685cf3dd2e76c8b9ea30427a06d89
Reviewed-on: http://git-master/r/97507
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

drivers/usb/host/ehci-tegra.c

index 7f17c2c..1c484a4 100644 (file)
@@ -950,6 +950,16 @@ static int tegra_ehci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
 
 static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
 {
+       struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
+
+       /* Fence read for coherency of AHB master intiated writes */
+       if (tegra->phy->instance == 0)
+               readb(IO_ADDRESS(IO_PPCS_PHYS + USB1_PREFETCH_ID));
+       else if (tegra->phy->instance == 1)
+               readb(IO_ADDRESS(IO_PPCS_PHYS + USB2_PREFETCH_ID));
+       else if (tegra->phy->instance == 2)
+               readb(IO_ADDRESS(IO_PPCS_PHYS + USB3_PREFETCH_ID));
+
        usb_hcd_unmap_urb_for_dma(hcd, urb);
        free_dma_aligned_buffer(urb);
 }