>> As this is extremely rare (never reported in a real use case) >> I'd keep this as simple as possible. Allocate one bounce buffer when needed, and copy all. >> If memory allocation fails (unlikely) print a warning, then we immediately know what to fix. >> >> We are talking about sizes where 16 sg entries have in total 1024 bytes of data. >> > Ok, I agree. >> ehci-tegra.c does something related to what you want. It replaces >> urb->transfer_buffer with a dma aligned bounce buffer. >> > I tried this (in hcd.c) and it seems to be working with my tests. I want to override the > unmap_urb_for_dma() and map_urb_for_dma() and keep all other things same as xhci driver. > I thought to use xhci_driver_override for doing this instead of creating a whole new glue > driver. Would that be ok ? There is already support that allows host controller drivers to override the default usb_hcd_map_urb_for_dma() and usb_hcd_unmap_urb_for_dma() functions. see comments in include/linux/usb/hcd.h struct hc_driver We recently added xhci_map_urb_for_dma() override to support Immediate Data Transfers (IDT), I think your quirk will fit nicely there. It can be after the IDT check as your quirk is not needed if IDT is used (one trb with up to 8 bytes of data). you will probably need to add a xhci_unmap_urb_for_dma() callback. -Mathias