Re: DRM/KMS: report

2023-10-15 Thread tlaronde
On Sun, Oct 15, 2023 at 10:13:18AM +, Taylor R Campbell wrote:
> 
> > DRM or now DRM2 (aka DRM/KMS) are inherently and heavily linked to
> > X11 and to Linux.  Due to the size of the thing, NetBSD is deriving
> > a version from the one FreeBSD tries to derive.
> 
> Not sure what you mean about FreeBSD, but our drm2 code base was
> developed largely independent of whatever is in FreeBSD, and as far as
> I know was started well before FreeBSD adopted the same approach of
> writing Linux API shims.

Then this is a difference with the first version, according to drm(4)
that is referring exclusively to DRM (first version) and is partial
(not mentionning DRM2 / DRMKMS) or obsolete.

For the record, I started first by trying to review _all_ the commits
starting from 2007-03-20 (the first import of the first---for NetBSD---
version)... But I realised, after some time and considering how fast I
was going through, it was hopeless... So I have a view, but far from
complete or even accurate.

> 
> > To make things even worse, the abuse of acronyms is blurring things that
> > didn't need to be made even less clear. Not to mention the fact that DRM
> > is also used for Digital Rights Management---that has strictly nothing
> > to do with the thing---, DRI (a part of the X11 stuff) is also used
> > instead of DRM for the X11 part, and DRM2 is also referred too as 
> > DRM/KMS.
> 
> sys/external/bsd/drm is the previous generation of the drm code base,
> from before it did any kernel mode-setting (KMS).  Display
> configuration was done by peeking and poking device registers from
> userland through /dev/mem and /dev/pci -- the legacy user mode-setting
> approach (UMS).  The /dev/dri/ nodes were used by userland only to map
> some registers and manage graphics buffers bound into the GPU address
> space.
> 
> sys/external/bsd/drm2 is the current generation of the drm code base,
> including both UMS and KMS.  With KMS, display configuration is done
> by a set of structured ioctls on /dev/dri/ nodes, with all device
> register access done by the kernel.  (The /dev/dri/ nodes are also
> used to manage graphics buffers.)
> 
> When I more or less started over from scratch, I called it drm2 just
> so it would have a distinct place in the source tree while people
> still relied on the previous generation of the code.
> 
> By now I think we should just delete sys/external/bsd/drm; it has been
> unmaintained for so long it is unlikely to work.  If there's interest
> in the legacy UMS drivers, they should all still be in the drm2 tree
> and can be adapted like I did with viadrmums.  But I have no hardware
> for most of them.

I will put all the documentation bits together some place for reference.

Thanks for the clarifications!

> 
> > The drivers using the new API have sometimes "kms" in the name (for
> > i915, I guess to make a difference with the previous "legacy"
> > i915drm), but generally not, or if this is the case, this is not the
> > device attaching early:
> > 
> > # DRMKMS drivers 
> > i915drmkms* at pci? dev ? function ?
> > intelfb*at intelfbbus?
> 
> `i915drmkms' happened because `i915' is not allowed (ends with a
> digit) and `i915drm' was already taken.
> 
> > To illustrate the namespace problem, take "radeon":
> > 
> > radeondrm* is the legacy DRM driver and:
> > 
> > radeon* is the DRM2 and this is its child, the fb, that has the "kms"
> > substring:
> > 
> > radeondrmkmsfb* at radeonfbbus?
> 
> `radeondrmkms' happened because `radeonfb' was already taken.
> 
> I'm not attached to these names, but they've been around for long
> enough they are probably named in existing boot.cfg files, so changing
> them might is likely to break people's bootloaders.
> 
> Not hard to imagine creating a new way to tag drivers that can be
> referenced by userconf so that renaming isn't necessary.
> 

If the drivers were matching a rule, I have already implemented in
sys/kern/subr_userconf.c (on my git fork on
https://github.com/tlaronde/src) the use of "patterns" to change,
disable, enable, find and list matching driver names.

I could add specifiers to the "patterns" to match parent device or child
device.

I could extend too cfdata in order to allow to take into account a
devclass and to match against it.

Modules are setting a class and it would be the simpler to be able to
use such a tag in userconf to disable the devices without having to
resort to ad hoc lists---and even worse, to expand a magic name in MD
bootinfo stuff, with the obligation to update lists and the risk to
have to augment the size of bootinfo data.

I wanted and still want to implement something general and not ad hoc
for drm in userconf.

If somebody knows already enough about autoconf and userconf to point me
to the more elegant and consistent way, I will gladly take advices!

> > For the ARM part, the API is implemented but, from what I gather,
> > totally independantly from the external sources in order to use the
> > framebuffer.
> 
> I 

re: DRM/KMS: report

2023-10-15 Thread matthew green
> By now I think we should just delete sys/external/bsd/drm; it has been
> unmaintained for so long it is unlikely to work.  If there's interest
> in the legacy UMS drivers, they should all still be in the drm2 tree
> and can be adapted like I did with viadrmums.  But I have no hardware
> for most of them.

it's been a long time since i checked, but it was the only working
DRM for most older R100/R200 chipsets.  see PR#49744.  this is really
the only reason it's remained in the tree.

i did check drm2 post-recent update on this old system, and it was
still not working properly.

... but i'll not argue against removing.


.mrg.


Re: DRM/KMS: report

2023-10-15 Thread Taylor R Campbell
> Date: Sat, 14 Oct 2023 19:57:59 +0200
> From: tlaro...@kergis.com
> 
> [I'm sending this to the tech-kern since the previous message on
> tech-userlevel is only: the list seems dead?]

Not dead, just quiet so far this month.

> DRM or now DRM2 (aka DRM/KMS) are inherently and heavily linked to
> X11 and to Linux.  Due to the size of the thing, NetBSD is deriving
> a version from the one FreeBSD tries to derive.

Not sure what you mean about FreeBSD, but our drm2 code base was
developed largely independent of whatever is in FreeBSD, and as far as
I know was started well before FreeBSD adopted the same approach of
writing Linux API shims.

> To make things even worse, the abuse of acronyms is blurring things that
> didn't need to be made even less clear. Not to mention the fact that DRM
> is also used for Digital Rights Management---that has strictly nothing
> to do with the thing---, DRI (a part of the X11 stuff) is also used
> instead of DRM for the X11 part, and DRM2 is also referred too as 
> DRM/KMS.

sys/external/bsd/drm is the previous generation of the drm code base,
from before it did any kernel mode-setting (KMS).  Display
configuration was done by peeking and poking device registers from
userland through /dev/mem and /dev/pci -- the legacy user mode-setting
approach (UMS).  The /dev/dri/ nodes were used by userland only to map
some registers and manage graphics buffers bound into the GPU address
space.

sys/external/bsd/drm2 is the current generation of the drm code base,
including both UMS and KMS.  With KMS, display configuration is done
by a set of structured ioctls on /dev/dri/ nodes, with all device
register access done by the kernel.  (The /dev/dri/ nodes are also
used to manage graphics buffers.)

When I more or less started over from scratch, I called it drm2 just
so it would have a distinct place in the source tree while people
still relied on the previous generation of the code.

By now I think we should just delete sys/external/bsd/drm; it has been
unmaintained for so long it is unlikely to work.  If there's interest
in the legacy UMS drivers, they should all still be in the drm2 tree
and can be adapted like I did with viadrmums.  But I have no hardware
for most of them.

> The drivers using the new API have sometimes "kms" in the name (for
> i915, I guess to make a difference with the previous "legacy"
> i915drm), but generally not, or if this is the case, this is not the
> device attaching early:
> 
> # DRMKMS drivers 
> i915drmkms* at pci? dev ? function ?
> intelfb*at intelfbbus?

`i915drmkms' happened because `i915' is not allowed (ends with a
digit) and `i915drm' was already taken.

> To illustrate the namespace problem, take "radeon":
> 
> radeondrm* is the legacy DRM driver and:
> 
> radeon* is the DRM2 and this is its child, the fb, that has the "kms"
> substring:
> 
> radeondrmkmsfb* at radeonfbbus?

`radeondrmkms' happened because `radeonfb' was already taken.

I'm not attached to these names, but they've been around for long
enough they are probably named in existing boot.cfg files, so changing
them might is likely to break people's bootloaders.

Not hard to imagine creating a new way to tag drivers that can be
referenced by userconf so that renaming isn't necessary.

> For the ARM part, the API is implemented but, from what I gather,
> totally independantly from the external sources in order to use the
> framebuffer.

I don't know how you conclude this, but access to the display
configuration is exposed to userland through the drm ioctls on
/dev/dri/ nodes.

The external sources implement all those ioctls and the
device-independent logic to process display configuration options and
apply them to the hardware with the device-dependent callbacks in,
e.g., sunxi_drm.c, sunxi_lcdc.c, 

We don't have anything remotely resembling the display configuration
API of DRM KMS.  You could redo that API from scratch, but it's the
easiest part of the upstream drm code base to maintain, so you'd end
up with a huge amount of wasted effort and none of the really
important drivers (intel, radeon, amdgpu, nouveau).

> There are no syscalls added related to the DRM.

syscalls, no.  Ioctls, yes.