Package: linux-image-6.9.7+debian+tj
Followup-For: Bug #1075713
X-Debbugs-Cc: tj.iam...@proton.me

This is best fixed in xorg-server. I've opened an upstream issue [0] and
sent the patch to xorg-devel@.

In the meantime here's a patch tested with kernel v6.8.12 and v6.9.7
using the device subsystem path as recommended by Thomas Zimmerman.
>From c7458db8a1701e9beb76831afe5f15d3351e1a47 Mon Sep 17 00:00:00 2001
From: Tj <tj.iam...@proton.me>
Date: Mon, 15 Jul 2024 10:45:17 +0100
Subject: [PATCH] fbdevhw: fix sysfs path PCI device detection

Linux kernel v6.9 has changed the symlink to point to the parent device.
This breaks fbdev_open() detection logic. Change it to use the subsystem
symlink instead which will remain stable.

Kernel v6.8:

[    14.067] (II) fbdev_open() sysfs_path=/sys/class/graphics/fb0
[    14.067] (II) fbdev_open() 
buf=../../devices/platform/vesa-framebuffer.0/graphics/fb0

Kernel v6.9:

[    15.609] (II) fbdev_open() sysfs_path=/sys/class/graphics/fb0
[    15.609] (II) fbdev_open() 
buf=../../devices/pci0000:00/0000:00:01.0/vesa-framebuffer.0/graphics/fb0

Originally found in automated Debian ISO QA testing [0] and confirmed in
Linux [1].

Tested on kernels v6.9.7 and v6.8.12

[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075713
[1] 
https://lore.kernel.org/lkml/lLyvPFC_APGHNfyGNHRpQy5izBikkaTPOpHooZIT3fFAoJPquSI31ZMueA99XTdr8ysir3X7O7IMdc6za-0m79vr_claeparHhoRouVgHOI=@proton.me/

Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1714
Signed-off-by: Tj <tj.iam...@proton.me>
---
 hw/xfree86/fbdevhw/fbdevhw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 76bc4809f..019af305b 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -378,9 +378,9 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
             node++;
         }
 
-        if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 ||
+        if (asprintf(&sysfs_path, "/sys/class/graphics/%s/device/subsystem", 
node) < 0 ||
             readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 ||
-            strstr(buf, "devices/pci")) {
+            strstr(buf, "bus/pci")) {
             free(sysfs_path);
             close(fd);
             return -1;
-- 
2.39.2

Reply via email to