Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Use a bounce buffer for rtlsdr on ARM to work around zero-copy problems.
On 5.x kernels with the USB mmap problems fixed, the distributed librtlsdr will use a zero-copy mapping for USB buffers. Unfortunately, there is something about the nature of the mapping on ARM (at least on Pis) that makes most access to the data extremely slow. The uc8_nodc converter is about 35x slower in this case compared to working on a heap-allocated buffer. Luckily, a plain memcpy() of the buffer is still reasonably fast, so we can use a bounce buffer and copy the data out of the slow mapping, then pass the copy to the converter. This mitigates most of the problem, at the expense of always needing that extra copy (which does somewhat defeat the purpose of zero-copy!) Unfortunately, librtlsdr provides no reliable way to control or detect the use of zero-copy mappings, so we have to assume the problem is always there (at least on ARM) and pay the cost of an unnecessary copy when zerocopy is _not_ in use, too.
- Loading branch information
653ad61There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this perhaps related to the following message that I have gotten with multiple RTL-SDR applications (notably rtl_433) on NetBSD earmv6hf:
"Please increase your allowed usbfs buffer size with the following command: echo 0 > /sys/module/usbcore/parameters/usbfs_memory_mb"
653ad61There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really related. That message is librtlsdr telling you that it failed to submit a transfer to libusb: https://github.com/steve-m/librtlsdr/blob/master/src/librtlsdr.c#L1894
(that message is linux-specific; I don't know what the failure mode on netbsd you're seeing is, but it might be that you're hitting a similar limit to what happens on linux)