[Openpvrsgx-devgroup] Stable /sys/class/drm/card%d
Andreas Kemnade
andreas at kemnade.info
Sat Aug 23 14:52:36 CEST 2025
Am Sat, 23 Aug 2025 10:54:02 +0200
schrieb "H. Nikolaus Schaller" <hns at goldelico.com>:
> There is a long known issue in the interaction between Xorg and pvrsrvkm.
>
> Depending on race conditions, the kernel loads the drm display drivers and
> the pvrsgx driver in random order. The result is that sometimes card0 and card1
> are swapped.
>
> for example GTA04 we can see
>
> root at letux:~# ls -l /sys/class/drm/
> total 0
> lrwxrwxrwx 1 root root 0 Aug 23 08:15 card0 -> ../../devices/platform/68000000.ocp/5000fe00.target-module/50000000.gpu/drm/card0
> lrwxrwxrwx 1 root root 0 Aug 23 08:15 card1 -> ../../devices/platform/omapdrm.0/drm/card1
> lrwxrwxrwx 1 root root 0 Aug 23 08:15 card1-Composite-1 -> ../../devices/platform/omapdrm.0/drm/card1/card1-Composite-1
> lrwxrwxrwx 1 root root 0 Aug 23 08:15 card1-DPI-1 -> ../../devices/platform/omapdrm.0/drm/card1/card1-DPI-1
> lrwxrwxrwx 1 root root 0 Aug 23 08:16 renderD128 -> ../../devices/platform/68000000.ocp/5000fe00.target-module/50000000.gpu/drm/renderD128
> lrwxrwxrwx 1 root root 0 Aug 23 08:16 renderD129 -> ../../devices/platform/omapdrm.0/drm/renderD129
> -r--r--r-- 1 root root 4096 Aug 23 08:15 version
> root at letux:~#
>
> while on OpenPandora (or a different boot run) we can get
>
> root at letux:~# ls -l /sys/class/drm
> total 0
> lrwxrwxrwx 1 root root 0 Aug 23 07:19 card0 -> ../../devices/platform/omapdrm.0/drm/card0
> lrwxrwxrwx 1 root root 0 Aug 23 07:19 card0-DPI-1 -> ../../devices/platform/omapdrm.0/drm/card0/card0-DPI-1
> lrwxrwxrwx 1 root root 0 Aug 23 07:19 card0-SVIDEO-1 -> ../../devices/platform/omapdrm.0/drm/card0/card0-SVIDEO-1
> lrwxrwxrwx 1 root root 0 Aug 23 08:15 card1 -> ../../devices/platform/68000000.ocp/50000014.target-module/50000000.gpu/drm/card1
> lrwxrwxrwx 1 root root 0 Aug 23 07:19 renderD128 -> ../../devices/platform/omapdrm.0/drm/renderD128
> lrwxrwxrwx 1 root root 0 Aug 23 08:15 renderD129 -> ../../devices/platform/68000000.ocp/50000014.target-module/50000000.gpu/drm/renderD129
> -r--r--r-- 1 root root 4096 Aug 23 07:18 version
> root at letux:~#
>
> Depending on how new Xorg is (e.g. Debian 11), it can cope with this random
> order and detect which card the GPU really is. But on older Xorgs (e.g. Debian 9)
> this mangles up Xorg and the display stays black, even if the GPU is not used
> (but driver loaded).
>
> Another issue is that if we define some xorg.conf the card number my need to be
> hard coded to get GPU support with X11.
>
Hmm, I found this snippet, so adding stuff depending on driver /
identifier
Section "OutputClass" Identifier "AMDgpu"
MatchDriver "amdgpu"
Driver "amdgpu"
Option "HotplugDriver" "amdgpu"
EndSection
Maybe that is something to play around with. I only knew InputClass.
> Therefore, stable card numbers would be helpful to avoid surprises.
>
> Here are some ideas how to achieve this (without enforcing the most modern Xorg):
>
> 1. add a request_module() to pvr_probe()
>
> This would request installing the display system first and become card0.
> Then, the GPU is initialized and becomes card1.
>
> Basically this adds just 9 lines of code but an issue is that it is not
> clear which module(s) must be requested to make the display card0. Do
> we have to request omap_drm or the panel driver? And on jz4780 yet another
> one.
>
And we also have vivante vs mxc_epdc...
> But this would just affect the pvrsrvkm driver that needs this feature.
> So who orders something has to pay for it...
>
> 2. add some install rule to /etc/modprobe.d
>
> install pvrsrvkm some-command...
>
> This would would move what would be in the kernel driver in case 1. avove
> into a modprobe rule.
>
> I had experimented with this but could not get it working.
>
> And: there is a strong deprecation warning in the manual:
>
> https://man7.org/linux/man-pages/man5/modprobe.d.5.html#COMPATIBILITY
>
> Another issue is that if this rule is not installed (it is not part
> of the uImage or .dtb) the random order will be back.
but you have a kernel which behaves more like vanilla mainline,
so less invasive.
>
> 3. add alises into the device tree and hack drm_minor_alloc()
>
> This would be the same scheme we have e.g. for mmc cards or serial ports
> which need stable names.
>
> The hack would scan the DTB aliases and map the minor number. And if
> there are no aliases defined it would fall back to the "find next free
> slot" rule.
>
well, it changes kernel main code and not just drivers, so it can
influence systems which do not need the hack.
> This would probably be the cleanest solution but it is unlikely
> to get it upstream ever. People will just say: I have no problems,
> update your Xorg...
>
No, they will not tell you to update your Xorg, they will tell use:
use wayland.
> 4. check for /sys/class/drm/card0 in pvr_probe()
>
> This idea would be to check if there is a /sys/class/drm/card0 and
> return -EPROBE_DEFER until it exists.
>
> The assumption is that some display driver will then probe first and if
> there is a card0, the pvrsrvkm would become card1 by the standard
> mechanism of drm_minor_alloc().
>
> It is unclear what happens if there is some setup with no display
> and no Xorg but GPU. Then the gpu could become card0 without issues
> but never is.
>
You can have no display, but probably still the omapdrm.
Ok, again modifing the kernel but in a less invasive form and local to
a driv
But what kind of software would be happy with just the GPU?
Number crunching? Needs probably more universal userspace than provided
by closed-source ti stuff. I guess that always implies some fiddling.
But we also have Vivante, there the chances for GPU without graphics
are higher. So doing that there can be problematic.
> 5. modify xorg.conf dynamically
>
or play around with OutputClass stuff. But that would also imply some
disabling of auto-adding devices and therefore mess with external
keyboards, etc.
> 6. other ideas?
6. Ship a patched Xorg
7. turn off gpu driver
- perhaps done for the vivante stuff, ok for Ebook readers but not
for anything else.
Regards,
Andreas
More information about the openpvrsgx-devgroup
mailing list