From patchwork Mon Oct 17 15:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 13008994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC14EC4332F for ; Mon, 17 Oct 2022 15:32:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F92610E44D; Mon, 17 Oct 2022 15:32:08 +0000 (UTC) Received: from mail-4018.proton.ch (mail-4018.proton.ch [185.70.40.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id B07A510E44D for ; Mon, 17 Oct 2022 15:32:02 +0000 (UTC) Date: Mon, 17 Oct 2022 15:31:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1666020720; x=1666279920; bh=bUJdkEV0AJZwcglqX6ugH3X0OXQISRQwEFpN+WUzGVw=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID; b=jPuonxeBy2lrLO10O0cJFeuq807yXprw7f4VlvVqYc4AeeN7jHFJLbtZwpChbBwaD UCHwb+KLpXMt4Blt/FsCtpMiMmwWIrWHDjiZHXYsNtlH57TZ2yzTnrFbtnOaWa0wDe DLMLIY6U1w2nrQnNy0DhIRUzQJxpruLzHcRTzx1uG/z2iFk33U5+2YXsKHjtsHlsF1 sMB5AF+haiYXq0r6uDEURZLlVABIyZo9KXBKt5Sx2TIaaiYUfkRT/ud/3FlxZe3a5Q RB7DUr3hatcai7FMDdW3trzBogRXTgbeIqhkirNiel3NAEHM3tHzxVqJImwiVYVWdW 487OpV04ptKSA== To: dri-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH 1/2] Revert "drm: hide unregistered connectors from GETCONNECTOR IOCTL" Message-ID: <20221017153150.60675-1-contact@emersion.fr> Feedback-ID: 1358184:user:proton MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , =?utf-8?q?Jonas_=C3=85dahl?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This reverts commit 981f09295687f856d5345e19c7084aca481c1395. It turns out this breaks Mutter. Signed-off-by: Simon Ser Cc: Daniel Vetter Cc: Lyude Paul Cc: Jonas Ådahl --- drivers/gpu/drm/drm_mode_config.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 939d621c9ad4..688c8afe0bf1 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -151,9 +151,6 @@ int drm_mode_getresources(struct drm_device *dev, void *data, count = 0; connector_id = u64_to_user_ptr(card_res->connector_id_ptr); drm_for_each_connector_iter(connector, &conn_iter) { - if (connector->registration_state != DRM_CONNECTOR_REGISTERED) - continue; - /* only expose writeback connectors if userspace understands them */ if (!file_priv->writeback_connectors && (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)) From patchwork Mon Oct 17 15:32:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 13008995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3194C4332F for ; Mon, 17 Oct 2022 15:32:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9B8610ED96; Mon, 17 Oct 2022 15:32:22 +0000 (UTC) Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id C758A10ED96 for ; Mon, 17 Oct 2022 15:32:14 +0000 (UTC) Date: Mon, 17 Oct 2022 15:32:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1666020732; x=1666279932; bh=IKMEh+TcgfoRlr9HJfKGhPSu4b8tesTclKkh0S1exQY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=XWeCzDaGJEO3QxbkmlTVdiuImyt82NQtjmkKO9KUZKr5gQjfyJSFvSJmVZESd8GOb XihvZ6IWWPrb1XHJZtDnK4fGZqO01/x0k4biBR6HbZuKPW5KqKUMk2Px+J5IGFbmJH oriw9gNudRBogbStisETZV3GvO7h4YyJJzcSC7b87Ng7UivxwaTciU4WhRv9rAOkRU ISnDCK7VvNEQiDvdTYBUU6or7V9ty4LNZyktGKUScXhautXSNFjYcyiNJnuJLi6ZF7 aDYKI54bvmcBBvD7gl26ZS8zRRxMPqClXMIDqeedklPjKYipX7S1weVjGCe4Qq2fSw VvJ11fgwW38CA== To: dri-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH 2/2] drm/connector: send hotplug uevent on connector cleanup Message-ID: <20221017153150.60675-2-contact@emersion.fr> In-Reply-To: <20221017153150.60675-1-contact@emersion.fr> References: <20221017153150.60675-1-contact@emersion.fr> Feedback-ID: 1358184:user:proton MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , =?utf-8?q?Jonas_=C3=85dahl?= , stable@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A typical DP-MST unplug removes a KMS connector. However care must be taken to properly synchronize with user-space. The expected sequence of events is the following: 1. The kernel notices that the DP-MST port is gone. 2. The kernel marks the connector as disconnected, then sends a uevent to make user-space re-scan the connector list. 3. User-space notices the connector goes from connected to disconnected, disables it. 4. Kernel handles the the IOCTL disabling the connector. On success, the very last reference to the struct drm_connector is dropped and drm_connector_cleanup() is called. 5. The connector is removed from the list, and a uevent is sent to tell user-space that the connector disappeared. The very last step was missing. As a result, user-space thought the connector still existed and could try to disable it again. Since the kernel no longer knows about the connector, that would end up with EINVAL and confused user-space. Fix this by sending a hotplug uevent from drm_connector_cleanup(). Signed-off-by: Simon Ser Cc: stable@vger.kernel.org Cc: Daniel Vetter Cc: Lyude Paul Cc: Jonas Ådahl Tested-by: Jonas Ådahl Reviewed-by: Lyude Paul --- drivers/gpu/drm/drm_connector.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index e3142c8142b3..90dad87e9ad0 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -582,6 +582,9 @@ void drm_connector_cleanup(struct drm_connector *connector) mutex_destroy(&connector->mutex); memset(connector, 0, sizeof(*connector)); + + if (dev->registered) + drm_sysfs_hotplug_event(dev); } EXPORT_SYMBOL(drm_connector_cleanup);