hotplug vga(drm radeon) 从断开连接变为连接,但仍被 sys 禁用
hotplug vga(drm radeon) turns disconnected to connected, but is still disabled from sys
这是我的显卡:
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
在没有插入Vga的情况下启动后,我热插拔了Vga显示器。但是屏幕仍然是黑色的,lightdm/xdm 没有出现。不过我注意到
VGA
状态为 connected
,
- 但是
enabled
是 disabled
:
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/status
connected
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/enabled
disabled
xdm
后台愉快运行:
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)
一旦我切换到其他 tty(例如,Ctrl Alt F1,它既是 connected
又是 enabled
:
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/status
connected
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/enabled
enabled
我使用 drm.debug=0x1e log_buf_len=4M
将 drm 转为详细模式,这是内核日志(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
这是完整的 drm|radeon
日志(包含许多 ioctl 日志):https://paste.ubuntu.com/p/rWDZ7GCdN6/
从完整的日志中,我发现切换到tty后的第一个ioctl是:
May 12 16:44:41 lccy7 kernel: [drm:drm_ioctl] pid=4206, dev=0xe200, auth=1, DRM_IOCTL_MODE_SETCRTC
我已经确定如果我用插入的 Vga 启动,lightdm/xdm 可以毫无问题地显示。
调试 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);
我发现没有人将 ProcRRSetScreenSize
和 ProcRRSetCrtcConfig
发送到 Xorg。所以应该是桌面环境问题
我的de是dde v15,dde v20和mate都可以,下面是deepin v20的进程树:
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)
所以deepin v15的解决方法很简单,补充:
display_daemon="/usr/lib/deepin-daemon/greeter-display-daemon"
if [ -x $display_daemon ]; then
$display_daemon &
fi
/usr/bin/lightdm-deepin-greeter
加入 lightdm greeter 并将 lightdm-deepin-greeter 引入系统
这是我的显卡:
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
在没有插入Vga的情况下启动后,我热插拔了Vga显示器。但是屏幕仍然是黑色的,lightdm/xdm 没有出现。不过我注意到
VGA
状态为connected
,- 但是
enabled
是disabled
:
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/status
connected
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/enabled
disabled
xdm
后台愉快运行:
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)
一旦我切换到其他 tty(例如,Ctrl Alt F1,它既是 connected
又是 enabled
:
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/status
connected
root@lccy7:~# cat /sys/class/drm/card0-VGA-1/enabled
enabled
我使用 drm.debug=0x1e log_buf_len=4M
将 drm 转为详细模式,这是内核日志(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
这是完整的 drm|radeon
日志(包含许多 ioctl 日志):https://paste.ubuntu.com/p/rWDZ7GCdN6/
从完整的日志中,我发现切换到tty后的第一个ioctl是:
May 12 16:44:41 lccy7 kernel: [drm:drm_ioctl] pid=4206, dev=0xe200, auth=1, DRM_IOCTL_MODE_SETCRTC
我已经确定如果我用插入的 Vga 启动,lightdm/xdm 可以毫无问题地显示。
调试 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);
我发现没有人将 ProcRRSetScreenSize
和 ProcRRSetCrtcConfig
发送到 Xorg。所以应该是桌面环境问题
我的de是dde v15,dde v20和mate都可以,下面是deepin v20的进程树:
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)
所以deepin v15的解决方法很简单,补充:
display_daemon="/usr/lib/deepin-daemon/greeter-display-daemon"
if [ -x $display_daemon ]; then
$display_daemon &
fi
/usr/bin/lightdm-deepin-greeter
加入 lightdm greeter 并将 lightdm-deepin-greeter 引入系统