Xorg cannot read ID_PATH in the config_udev_odev_setup_attribs function
I have carefully read the 993 bug(#993 (closed))
but it is different, ID_PATH can be read in the config_udev_init function but it has not set at config_udev_odev_probe->config_udev_odev_setup_attribs. I think we need to do some synchronous operations to ensure that ID_PATH prop can be read correctly if it exists
Here is the scene:
(1)I use the radeon HD 8570 card, lspci -v | grep VGA
06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Oland [Radeon HD 8570 / R7 240/340 OEM] (rev 87) (prog-if 00 [VGA controller])
Subsystem: Bitland(ShenZhen) Information Technology Co., Ltd. Oland [Radeon HD 8570 / R7 240/340 OEM]
Flags: bus master, fast devsel, latency 0, IRQ 70, NUMA node 0
Memory at e0030000000 (64-bit, prefetchable) [size=256M]
Memory at e0041100000 (64-bit, non-prefetchable) [size=256K]
I/O ports at 4000 [size=256]
Expansion ROM at e0041140000 [disabled] [size=128K]
Capabilities: [48] Vendor Specific Information: Len=08 <?>
Capabilities: [50] Power Management version 3
Capabilities: [58] Express Legacy Endpoint, MSI 00
Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
Capabilities: [150] Advanced Error Reporting
Capabilities: [200] #15
Capabilities: [270] #19
Kernel driver in use: radeon
Kernel modules: radeon, amdgpu
(2) initrd does not contain the radeon ko and radeon firmware. So the firmware needs to be read from the hard disk, which delays the loading of the driver and delays the creation of the graphics card device ID_PATH
root@nvme-pc:/boot# lsinitrd initrd.img-4.19.0-19-loongson-3 | grep radeon
root@nvme-pc:/boot#
(3) I add some print info in the Xorg config/udev.c and use print_drm_properties to read all props of the card0 ,code like this:
72 static void print_drm_properties(struct udev_device *device) {
73 struct udev_list_entry *properties_list, *entry;
74
75 properties_list = udev_device_get_properties_list_entry(device);
76
77 udev_list_entry_foreach(entry, properties_list) {
78 const char *name = udev_list_entry_get_name(entry);
79 const char *value = udev_list_entry_get_value(entry);
80
81 printf("%s=%s\n", name, value);
82 LogMessage(X_INFO, "=====%s=%s\n", name, value);
83 }
84 }
538 static void
539 config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path, const char *syspath,
540 int major, int minor,
541 config_odev_probe_proc_ptr probe_callback)
542 {
543 struct OdevAttributes *attribs = config_odev_allocate_attributes();
544 const char *value, *str;
545
546 attribs->path = XNFstrdup(path);
547 attribs->syspath = XNFstrdup(syspath);
548 attribs->major = major;
549 attribs->minor = minor;
550
551 LogMessage(X_INFO, "=====path %s, syspath %s, major %d, minor %d\n", attribs->path, attribs->syspath, major, minor);
552
553 //sleep(2);
554 print_drm_properties(udev_device);
555
556 value = udev_device_get_property_value(udev_device, "ID_PATH");
557 if (value && (str = strrstr(value, "pci-"))) {
558 attribs->busid = XNFstrdup(str);
559 attribs->busid[3] = ':';
560 }
561
562 LogMessage(X_INFO, "======1======value %s, attribs->busid %s\n", value, attribs->busid);
563
564 if (!value)
565 attribs->busid = config_udev_get_fallback_bus_id(udev_device);
566
567 LogMessage(X_INFO, "======2======value %s, attribs->busid %s\n", value, attribs->busid);
568 /* ownership of attribs is passed to probe layer */
569 probe_callback(attribs);
570 }
log like this:
[ 9.545] (II) systemd-logind: logind integration requires -keeptty and -keeptty was not provided, disabling logind integration
[ 9.546] (II) =====config_udev_odev_probe:636==path /dev/dri/card0, sysname card0, subsys drm====
[ 9.546] (II) ==========config_udev_odev_probe:646======
[ 9.546] (II) =====path /dev/dri/card0, syspath /sys/devices/pci0000:00/0000:00:0f.0/0000:06:00.0/drm/card0, major 226, minor 0
[ 9.546] (II) =====DEVNAME=/dev/dri/card0
[ 9.546] (II) =====DEVPATH=/devices/pci0000:00/0000:00:0f.0/0000:06:00.0/drm/card0
[ 9.546] (II) =====DEVTYPE=drm_minor
[ 9.546] (II) =====MAJOR=226
[ 9.546] (II) =====MINOR=0
[ 9.546] (II) =====SUBSYSTEM=drm
[ 9.546] (II) ======1======value (null), attribs->busid (null)
[ 9.546] (II) ======2======value (null), attribs->busid pci:0000:06:00.0
[ 10.966] (II) This device may have been added with another device file.
[ 10.966] (II) ==========config_udev_init:483===syspath /sys/devices/pci0000:00/0000:00:0f.0/0000:06:00.0/drm/card0===
[ 10.966] (II) =====DEVLINKS=/dev/dri/by-path/pci-0000:06:00.0-card
[ 10.966] (II) =====DEVNAME=/dev/dri/card0
[ 10.966] (II) =====DEVPATH=/devices/pci0000:00/0000:00:0f.0/0000:06:00.0/drm/card0
[ 10.966] (II) =====DEVTYPE=drm_minor
[ 10.966] (II) =====ID_FOR_SEAT=drm-pci-0000_06_00_0
[ 10.966] (II) =====ID_PATH=pci-0000:06:00.0
[ 10.966] (II) =====ID_PATH_TAG=pci-0000_06_00_0
[ 10.966] (II) =====MAJOR=226
[ 10.966] (II) =====MINOR=0
[ 10.966] (II) =====SUBSYSTEM=drm
[ 10.966] (II) =====TAGS=:seat:master-of-seat:uaccess:
[ 10.966] (II) =====USEC_INITIALIZED=10944908
[ 10.966] (II) =====device_added:124==path /dev/dri/card0, syspath /sys/devices/pci0000:00/0000:00:0f.0/0000:06:00.0/drm/card0, subsys drm====
ID_PATH has not set at the udev_device_get_property_value(udev_device, "ID_PATH") function, but if I add a delay like sleep(2), ID_PATH has been set.