Librtlsdr zerocopy buffers not working on Tinkerboard Armbian

Carl Laufer admin at rtl-sdr.com
Tue Oct 2 04:22:14 UTC 2018


I did some more tests. I upgraded the OS on my Odroid XU4 to Ubuntu 18.04,
and this has libusb 1.0.21 in the repo's (the previous one I was using had
libusb 1.0.20). Now I get the same continuous lost sample bytes problem on
the XU4 as on the Tinkerboard - a huge amount of dropped samples with
zerocopy enabled.

However, on the latest Raspbian on the Rpi3, I don't see the problem. On
the Pi3 rtl_test returns only one line of dropped samples, then no more.

Allocating 15 zero-copy buffers
lost at least 156 bytes

On the Odroid and Tinkerboard it's more like:

Allocating 15 zero-copy buffers
lost at least 13617588 bytes
lost at least 12326518 bytes
lost at least 13208366 bytes
lost at least 13301044 bytes
...and so on forever

No other error messages are seen, and disabling the usbfs_memory_mb limit
by setting it to zero doesn't get rid of the problem.

I'm not too sure about the CMA stuff, i'm just using the default OS images
provided for the Tinkerboard and XU4, and standard Ubuntu 18.04 on my
laptop.

Regards,
Carl Laufer

On Tue, Oct 2, 2018 at 10:28 AM Steve Markgraf <steve at steve-m.de> wrote:

> Hi Carl,
>
> On 01.10.2018 05:42, Carl Laufer wrote:
> > I did a diff against Keenerds and discovered the new zerocopy buffer
> > code in the Osmocom drivers. After commenting that out, the Osmocom
> > drivers work fine on the Tinkerboard with Armbian and there is no sample
> > loss.
>
> That's very strange, because from an rtl-sdr point of view it is just
> regular memory that was allocated by the Kernel (and happens to be
> DMA-able) and mapped into userspace. So my first guess is that something
> must be going wrong either inside the Kernel or libusb.
>
> > Strangely, on TinkerOS and Ubuntu OS for Tinkerboard, all of which run
> > Kernel 4.4, I do not get sample loss with the Osmocom drivers and the
> > zerocopy code enabled.
>
> Yes, as 4.4 doesn't support usbfs zerocopy.
>
> > I'm also running the Osmocom drivers on an Odroid XU4 with Ubuntu which
> > is also running Kernel 4.14, and on Raspbian, and on those there is no
> > sample loss. So it seems to be something specific to the Tinkerboard and
> > Armbian with Kernel 4.14y.
> >
> > Not sure if the zerocopy code is just not getting activated on those
> > other OSes or what. How do I check if the installed libusb API version
> > is >= 0x01000105?
>
> I've put that information into the commit message:
>
> > Requires Linux >= 4.6 and libusb >= 1.0.21.
>
> (
> https://cgit.osmocom.org/rtl-sdr/commit/?id=a854ae8b48d42e8dad514c75d3a4c6cfb62707da
> )
>
> So it's enabled if both versions are there.
>
> > Any ideas what could cause the zero copy code to result in the lost
> samples?
>
> Do you get any error messages when the library is loaded? What is the
> value of /sys/module/usbcore/parameters/usbfs_memory_mb, and can you try
> to increase it or set it to 0 to disable the limit?
>
> Was the Kernel built with CONFIG_CMA=y, and what is the value of
> CONFIG_CMA_SIZE_MBYTES?
>
> If any of this isn't right, there normally should appear a warning and
> "falling back to buffers in userspace" when starting the application,
> but maybe there is something going wrong...
>
> Regards,
> Steve
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/osmocom-sdr/attachments/20181002/020935b8/attachment.html>


More information about the osmocom-sdr mailing list