News for hackers. Stuff that matters.
Re:Free user space for non-graphics drivers by ddevault on Saturday June 06, 2020 @01:50PM (#23440944)
Strong support for rejecting kernel drivers with a proprietary userspace counterpart. Totally violates the spirit of the GPL. I was NACK to this WSL driver, too, totally flies in the face of the rest of the Linux graphics stack. Companies should get in the habit of talking to the kernel early, and not just dumping a patchset over the fence and hoping we like it.
Re:Free user space for non-graphics drivers by chrisseaton on Saturday June 06, 2020 @02:52PM (#23441450)
Why do companies care if their driver is in the main kernel repository or not? All that matters is if distributions ship it, which they have to if people want their computers to work. Why don't they just say 'take it or leave it.'
Re:Free user space for non-graphics drivers by g_p on Saturday June 06, 2020 @08:09PM (#23443498)
Good question. The answer is that it requires you to keep your driver maintained as a patch that applies against the kernel you want to use it on.

Every release, there's refactoring and improvements of the kernel subsystems. They don't offer stable APIs (by design) for drivers - you need to keep it up to date.

If you want to see this for real, try getting a "code thrown over the wall once" type embedded device kernel tree, figure out the kernel version it shipped on (likely ancient), and try to apply the latest patch level for that release to it. Then resolve the inevitable issues even just applying a few minor bug fixes.

Now if you to to update to the next major kernel version, you'll start to find functions your driver tried to call aren't there, or have new function definitions. You need to dig through the code to see what's changed. Over a few major versions, you'll eventually realise this is a whole lot of bother. If you just mainline your driver, you'll no longer need to worry about this costly maintenance burden - it might well be a few engineers spending most of their time on it. That quickly adds up, and suddenly mainlining starts to make sense.

Nvidia has to keep updating their proprietary driver every release, and presumably has a few developers doing this. I can't speak for how well it works, as I always go for AMD, but other comments here seem to confirm distributions will happily break Nvidia drivers because they aren't mainline and therefore aren't tested.

Re:Free user space for non-graphics drivers by tasogare on Saturday June 06, 2020 @11:18PM (#23444487)
> They don't offer stable APIs (by design) for drivers

The real problem lies in this practice. Which other popular system uses this approach? Windows, macOS but also open source alternative like FreeBSD all have well-defined kernel API and drivers SDK. So, not providing a standard interface but then crying for the lack of third party drivers is hypocritical: the problem is self-inflicted.

Re:Free user space for non-graphics drivers by cycloptic on Sunday June 07, 2020 @12:24AM (#23444753)
This has been explained so much that there is a documentation page all about it: https://www.kernel.org/doc/html/latest/process/stable-api-no...

No other popular system follows the same development cycle as the Linux kernel.

Re:Free user space for non-graphics drivers by g_p on Sunday June 07, 2020 @09:30AM (#23447190)
Good link - there's also a clear case that "requiring" the kernel to provide long-term stable driver API/ABIs is simply reallocating a cost towards the benevolent open source maintainers, to allow closed-source companies "leeching" (to use Greg K-H's words) from the kernel devs to benefit.

There's clearly a non-zero (and indeed non-trivial) cost to providing a stable kernel driver API, and the kernel devs don't want to bear that cost, as they feel it would hold back the kernel from evolving, improving on APIs, and fixing security issues or other implementation bugs.

The other side of the coin is that closed driver developers want this stable API to reduce their own development costs, but they will not follow the "intended" workflow that reduces the ongoing maintenance cost to effectively zero.

Re:Free user space for non-graphics drivers by agapon on Tuesday June 09, 2020 @04:46AM (#23464916)
Unfortunately, that's not very true for FreeBSD. Complex driver modules (e.g., virtualbox, graphics) get broken all the time by kernel API changes. However you can replace FreeBSD with illumos -- it has a well defined DDI (device driver interface), an OpenSolaris legacy.
Re:Free user space for non-graphics drivers by fiddlerwoaroof on Saturday June 06, 2020 @11:50PM (#23444620)
This is intentional: the kernel developers don’t want to make proprietary drivers easy to maintain.
Re:Free user space for non-graphics drivers by cycloptic on Sunday June 07, 2020 @12:25AM (#23444756)
If anything it's the other way around. Proprietary developers don't want to make the kernel easy to refactor.
Re:Free user space for non-graphics drivers by NullPrefix on Saturday June 06, 2020 @09:20PM (#23443888)
> If you just mainline your driver, you'll no longer need to worry about this costly maintenance burden

"Pro" move is to just skip the costly maintenance and keep the kernel same, for old times sake.

Re:Free user space for non-graphics drivers by g_p on Sunday June 07, 2020 @09:17AM (#23447112)
Yup, and with that, welcome to the world of semi-proprietary ARM development boards. Leave security patches at the door, and enjoy your version 3.5 kernel for as long as the hardware lasts!

Joking aside, I think a lot of this comes down to the incentives (or lack thereof) in the ecosystem - there is no real penalty for releasing an insecure product, or one that can't be kept up to date. Thus inventivising shipping on an outdated kernel you can't maintain, and never patching it.

If those shipping products had to factor in the externalities of this decision, they would rapidly be mainlining everything to reduce the costs of this. The cost of "mainlining" their code will be trivial compared to the (unmeasured) cost of the disposal of the equipment during a reasonable lifespan due to lacking updates, and the replacement of the equipment.

Re:Free user space for non-graphics drivers by matheusmoreira on Saturday June 06, 2020 @06:06PM (#23442664)
Companies would then have to maintain the drivers themselves. If I remember correctly, the Linux kernel gets over 20 patches per hour. They have to pay developers to maintain the out-of-tree drivers or get left behind.

This is one reason why so many mobile devices run ancient kernels which can't be updated. They stopped maintaining the out-of-tree drivers so people remain permanently stuck on the latest version that still works.

Re:Free user space for non-graphics drivers by stefan_ on Saturday June 06, 2020 @03:07PM (#23441523)
The kernel has no stable interface for device drivers and in fact internal APIs routinely change. If your device driver is in the kernel repository, it will be updated by the people making changes and you get the chance to give feedback.
Re:Free user space for non-graphics drivers by chrisseaton on Saturday June 06, 2020 @03:51PM (#23441773)
But again RedHat and Canonical for example can't ship without updating the changed kernel code to match the driver, so can't they leave it to them to fix?
Re:Free user space for non-graphics drivers by bonzini on Saturday June 06, 2020 @04:15PM (#23441919)
Red Hat doesn't ship any proprietary module. However, they do list a number of symbols and struct definitions as stable, unlike the upstream kernel, and preserve them for the life of a RHEL major release. This is why RHEL stays on an old kernel release and backports new features to the old release, instead of releasing new kernels.
Re:Free user space for non-graphics drivers by wmf on Saturday June 06, 2020 @04:17PM (#23441926)
Red Hat and Canonical aren't suckers; if you dump an infinite maintenance burden on them they will think very hard before accepting it.
Re:Free user space for non-graphics drivers by chrisseaton on Saturday June 06, 2020 @04:27PM (#23441982)
What are they going to do? Ship a distribution without proper graphics support?
Re:Free user space for non-graphics drivers by wmf on Saturday June 06, 2020 @04:35PM (#23442023)
Basically yes.

Note that most of the GPU driver problems are on phones and neither RHEL nor Ubuntu officially support phones at all. And there are also many PC components that RHEL/Ubuntu don't support either, although usually that's just because the hardware is too new.

Re:Free user space for non-graphics drivers by CoolGuySteve on Saturday June 06, 2020 @04:39PM (#23442052)
The wayland login in Ubuntu 18.04 already broke Nvidia's proprietary driver.

So yes.

Re:Free user space for non-graphics drivers by bonzini on Saturday June 06, 2020 @06:31PM (#23442885)
Red Hat ships nouveau. Nvidia is the one that chooses which distros to support (in addition to upstream kernels) and adapts their driver shim if needed.
Re:Free user space for non-graphics drivers by stefan_ on Saturday June 06, 2020 @10:28PM (#23444291)
Your mistake is thinking RedHat and Canonical are some sort of players here. The vast vast majority of Linux deployments are not from any sort of Linux distribution company.
Re:Free user space for non-graphics drivers by bonzini on Sunday June 07, 2020 @02:26AM (#23445235)
Nvidia makes way more money from Quadro and Tesla cards than from the consumer cards (probably in general, and certainly running on Linux). "Company-made" Linux (including CentOS) is absolutely a player there.

Disclaimer, I work for Red Hat.

Re:Free user space for non-graphics drivers by imtringued on Saturday June 06, 2020 @08:53PM (#23443720)
Distributions with modern kernels can't ship with drivers for old kernels.
Re:Free user space for non-graphics drivers by mappu on Saturday June 06, 2020 @09:45PM (#23444035)
> Totally violates the spirit of the GPL.

In the specific, I think the relevant part is whether the kernel component and the userspace component are an Aggregate or not for the purposes of GPL virality. From the gnu.org GPL FAQ:

> Where's the line between two separate programs, and one program with two parts? This is a legal question, which ultimately judges will decide. We believe that a proper criterion depends both on the mechanism of communication (exec, pipes, rpc, function calls within a shared address space, etc.) and the semantics of the communication (what kinds of information are interchanged). If the modules are included in the same executable file, they are definitely combined in one program. If modules are designed to run linked together in a shared address space, that almost surely means combining them into one program. By contrast, pipes, sockets and command-line arguments are communication mechanisms normally used between two separate programs. So when they are used for communication, the modules normally are separate programs. But if the semantics of the communication are intimate enough, exchanging complex internal data structures, that too could be a basis to consider the two parts as combined into a larger program.

I agree we're somewhere murky within the last paragraph. The mechanism is separated well enough - the kernel driver is just IOCTLs over a pipe. The semantics are certainly carrying complex internal data structures, however, those data structures aren't part of any GPL program at all.

So perhaps it's not really anti-GPL - but it is certainly useless in a fully Free environment.

Re:Free user space for non-graphics drivers by monocasa on Saturday June 06, 2020 @03:31PM (#23441656)
> I was NACK to this WSL driver, too, totally flies in the face of the rest of the Linux graphics stack. Companies should get in the habit of talking to the kernel early, and not just dumping a patchset over the fence and hoping we like it.

I guess I'm not sure how much earlier they can bring in the main kernel than a graphics driver that doesn't even display graphics yet. Like I've seen the amount of bikeshedding that happens when talking about hypotheticals with no code to reference.

What should they have done differently in your mind?

Re:Free user space for non-graphics drivers by ddevault on Saturday June 06, 2020 @03:55PM (#23441798)
The problem is that they built an entirely independent graphics stack. It does not co-exist at all with any of the graphics subsystem which has been built up for many drivers and use-cases over the past 5-10 years.

What they should have done is approached the community with their idea and sought input on how to design their approach. We would have discussed solutions which integrated better into the existing stack. But, then they would be robbed of the chance to do a big announcement and get ahead of the press cycle with their bad driver.

Re:Free user space for non-graphics drivers by monocasa on Saturday June 06, 2020 @04:02PM (#23441853)
I mean, the were actively asking how to better integrate it before it had gotten to the point of displaying graphics, with some mainline kernel devs questioning if it should be integrated with the graphics stack at all, and be pushed back into the hyperv side of things.

It's very clearly an RFC with an eye for "how can we better collaborate and who should we collaborate with?"

I think they need to better document and support a more opensource stack on the user side of things (maybe a vulkan or mesa targeting the WDDM ioctl interface rather than on the dx12 UAPI), but those are surmountable issues, and makes it look like the amdgpu side of the house.

Re:Free user space for non-graphics drivers by bonzini on Saturday June 06, 2020 @04:09PM (#23441890)
It had gotten to the point where you can do machine learning and other CUDA applications, and that brings a lot more money than graphics.

WSL is definitely pulling an Embrace Extend Extinguish. I am not saying the new Microsoft is the same as Ballmer's, but still.

Re:Free user space for non-graphics drivers by monocasa on Saturday June 06, 2020 @04:56PM (#23442158)
Full graphics is on the roadmap, basic compute was just an MVP.

Linus has said that he doesn't want discussions without code for the reasons I've stated.

All the complaints I've heard about how WSL didn't do the right thing make it sound like there is no right way, despite passthrough graphics drivers for otherwise totally proprietary stacks on hypervisor stacks from companies with blatant GPL violations ending up mainlined with praise (cough VMWare). And despite the fact that the only way that's been proven to virtualize graphics cards without 2stage MMUs is to replicate the host's ioctl layer into the guest. There's a reason why Virgl isn't used by anyone serious about perf, it's the fundamentally wrong architecture.

Re:Free user space for non-graphics drivers by bonzini on Saturday June 06, 2020 @06:22PM (#23442795)
CUDA may be an MVP, but it's a damn useful and lucrative MVP.

Also, VFIO mdev can be used to virtualize graphics cards to virtual machines, both nVidia and Intel. Note this is not device assignment (that's "plain" VFIO); it's the host driver exposing a partly pass-through, partly emulated device that virtualizes the host device. mdev's design was initially a Red Hat-nVidia collaboration with input from Intel (I had a small role from the Red Hat side, mostly coming up with the name :-)) and implemented by nVidia, and is used in production with both Windows and Linux guests.

Re:Free user space for non-graphics drivers by monocasa on Saturday June 06, 2020 @06:56PM (#23443087)
It's not full VFIO, but it still takes hardware support. It's not really a comparable solution.
Re:Free user space for non-graphics drivers by bonzini on Sunday June 07, 2020 @02:18AM (#23445199)
Not necessarily. Nvidia doesn't have hardware support, rather the guest driver communicates changes to the page tables to the host driver in such a way that the host can establish shadow page tables that merge the guest and host translations.
Re:Free user space for non-graphics drivers by monocasa on Sunday June 07, 2020 @02:45AM (#23445314)
That's not a great example though, because mdev on Nvidia is proprietary kernel module->proprietary guest kernel module->proprietary user driver.

And in that case too, the ioctl layer is almost entirely maintained across the boundaries like the scheme I'm saying. You need to do that or you almost certainly get a weird impedance mismatch between guest and host that destroys perf.

Re:Free user space for non-graphics drivers by bonzini on Sunday June 07, 2020 @07:47AM (#23446699)
Even if nVidia's driver has a more lightweight abstraction compared to Intel's, and puts more stuff in userspace, that is not particularly relevant in my opinion: mdev only sits between host and guest driver and by design the host driver only emulates the bare minimum and multiplexes hardware resources instead. What happens in the guest between the driver and userspace does not matter to mdev.
Re:Free user space for non-graphics drivers by monocasa on Monday June 08, 2020 @04:16PM (#23460293)
It is relevant, because NVidia's binary driver looks like WDDM on every platform.

And Intel needs something like this either way because their hardware arch is different, and their GPU is heavily integrated with the main IOMMU.

Re:Free user space for non-graphics drivers by Kednicma on Saturday June 06, 2020 @06:10PM (#23442696)
Wait, since when are you in charge of this part of the kernel?