DVB, header files, and user-space regressions
A regression that was recently reported for 5.14 in the media subsystem is a bit of a strange beast. The kernel's user-space binary interface (ABI) was not changed, which is the usual test for a patch to get reverted, but the report still led to a reversion. The change did lead to problems building a user-space application because it moved some header files to staging/ as part of a cleanup for a deprecated—though apparently still functioning—driver for a Digital Video Broadcasting (DVB) device. There are a few different issues tangled together here, but the reversion of a regression in the user-space API (and not ABI) is a new wrinkle.
Soeren Moch reported the regression in a lengthy message on August 11. Parts of the message were aimed at Linus Torvalds and requested the reversion of three patches committed by media subsystem maintainer Mauro Carvalho Chehab. Those patches moved the av7110 driver to staging and followed up by moving some documentation and header files there as well. But that broke the ability to build parts of the Video Disk Recorder (VDR) application, which is shipped with multiple Linux distributions, Moch said.
He pointed to a Red Hat bug
that had been filed by another member of the VDR community as evidence of
the problem. VDR uses header files from the uapi/linux/dvb
directory; when those got moved, VDR would no longer build on the kernel
used for the upcoming Fedora 35. Beyond that, Moch disagreed with
moving "the long existing and working av7110 driver
" to
staging/.
Much of the email was addressed to Chehab; it complained about the deprecation of the existing DVB API [Update: As noted in the comments, this is the "full-featured" DVB API implemented by av7110 and used by VDR.], the removal of av7110 support, and Chehab's unwillingness to merge another driver that also implements the API. There are, Moch said, working devices and existing DVB streams that can be accessed using those drivers. He took issue with Chehab's commit message on the patch moving av7110:
Your commit message "the decoder supports only MPEG2, with is not compatible with several modern DVB streams" is at least misleading. The most popular satellite TV provider in Germany (Astra) still transmits most of the interesting programs MPEG-2 encoded, so also this is actively used and no reason to retire this card.
But Chehab sees things differently; the av7110 hardware stopped being produced 15 years ago and the DVB API that the driver implements is not useful for today's hardware:
The API that got removed was written to control the av7110 MPEG-2 decoder, and was never integrated at the DVB core: the av7110 had a driver-specific implementation inside its code.Besides that, the API was never fully documented: there are several ioctls from the now removed API that never had any in-kernel implementation, nor had and descriptions at the specs. None of the current upstream maintainers have any [clue] about what such ioctls are supposed to do, nor do we have any av7110 hardware to test it.
There is a clear disagreement about some of that, and Moch repeatedly offers to maintain the av7110 driver going forward. He would also like to see his saa716x driver, which also implements the DVB API, get merged and said he would maintain that as well. According to Moch, there is an active community that is using the hardware with VDR and the DVB API fits its needs well. But Chehab said:
Keeping av7110 in-kernel has been a waste of limited upstream development resources. A couple of years ago, we needed to fix the av7110 API due to year-2038 issues. From time to time, we get bugs affecting it (even security ones), as the code has been bit-rotting for a long time. The most recent one probably broke the driver without nobody noticing it for a couple of Kernel reviews, as mentioned above.
Moch disputes
that characterization and had some strongly worded complaints about
Chehab's handling of the media subsystem, part of which he addressed to
Torvalds. There is clearly a long-running dispute being aired in the
thread; Torvalds stepped
in to clarify a few things. He said that the regression policy is solely
aimed at the ABI of the kernel, which did not change: "old
programs continue to work
". He also lamented that VDR was using the
kernel headers directly; that is not how it is supposed to work:
We very much try to discourage user space applications from using the kernel header files directly - even projects like glibc etc are supposed to _copy_ them, not include the kernel headers.Exactly because re-organization and changes to the kernel tree shouldn't be something that then causes random problems elsewhere that are so hard to test - and synchronize - from the kernel standpoint (or from the standpoint of the other end).
On the other hand, though, the header files in question were in the
uapi directory: "while it is annoying how user space programs
used them this way, I think it's also not entirely unreasonable
".
So he reverted the header-file move, while leaving the other changes
(moving av7110 and the DVB API documentation to staging/) intact.
He suggested that VDR and any other application using the header files copy
them into their tree. He agreed with Chehab that moving av7110 out of the
main tree was the right move:
I'm not convinced that it makes sense to move the av7110 driver back from staging - it may continue to work, but it _is_ old and there is no maintenance - and I would certainly suggest that any other out-of-tree driver that uses these old interfaces that nothing else implements shouldn't do so, considering that nothing else implements them.
Both Torvalds and Chehab seem to ignore or discount Moch's offer to maintain the driver, though he presumably can do so in staging/. Keeping the driver working is a good way to ensure that it does not get removed altogether. Moch's questions about the eventual fate of av7110 remain unanswered, however:
How long can this driver stay in staging? Would you move the driver back from staging when I do proper maintenance for it? Is it normal linux policy to remove drivers after a certain period of time, even if a driver still has users and someone that volunteers to maintain it?
So, for now at least, users of VDR will be able to build it for recent
kernels; moving forward, copying the header files should ensure that it
continues to build. If the driver gets removed, though, users will also need to
build the driver in order to make things work. Chehab said that he
is open to discussing an API for DVB, "but such API should support modern embedded
hardware, and should be designed to allow it to be extended to
support to future needs
". That could lead to a reworked saa716x
driver that would be acceptable for inclusion in the mainline, but even
that hardware is quite old and it is not clear that the VDR community is
interested in making those kinds of changes.
It is somewhat surprising to see a working driver with an active community getting this treatment, but Chehab is adamant that the DVB API is deprecated as part of the media subsystem. In the thread, there is a strong undercurrent of displeasure with the treatment of the DVB API over the years and with Chehab's handling of it, but Linux maintainers have a wide remit over their subsystems. The two "sides" seem pretty dug in, at this point, so it may take some other interested parties stepping up to find some kind of workable solution—or the VDR community will need to continue using drivers that are either in staging/ or out of the mainline entirely.
This event does demonstrate a bit of an expansion of the regression policy for the kernel. Even though he was not happy about the use of the header files, Torvalds did not want to break an existing user-space application, thus the revert. One wonders how many other applications or libraries have not gotten the memo about not using the kernel user-space API header files directly, however. That could lead to problems with reorganizations and cleanups down the road.
Posted Aug 25, 2021 19:13 UTC (Wed)
by dullfire (guest, #111432)
[Link] (2 responses)
The overlooking of the offer to maintain seems... very odd to me.
Posted Aug 25, 2021 19:23 UTC (Wed)
by johill (subscriber, #25196)
[Link]
As far as I can tell, the driver is the only user of the DVB API that some at least would like to see removed, and thus getting rid of the driver is a necessary step. So removing the driver likely isn't the end of the road here - the goal is removing the other code that's old possibly has bad interactions with the rest of the system, and whatnot. I don't know what that code does, but if you look at what we've had to do with wireless extensions in WiFi ... those things are not fun.
Now, if somebody now were to maintain the driver in staging/ you could institute the same policy as elsewhere: if must use the APIs today considered correct to leave there.
It doesn't seem like that was on offer though, mostly it seemed to be "maintain the driver as is", with explicitly disagreement on the (eventual) removal of the DVB API.
Posted Sep 2, 2021 13:42 UTC (Thu)
by mrugiero (guest, #153040)
[Link]
Posted Aug 25, 2021 19:53 UTC (Wed)
by mss (subscriber, #138799)
[Link] (6 responses)
Rather, it's only a part of it, for so called "full-featured" devices, that was used just by the av7110 driver, that was moved to staging recently.
Posted Aug 26, 2021 1:29 UTC (Thu)
by jake (editor, #205)
[Link]
Yeah, that's a good point and I should have been clearer in the article, which I updated to hopefully help with that.
thanks!
jake
Posted Aug 26, 2021 12:55 UTC (Thu)
by mchehab (subscriber, #41156)
[Link] (4 responses)
Yes. The DVB API, used by all drivers is OK, and has been actively maintained.
The problem is related to the DVB API extension (called "full-featured") which brings support to start/stop in-hardware audio/video decoding. The API has problems that are known since 2005. There was an attempt to fix it back then by the API developers: https://www.linuxtv.org/downloads/legacy/linux-dvb-api-v4...). Unfortunately the company that was sponsoring the DVB API on that time bankrupted and such work stopped abruptly.
Quoting the 2005 document:
> 2.1 Present situation
Chapter 2.2 describes the known issues back in 2005. Some were never addressed:
> Linux DVB API Version 3 problems
It was offered in the past to merge the (also old) saa716x driver upstream, with the condition that the API would be redesigned, but the downstream maintainer of the driver didn't want to change the API.
Posted Aug 26, 2021 14:17 UTC (Thu)
by farnz (subscriber, #17727)
[Link] (2 responses)
I'm coming in clueless here (joys of not looking at this stuff in the last 5 years), but I recall there being work done on the Media Controller API to let you (e.g.) take audio and video streams from a demuxer, and feed them in-kernel to an appropriate ALSA audio device (that does decode and/or output to connectors) and V4L2 memory-to-memory decoder or output device.
Am I remembering that work properly? If so, would it work to have a V4L2 video decoder and an ALSA device for the SA716x and AV7110 chips, plus a suitable link in the Media Controller API to tell userspace that the chip prefers to be fed data from its own demux?
Posted Aug 27, 2021 0:02 UTC (Fri)
by pj (subscriber, #4506)
[Link]
Posted Aug 27, 2021 9:58 UTC (Fri)
by mchehab (subscriber, #41156)
[Link]
Yes.
In order to understand the issue, some explanation is needed.
A MPEG-TS may contain multiple elementary streams. On a "full-featured" hardware, there is a hardware demux, which is set via the normal DVB ("budget") API to filter audio, video and data elementary streams (ES) on its multiple outputs. Each demux filter output containing a video ES that will be decoded should then be wired to a video decoder. The same happens with audio ES and with OSD (On Screen Display) ES.
The deprecated "full-featured" API, as implemented on av7110, assumes that at most one audio and one video ES will be decoded on a given time. Such assumption works with TMS320AV7110 chipset (a.k.a. "av7110"), as the hardware has internally a single A/V codec set, and an independent video and audio output hardware, and an On Screen Display (OSD) generator on it, hardwired to handle an OSD elementary stream.
On modern devices and chipsets, there are multiple tuning stages ("frontend"), decoders and demuxes that are not hardwired nor grouped altogether. They typically have an Image Signal Processor (ISP) integrated with a GPU, and all other things, including OSD and programming guide are decoded by the CPU, and then sent to the displayed at the GPU. They can also do Picture in Picture. So, multiple video ES can be shown at the same time. Such hardare also allow any combination from frontend<x> to demux<y> to audio or video codec <z>. There's no way to control such hardware with the "full-featured" API, nor to expand it to fit such model.
That's where the media controller API takes place: it was designed to allow setting up the connections between multiple hardware/firmware blocks. With it, each demux output becomes visible, so it is easy to setup a pipeline from the tuner up to the audio/video outputs.
By using me media controller API, on chipsets where the A/V codecs need to be controlled and the display output needs to be composed, standard APIs should be used, e. g. V4L2 for codecs, ALSA for audio, DRM for video.
It doesn't sound too hard to convert a simple hardware like av7110 to use the media controller instead. On such hardware, there's no need for ALSA/V4L/DRM APIs, as there's nothing that can be controlled there. Yet, to do that, the developer needs to have such hardware and a PC with old PCI slots, plus a separate monitor (or stream capture hardware) with a RCA video input. On the other hand, there's not much value on doing that nowadays, as av7110 supports only MPEG2 for video and existing hardware probably comes supports only the first generation of the DVB standard. So, while it would be nice to do such work, there's not much value in practice, as probably there aren't much av7110 users anymore.
In any case, the driver is currently in staging. If someone is willing to do that, just send the patches. Once the driver got converted to the media controller, it can be moved back to mainstream.
The same applies to saa716x: if it gets converted to use the media controller and stop depending on the legacy full-featured API, it can also be merged upstream.
Posted Sep 22, 2021 17:03 UTC (Wed)
by fratti (guest, #105722)
[Link]
Posted Aug 26, 2021 8:08 UTC (Thu)
by pm215 (subscriber, #98099)
[Link] (2 responses)
And copying header files doesn't protect you from the incompatibility reported in this article, it just delays it. Existing source trees of your userspace program continue to build, which is nice, but next time you need to update the headers from the kernel for some reason you find you now need to maintain some frankenstein's-header mixture of up-to-date header and the old pre-removal header. (And if you're unlucky it took you long enough to notice that the old API bits are now firmly gone and not 'ok, let's revert' recoverable...)
Posted Aug 26, 2021 9:18 UTC (Thu)
by edeloget (subscriber, #88392)
[Link] (1 responses)
Posted Aug 26, 2021 16:48 UTC (Thu)
by pm215 (subscriber, #98099)
[Link]
Posted Aug 27, 2021 7:51 UTC (Fri)
by bmork (subscriber, #88411)
[Link] (1 responses)
I gave up and moved on after this bloody damn obvious patch just got stuck:
Those two files were merged with the rest of the driver, but never ever referenced by anything. Deleting them should be a no-brainer, and would be in any other subsystem.
Instead we still have drivers/media/pci/mantis/mantis_core.h (yes, Mauro moved this stuff around in 2012) in the current kernel. Do a git grep mantis_core.h and notice all the references...
mantis_core.c was finally removed by 519648bed470 ("media: mantis: remove orphan mantis_core.c") in 2020. After 10 years of blind patching of dead code.
Sure, dead code in an obscure driver is a minor issue. Unfortunately, I belive this is symptomatic for Mauros "maintenance" of the DVB subsystem. I fully understand Soerens frustration. I was lucky enough that I didn't have to care, and could just move on to other subsystems. Playing with DVB could have been fun. But it was definitely not worth the frustrations dealing with the linux-media subsystem and dead-end mailing list.
Posted Aug 27, 2021 15:27 UTC (Fri)
by corbet (editor, #1)
[Link]
(Just my own opinion, obviously).
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
Anybody can take a reservation, the important part is holding the reservation.
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
> as it is still used by _a lot_ of DVB drivers in the kernel.
DVB, header files, and user-space regressions
>
> First of all, PCs and embedded platforms are divering. For PCs, new cards are only available as ”budget” cards, which means that they only provide the full, raw, unmodified TS to the system and put the burden of handling the data to the main CPU.
> On embedded platforms, however, dedicated STB/IDTV chipsets demultiplex the data for direct application use and specialized hardware or firmware on DSPs relieves the main CPU greatly.
>
> The Linux DVB API Version 3 was focussed on the popular Siemens PCI DVB card.
> ...
> The Linux DVB API Version 3 has very limited support for modern hardware.
> ...
> Because of the architectual problems of the core, the inconsitency of the API and the lack of zero-copy DMA it’s not possible to simply extend the existing API. A complete new design is inevitable.
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
DVB, header files, and user-space regressions
https://lore.kernel.org/linux-media/1277054487-14384-1-gi...
So I was pretty active in the media subsystem 10+ years ago too, and was paying attention for longer. My experience is that, under Mauro's maintainership (and with a lot of help from people like Hans) it has gone from a toxic wild west to a smoothly functioning development community. All is not perfect — it never is — but I believe it to be a well-maintained subsystem for the most part. To me, this episode looks a bit like a holdover from the bad old days.
Media subsystem