basler / linux-usb-zerocopy

usb3 zerocopy support for linux
https://github.com/Basler/linux-usb-zerocopy/wiki
Other
4 stars 2 forks source link

ensure ehci and ohci compatibility #4

Open stefanklug opened 9 years ago

stefanklug commented 9 years ago

Zerocopy should also be supported for ehci controllers. At least ehci and ohci controllers must be detected and ensured that everything still works on these devices.

Idea: check if devices's dma_mask is > physical memory of the system. If yes, we can unconditionally use any memory from userspace. Otherwise we disable zerocopy completely for this device. This way we don't have to switch between copying and zerocopy based on the buffer we got from userspace. And newer controllers should support dma to the whole physical memory anyway.

parafin commented 9 years ago

As far as I understood both xHCI and EHCI come in both variants - 32 and 64 bit capable. But with xHCI it's common (very likely) that it supports 64 bit, with EHCI I'm not sure exactly, but 64 bit support isn't as common. Having said that, I don't see any other way but to disable zerocopy in case dma mask is less than memory size. Another question is buffer alignment. With xHCI there are no requirements (if I read the spec correctly), with others I'm not sure (at least 32 bytes alignment requirement exists in some) - didn't investigate yet. I'm guessing to require the buffer to be aligned to page boundary would be enough and reasonable, if for some controller it's not enough, then disable zero copy.