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);