[Openpvrsgx-devgroup] [Letux-kernel] Stable /sys/class/drm/card%d

H. Nikolaus Schaller hns at goldelico.com
Sat Aug 23 17:41:57 CEST 2025


Hi Andreas,

> Am 23.08.2025 um 14:52 schrieb Andreas Kemnade <andreas at kemnade.info>:
> 
> 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.

That is interesting. Thanks for the hint.

> 
>> 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...

Agreed, but on such systems the pvrsgx driver isn't loaded at all - so there is no conflict if we
patch pvr_probe().

> 
>> 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.

Agreed and I would prefer if there would be a vanilla mainline solution, but
if modprobe has no "install" command or it is not working, we must find a different
one.

> 
>> 
>> 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.

No, it can't. It does not change behaviour of systems where no aliases are defined
in the DTB if it simply ignores the additional mapping option.

And this solution I would not even consider it a hack but a new (optional)
feature. Exactly the same as for mmc or serial or other subsystems.

It could be as simple as adding of_alias_get_id() to drm_minor_alloc().
Provided that there is access to the device tree nodes.

BTW: there are DRM devices that use of_alias_get_id(). E.g.
exynos_drm_check_fimc_device(), mtk_drm_probe(().

Even omap_display_id() supports an display alias...

> 
>> 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.

Yes, I always forget... But what should one do on smaller embedded systems where
Wayland is overkill or not available?

There have been ToDo-documents how to install pvrsgx with X11 side by side at least
for the 1.14 releases (AFAIR).

And AFAIK, there is no wayland compatible user-space for pvrsgx.

Unless TI or Imagination can finally be convinced that it is now (20 years after
launch of the 520 - likely all patents are now expired) time to make the full
SGX DDK open source.

I remember there was a leak approximately 10 years ago but there is no trace left
online.

> 
>> 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.

I checked that and it appears that the card is only instantiated if there are these modules:
- omapdrm
- display_connector
- panel driver (or similar)

So with omapdrm alone there is no card0 for a display system...

> 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?

BitCoin mining or training large language models :)
But with the limitations of the pvrsgx user-space this is not anything anyone 
would do. IMHO.

> 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

Hm. Do you have a reference which patch this could be?

> 
> 7. turn off gpu driver
>   - perhaps done for the vivante stuff, ok for Ebook readers but not
>     for anything else.

This seems not to be the best solution if you want display, X11 and GPU :)

BR and thanks,
Nikolaus



More information about the openpvrsgx-devgroup mailing list