clinux-kernelgputtyxorg

hotplug vga(drm radeon) changes status from disconnected to connected, but is still disabled seen from sys


Here is my graphic card:

03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Caicos [Radeon HD 6450/7450/8450 / R5 230 OEM]
        Subsystem: XFX Pine Group Inc. Caicos [Radeon HD 6450/7450/8450 / R5 230 OEM]
        Kernel driver in use: radeon

After booting without VGA plugged in, I hotplug the VGA monitor. However, the screen remains black and lightdm/xdm does not appear. I did notice though

root@lccy7:~# cat /sys/class/drm/card0-VGA-1/status 
connected
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/enabled 
disabled

xdm runs happily in the background:

root@lccy7:~# systemctl status xdm
* xdm.service - X-Window Display Manager
   Loaded: loaded (/lib/systemd/system/xdm.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-05-12 14:37:03 CST; 1h 3min ago
 Main PID: 2589 (xdm)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/xdm.service
           |-2589 /usr/bin/xdm -nodaemon
           `-2604 /usr/lib/xorg/Xorg :0 -auth /var/lib/xdm/authdir/authfiles/A:0-InChxF

May 12 14:37:01 lccy7 systemd[1]: Starting X-Window Display Manager...
May 12 14:37:03 lccy7 systemd[1]: Started X-Window Display Manager.
May 12 14:37:04 lccy7 xdm[2635]: pam_unix(greeter:session): session opened for user root by (uid=0)

Once I switch to other tty(e.g., Ctrl Alt F1, it is both connected and enabled:

root@lccy7:~# cat /sys/class/drm/card0-VGA-1/status 
connected
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/enabled 
enabled

I tried to enable verbose mode for DRM: drm.debug=0x1e log_buf_len=4M, and below is kernel log(journalctl -b 0 -k | grep -E "enabled|\bconnected|hotplug" | grep -v i2c):

# before plugging in Vga:
root@lccy7:~# journalctl -b 0 -k | grep -E "enabled|\bconnected|hotplug" | grep -v i2c
May 12 16:34:31 lccy7 kernel: console [tty0] enabled
May 12 16:34:31 lccy7 kernel: raid6: .... xor() 1078 MB/s, rmw enabled
May 12 16:34:31 lccy7 kernel: [drm] radeon kernel modesetting enabled.
May 12 16:34:31 lccy7 kernel: [drm] PCIE GART of 1024M enabled (table at 0x0000000000274000).
May 12 16:34:31 lccy7 kernel: radeon 0000:03:00.0: WB enabled
May 12 16:34:31 lccy7 kernel: [drm:drm_sysfs_hotplug_event] generating hotplug event
May 12 16:34:31 lccy7 kernel: [drm:drm_sysfs_hotplug_event] generating hotplug event
May 12 16:34:31 lccy7 kernel: [drm:drm_sysfs_hotplug_event] generating hotplug event
May 12 16:34:31 lccy7 kernel: radeon 0000:03:00.0: No connectors reported connected with modes
May 12 16:34:31 lccy7 kernel: [drm:drm_enable_connectors] connector 37 enabled? no
May 12 16:34:31 lccy7 kernel: [drm:drm_enable_connectors] connector 39 enabled? no
May 12 16:34:31 lccy7 kernel: [drm:drm_enable_connectors] connector 41 enabled? no
May 12 16:34:31 lccy7 kernel: [drm] amdgpu kernel modesetting enabled.
May 12 16:34:31 lccy7 kernel: sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
May 12 16:34:31 lccy7 kernel: sd 2:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
May 12 16:34:36 lccy7 kernel: [drm:drm_sysfs_hotplug_event] generating hotplug event
May 12 16:34:36 lccy7 kernel: [drm:drm_fb_helper_hotplug_event] 
May 12 16:34:36 lccy7 kernel: [drm:drm_enable_connectors] connector 37 enabled? no
May 12 16:34:36 lccy7 kernel: [drm:drm_enable_connectors] connector 39 enabled? no
May 12 16:34:36 lccy7 kernel: [drm:drm_enable_connectors] connector 41 enabled? no



# After plugging to Vga: 

May 12 16:41:35 lccy7 kernel: [drm:radeon_atombios_connected_scratch_regs] CRT1 connected
May 12 16:41:35 lccy7 kernel: [drm:output_poll_execute] [CONNECTOR:41:VGA-1] status updated from disconnected to connected
May 12 16:41:35 lccy7 kernel: [drm:drm_sysfs_hotplug_event] generating hotplug event
May 12 16:41:35 lccy7 kernel: [drm:radeon_atombios_connected_scratch_regs] CRT1 connected


# After switching to tty1: 

May 12 16:45:39 lccy7 kernel: [drm:drm_fb_helper_hotplug_event] 
May 12 16:45:39 lccy7 kernel: [drm:radeon_atombios_connected_scratch_regs] CRT1 connected
May 12 16:45:39 lccy7 kernel: [drm:drm_enable_connectors] connector 37 enabled? no
May 12 16:45:39 lccy7 kernel: [drm:drm_enable_connectors] connector 39 enabled? no
May 12 16:45:39 lccy7 kernel: [drm:drm_enable_connectors] connector 41 enabled? yes

Here is the full drm|radeon log(with many ioctl logs): https://paste.ubuntu.com/p/rWDZ7GCdN6/

From the complete log, I identified the initial ioctl following the switch to tty as:

May 12 16:44:41 lccy7 kernel: [drm:drm_ioctl] pid=4206, dev=0xe200, auth=1, DRM_IOCTL_MODE_SETCRTC

I have double confirmed if I boot with plugged Vga, lightdm/xdm can display without any issues.


Solution

  • after debugging xorg:

    #+BEGIN_SRC diff
    From c4efeab9ae215b0e46c81cdaba5aee04d6635e71 Mon Sep 17 00:00:00 2001
    From: chenli <chenli@uniontech.com>
    Date: Wed, 2 Sep 2020 07:28:56 -0400
    Subject: [PATCH] dump pid per request
    
    ---
     randr/randr.c | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/randr/randr.c b/randr/randr.c
    index 6e3f14b..6602274 100644
    --- a/randr/randr.c
    +++ b/randr/randr.c
    @@ -670,6 +670,7 @@ static int
     ProcRRDispatch(ClientPtr client)
     {
         REQUEST(xReq);
    +    LogMessage(X_ERROR, "ProcRRDispatch: stuff->data %d, !ProcRandrVector[stuff->data] %d, pid = %d\n", stuff->data, !ProcRandrVector[stuff->data], client->clientIds->pid);
         if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
             return BadRequest;
         return (*ProcRandrVector[stuff->data]) (client);
    

    I found no one send ProcRRSetScreenSize and ProcRRSetCrtcConfig to Xorg. So it should be a desktop environment issue.

    My de is dde v15, but both dde v20 and mate work fine, below is deepin v20's process tree:

    2555 ?        Ssl    0:00 /usr/sbin/lightdm
     2572 tty1     tsl+   0:01  \_ /usr/lib/xorg/Xorg -background none :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt1 -novtswitch
     2700 ?        Sl     0:00  \_ lightdm --session-child 16 19 20
     2744 ?        Ss     0:00  |   \_ /bin/bash /usr/bin/deepin-greeter
     2746 ?        S      0:00  |       \_ /bin/bash /etc/deepin/greeters.d/lightdm-deepin-greeter
     2748 ?        Sl     0:00  |           \_ /usr/lib/deepin-daemon/greeter-display-daemon
     3211 ?        S      0:00  |           |   \_ xrandr --output VGA-0 --auto --pos 0x0 --output DVI-0 --off --output HDMI-0 --off
     2749 ?        Sl     0:02  |           \_ /usr/bin/lightdm-deepin-greeter
     3123 ?        Sl     0:04  |               \_ /usr/bin/python3 /usr/bin/onboard -e --layout Small
    

    greeter-display-daemon(https://github.com/linuxdeepin/startdde/commit/489aa9b8bc38126d0a036e81f9b9f643b35ba205) sends request to xorg. For mate, it is done by mate-settings-daemon(https://github.com/mate-desktop/mate-desktop/blob/a0da3060df54a69f38b76dfd52c137700bdac96e/libmate-desktop/mate-rr.c#L1714)

    So the solution is easy for deepin v15, add:

    display_daemon="/usr/lib/deepin-daemon/greeter-display-daemon"
    if [ -x $display_daemon ]; then
        $display_daemon &
    fi
    /usr/bin/lightdm-deepin-greeter
    

    to lightdm greeter and introduce lightdm-deepin-greeter to system