[Openpvrsgx-devgroup] Stable /sys/class/drm/card%d
H. Nikolaus Schaller
hns at goldelico.com
Sat Aug 23 10:54:02 CEST 2025
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.
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.
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.
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.
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...
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.
5. modify xorg.conf dynamically
6. other ideas?
What are your opinions and suggestions?
BR,
Nikolaus
More information about the openpvrsgx-devgroup
mailing list