From owner-freebsd-current@freebsd.org Tue Dec 1 14:01:09 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B8D54AA9B8 for ; Tue, 1 Dec 2020 14:01:09 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4ClkKJ0kN9z3qKd; Tue, 1 Dec 2020 14:01:07 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 1AECD260217; Tue, 1 Dec 2020 15:01:06 +0100 (CET) Subject: Re: Issues with USB-C external monitors To: Ali Abdallah , freebsd-current@freebsd.org, Scott Long References: <20201201131430.ol7pzms24h743iwf@frix230> From: Hans Petter Selasky Message-ID: <342519ee-6f73-98be-29b1-cea7890ccb1e@selasky.org> Date: Tue, 1 Dec 2020 15:00:55 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201201131430.ol7pzms24h743iwf@frix230> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4ClkKJ0kN9z3qKd X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.30 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[88.99.82.50:from]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[selasky.org]; ARC_NA(0.00)[]; SPAMHAUS_ZRD(0.00)[88.99.82.50:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.997]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:88.99.0.0/16, country:DE]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-current]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2020 14:01:09 -0000 On 12/1/20 2:14 PM, Ali Abdallah wrote: > Hello, > > I have a T495 with a USB-C docking station with two external monitors, > running current to get the vega 10 amdgpu to work. > > When the power is lost for on the USB-C dock, then the X server looses > all external monitors. They appear as disconnected after running xrandr > and I cannot figure out a way to bring them back without killing my > current session and start X again, but that is very annoying... > > I tried to debug the issue and I'm pretty sure that the X server on > FreeBSD is not reconfiguring the drm connectors automatically. > > Let's say I have DP-4 as external connector, when the power is lost, > DP-4 disappears, when the power is back, DP-4 re-appear again but in > unknown status. > > $ sysctl sys.class.drm | grep DP-4 > sys.class.drm.card0-DP-4.modes: > sys.class.drm.card0-DP-4.dpms: Off > sys.class.drm.card0-DP-4.enabled: disabled > sys.class.drm.card0-DP-4.status: unknown > > Now just running a simple libdrm code to rescan the connectors: > > __snippet__ > res = drmModeGetResources(fd); > for (int i = 0; i < res->count_connectors; ++i) { > conn = drmModeGetConnector(fd, res->connectors[i]); > > After running the above code, the drm stack is somehow triggered to > re-read the DP-4.status, which appears now to be connected, but not > configured. > > $ sysctl sys.class.drm | grep DP-4 > sys.class.drm.card0-DP-4.modes: 1920x1080 > sys.class.drm.card0-DP-4.dpms: Off > sys.class.drm.card0-DP-4.enabled: disabled > sys.class.drm.card0-DP-4.status: connected > > I didn't dig further to see if I can trigger the X server to re-scan drm > connectors and eventually remove those that vanished, and add newly > detected connectors. On Linux that seems to work automatically. > > Any thoughts? There is missing code in the kernel to handle USB-C PCI express attach/detach. CC'ing Scott Long. --HPS