Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A266606A322 for ; Sat, 5 Dec 2026 00:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XM5AzQ4K Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 720211131F0; Sat, 5 Dec 2026 00:17:38 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DB101131DE for ; Sat, 5 Dec 2026 00:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796429850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ro8UuBwyXcUSyON+2Dp4EI8e31kAofleqz1t0LSxDI8=; b=XM5AzQ4KlNAhJEp3DjIas+0JDnRM30rI/DyiPtKXgYk5HG1vDc2oP6ZGtZz1BlfSAz4CGf 0Tj0ZzHnqlHY97IPO8Y1uxFvP/Ei4W1sFp+7paXLwqueJSREHO48ec06QEcE4kLNzb8PRf R+n93E7EVibQCfVjmaVhkilyfx+XBQE= X-MC-Rep: binary re single Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-5jzWuzpbOBeHJSAx0WQb4g-1; Sat, 5 Dec 2026 00:17:27 +0000 X-MC-Unique: 5jzWuzpbOBeHJSAx0WQb4g-1 X-Mimecast-MFC-AGG-ID: 5jzWuzpbOBeHJSAx0WQb4g_1796429846 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4d0ef152962so1129614f8f.2 for ; Fri, 04 Dec 2026 16:17:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796429846; x=1797034646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ro8UuBwyXcUSyON+2Dp4EI8e31kAofleqz1t0LSxDI8=; b=l8cVEBj1m5OFp69r9T/Ch3LqbvKjRSnV4k5MWCPusUvpQhpSWEcgVZnedo2J4vxG7t 5BH251Z6ggB5bkPnuak6QHbKqQgGtfZLnSqUVxTx6hGLsJkD/iM2M7hMxc1p8gn5n+Sp wi/n6JLIFYN81S6ygglAZ84mcHXDhJ1odrWBM9lS4EN3RIo1iuo/VBHtomW5/+iA+IQh 9UXqerHaHlQjJ071fxA8GBPgy4u63NRw7ES+U9bqCzT2RRdxaytfjHZ0CSc7hEqf4okc Jy14fBMhRJWikg+lWFGQWnygVJr4s0UGO5JBlolXaMKs/xmGyeRKey5+jy/uJ4iCrjcH Yy5A== X-Gm-Message-State: AB4q+uGR7CwVqIzsegH6rFmKh8a2oG/XT6hvig4Wv8jodtPCxV8NK1iC hapu4itzrNhefTL69gOipeDD/KEbHUbE5TQ34Z2mCAq1/CsmiKhAUKqxbNtLosjOBefSEqrexQ8 i1pWU2T3rn2pKuVNIOHFUOeusZ8/x6y2EYZvLEKid1NjoDTpVgb3zZV3Dwj+8/FHTnO7mV01oia ugelw4W4HW+R8uvNJGpvTV9slJ9aB9l2YuIX1sK7GRS6bOJSrW5TReuEYo/YBi5z87 X-Gm-Gg: AZFdTZci5pGDAdKCcLI8KJ52uMNuqO54WlH4xUJHZqGxX8q1FuyBZWGnbogn/noD+Mi 57QzGvNWsGacBpm3A3IXmbVVSKnnBk8zJVWa+F9SnOA0RbnNj5Q9Mj826QWpM6FEhXXBHP9inZc HAUmCjPvNgnn2K5G//KAQjW3BAuuab2puONQFWZ6dkCLl8I4bxNTKJOOo1H0AnKncv1XMuoD1Pg Lkwsr26vorr6eDoc6bIq2kMiCQGOPXdD63vNUZ86m6sgWPwEJuC+qrbfGsxlxcaF2VYCgx9i/It RaiFUsA0e/sNtJ4rHPfH1mF8qAKpAMrt1J8wt+mZNDqHoz9sVG/bQZU32NyuOJsfq6nQKj5bkrx IYH0ea55Ih8J3G6Fy1N9y65cYMnbs7AawR3AXaonxOdUS3G6OV2h/cZPLIVtU9PyIB+ZzHBYQFQ U4/2nwBU51la63/cexZX5UNLlPjJOO/lI2rS3WTpi4R5V+7WZ4Eg== X-Received: by 2002:a05:6000:4609:b0:4ba:e268:831a with SMTP id ffacd0b85a97d-4d1e291c211mr6458158f8f.6.1796429846021; Fri, 04 Dec 2026 16:17:26 -0800 (PST) X-Received: by 2002:a05:6000:4609:b0:4ba:e268:831a with SMTP id ffacd0b85a97d-4d1e291c211mr6458115f8f.6.1796429845501; Fri, 04 Dec 2026 16:17:25 -0800 (PST) Received: from toolbx.fritz.box (p200300c1df2c2200ffbdcfa601075f09.dip0.t-ipconnect.de. [2003:c1:df2c:2200:ffbd:cfa6:107:5f09]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17302b07dsm7918380f8f.30.2026.12.04.16.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 16:17:24 -0800 (PST) From: Sebastian Wick To: dri-devel@lists.freedesktop.org Cc: louis.chauvet@bootlin.com, hamohammed.sa@gmail.com, simona@ffwll.ch, melissa.srw@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, Sebastian Wick Subject: [PATCH v2 1/2] drm/vkms: Add drm_dev_enter/exit guards for hot-removable paths Date: Sat, 5 Dec 2026 01:17:00 +0100 Message-ID: <20261205001701.1125045-2-sebastian.wick@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205001701.1125045-1-sebastian.wick@redhat.com> References: <20261205001701.1125045-1-sebastian.wick@redhat.com> X-Archived-By: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zKJSrT4aCCfKEYbmSFKvYL8JnrK36PuHmaP05JP6tFQ_1796429846 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 In preparation for switching to drm_dev_unplug() for ConfigFS device removal, add drm_dev_enter()/drm_dev_exit() guards to vkms callbacks that can be reached while the device is being torn down. drm_dev_unplug() relies on these SRCU guards to wait for in-flight operations before proceeding with teardown. Without them, synchronize_srcu() completes immediately and the teardown path can race with in-flight operations. Guard the following callbacks: - vkms_connector_detect() and vkms_conn_get_modes(): called from the MODE_GETCONNECTOR ioctl via fill_modes, which holds mode_config.mutex. Without the guard, an in-flight getconnector can hold locks that drm_atomic_helper_shutdown() needs. - vkms_wb_connector_get_modes(): same fill_modes path for the writeback connector. - vkms_set_crc_source(): called from the CRC debugfs release path. The debugfs proxy explicitly does not protect the release callback against removal races, so this needs its own guard. Atomic commit callbacks are intentionally not guarded: they are serialized against drm_atomic_helper_shutdown() via modeset ww_mutex locks, and must remain functional after unplug so shutdown can disable CRTCs. Changes in v2: - Check drm_dev_enter() after vkms_crc_parse_source() in vkms_set_crc_source() so that the composer is also stopped when the CRC source is disabled on a device that is already gone, instead of failing the ioctl and leaving the composer running Signed-off-by: Sebastian Wick --- drivers/gpu/drm/vkms/vkms_composer.c | 11 ++++++++++- drivers/gpu/drm/vkms/vkms_connector.c | 14 +++++++++++++- drivers/gpu/drm/vkms/vkms_writeback.c | 13 +++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 0fc915a954ba..23df0cb9eeb1 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -731,11 +732,19 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) { struct vkms_output *out = drm_crtc_to_vkms_output(crtc); bool enabled = false; - int ret = 0; + int ret, idx; ret = vkms_crc_parse_source(src_name, &enabled); + if (!drm_dev_enter(crtc->dev, &idx)) { + if (!enabled) + vkms_set_composer(out, false); + return -ENODEV; + } + vkms_set_composer(out, enabled); + drm_dev_exit(idx); + return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c index b0a6b212d3f4..81cd845cf84f 100644 --- a/drivers/gpu/drm/vkms/vkms_connector.c +++ b/drivers/gpu/drm/vkms/vkms_connector.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include +#include #include #include #include @@ -16,6 +17,10 @@ static enum drm_connector_status vkms_connector_detect(struct drm_connector *con struct vkms_connector *vkms_connector; enum drm_connector_status status; struct vkms_config_connector *connector_cfg; + int idx; + + if (!drm_dev_enter(dev, &idx)) + return connector_status_disconnected; vkms_connector = drm_connector_to_vkms_connector(connector); @@ -31,6 +36,8 @@ static enum drm_connector_status vkms_connector_detect(struct drm_connector *con status = vkms_config_connector_get_status(connector_cfg); } + drm_dev_exit(idx); + return status; } @@ -44,12 +51,17 @@ static const struct drm_connector_funcs vkms_connector_funcs = { static int vkms_conn_get_modes(struct drm_connector *connector) { - int count; + int count, idx; + + if (!drm_dev_enter(connector->dev, &idx)) + return 0; /* Use the default modes list from DRM */ count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX); drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF); + drm_dev_exit(idx); + return count; } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index ecf29a2c0c8e..e779ace7b383 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -67,9 +68,17 @@ static int vkms_wb_atomic_check(struct drm_connector *connector, static int vkms_wb_connector_get_modes(struct drm_connector *connector) { struct drm_device *dev = connector->dev; + int count, idx; - return drm_add_modes_noedid(connector, dev->mode_config.max_width, - dev->mode_config.max_height); + if (!drm_dev_enter(dev, &idx)) + return 0; + + count = drm_add_modes_noedid(connector, dev->mode_config.max_width, + dev->mode_config.max_height); + + drm_dev_exit(idx); + + return count; } static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector, -- 2.55.0