From nobody Sun Dec 14 02:02:12 2025 Received: from mslow3.mail.gandi.net (mslow3.mail.gandi.net [217.70.178.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E055413AD38 for ; Fri, 8 Aug 2025 13:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.178.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754661183; cv=none; b=PBy0/epgg49YzZl4sfwq248pQ8O9Mk5mg+1GpkcPE7R6cRGD+Jysuhax/gaXGgAY/H04zVSmabX/slIs8yjn5JT0SWMtWf8fN//f4n7B7rs/XdFmnLNf9RHxQmDlpLj7t3hMP7LdAa3zl95N+ls0YpNgMzTSYyXPXaSAKlfZp0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754661183; c=relaxed/simple; bh=XWrN8dP52L0IECQzWlmUPJVMRWiGNv48/cj4Jc07Mns=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RNFSp8Z4vjuG56a+wprAIRYtkUha5msf19knfVY8bvMy2zE15WvTV920fNQXSkQvTbGpJlfAK8F6HFauoBiwmlat1i2grqLWIp6kudCdVAuRx1JxjhhzrZaTDoP5m3DZxRU6+/k024t+lkOpmeVp/DOMD2uTx7dHsB9PbQLPP1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=LnZsYBMH; arc=none smtp.client-ip=217.70.178.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="LnZsYBMH" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by mslow3.mail.gandi.net (Postfix) with ESMTP id 4ECDA580D99 for ; Fri, 8 Aug 2025 13:24:45 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5396643271; Fri, 8 Aug 2025 13:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1754659477; 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=treXRwqi4SRhQJUrldc4icMQ5j0ZarZub9IcestONf4=; b=LnZsYBMH5x0nLG1bjCVBAqIegeaQq6J+L/4HRYo+gDF37gKN3itJENXn5swEhkp3DEleOH Z0neTAr+2M9qr07S4vk4MeG1EX2LTqFQf3twG35lnHTqYuvgMNGDaLskSFYalDtpfK/rBQ c4krbd2Qn88uDfRtIq2cJLX4prRCFCCZxMldaBMGKYH1bzcyFiaXVoAz67zuP2fdDurI6Q BoJ0IHVGCHyyFqoDGHsSiRT/2466G6V8hVuSota+le9fOffoEfw9Rc2CD2PxBQEorlQiV9 QayyUNwuNB843hkExT03ThkJxPSTffjHUGViqOlifHWOxk01HzVG4HvV6DagZQ== From: Luca Ceresoli Date: Fri, 08 Aug 2025 15:24:28 +0200 Subject: [PATCH 1/2] drm/bridge: add drm_bridge_unplug() and drm_bridge_enter/exit() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250808-drm-bridge-atomic-vs-remove-v1-1-a52e933b08a8@bootlin.com> References: <20250808-drm-bridge-atomic-vs-remove-v1-0-a52e933b08a8@bootlin.com> In-Reply-To: <20250808-drm-bridge-atomic-vs-remove-v1-0-a52e933b08a8@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduvdefleefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepnfhutggrucevvghrvghsohhlihcuoehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeehjefgudegvddukeegvedtgfduudehtdfgteefvefgheekjeehvdeihfdtfffhkeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeejkedrvdduvddrvdejrdduudehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepjeekrddvuddvrddvjedrudduhedphhgvlhhopegludejvddrudeirddtrddungdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedujedprhgtphhtthhopegrnhgurhiivghjrdhhrghjuggrsehinhhtvghlrdgtohhmpdhrtghpthhtohepnfgruhhrvghnthdrphhinhgthhgrrhhtsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehjohhnrghssehkfihisghoo hdrshgvpdhrtghpthhtohepnhgvihhlrdgrrhhmshhtrhhonhhgsehlihhnrghrohdrohhrghdprhgtphhtthhopehjvghrnhgvjhdrshhkrhgrsggvtgesghhmrghilhdrtghomhdprhgtphhtthhopehthhhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehtiihimhhmvghrmhgrnhhnsehsuhhsvgdruggv X-GND-Sasl: luca.ceresoli@bootlin.com To allow DRM bridges to be removable, add synchronization functions allowing to tell when a bridge hardware has been physically unplugged and to mark a critical section that should not be entered after that. This is inspired by the drm_dev_unplugged/enter/exit() functions for struct drm_device. Suggested-by: Maxime Ripard Link: https://lore.kernel.org/all/20250106-vigorous-talented-viper-fa49d9@h= ouat/ Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/drm_bridge.c | 58 ++++++++++++++++++++++++++++++++++++++++= ++++ include/drm/drm_bridge.h | 12 +++++++++ 2 files changed, 70 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index c3bfcd735a3c426a147bf0a7427b3d2cd0df3524..486bc48881c6a05ebe3c911754a= 40530f0d08e3e 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -27,6 +27,7 @@ #include #include #include +#include =20 #include #include @@ -200,6 +201,63 @@ static DEFINE_MUTEX(bridge_lock); static LIST_HEAD(bridge_list); =20 +DEFINE_STATIC_SRCU(drm_bridge_unplug_srcu); + +/** + * drm_bridge_enter - Enter DRM bridge critical section + * @dev: DRM bridge + * @idx: Pointer to index that will be passed to the matching drm_bridge_e= xit() + * + * This function marks and protects the beginning of a section that should= not + * be entered after the bridge has been unplugged. The section end is mark= ed + * with drm_bridge_exit(). Calls to this function can be nested. + * + * Returns: + * True if it is OK to enter the section, false otherwise. + */ +bool drm_bridge_enter(struct drm_bridge *bridge, int *idx) +{ + *idx =3D srcu_read_lock(&drm_bridge_unplug_srcu); + + if (bridge->unplugged) { + srcu_read_unlock(&drm_bridge_unplug_srcu, *idx); + return false; + } + + return true; +} +EXPORT_SYMBOL(drm_bridge_enter); + +/** + * drm_bridge_exit - Exit DRM bridge critical section + * @idx: index returned by drm_bridge_enter() + * + * This function marks the end of a section that should not be entered aft= er + * the bridge has been unplugged. + */ +void drm_bridge_exit(int idx) +{ + srcu_read_unlock(&drm_bridge_unplug_srcu, idx); +} +EXPORT_SYMBOL(drm_bridge_exit); + +/** + * drm_bridge_unplug - unplug a DRM bridge + * @dev: DRM bridge + * + * This tells the bridge has been physically unplugged and no operations on + * device resources must be done anymore. Entry-points can use + * drm_bridge_enter() and drm_bridge_exit() to protect device resources in + * a race free manner. + */ +void drm_bridge_unplug(struct drm_bridge *bridge) +{ + bridge->unplugged =3D true; + + synchronize_srcu(&drm_bridge_unplug_srcu); +} +EXPORT_SYMBOL(drm_bridge_unplug); + static void __drm_bridge_free(struct kref *kref) { struct drm_bridge *bridge =3D container_of(kref, struct drm_bridge, refco= unt); diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 620e119cc24c3491c2be5f08efaf51dfa8f708b3..0c6869ebb2be9b89499ee5c4269= 2fd94ca5b3161 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1095,6 +1095,14 @@ struct drm_bridge { */ struct kref refcount; =20 + /** + * @unplugged: + * + * Flag to tell if the bridge has been unplugged. + * See drm_bridge_enter() and drm_bridge_unplug(). + */ + bool unplugged; + /** @driver_private: pointer to the bridge driver's internal context */ void *driver_private; /** @ops: bitmask of operations supported by the bridge */ @@ -1226,6 +1234,10 @@ drm_priv_to_bridge(struct drm_private_obj *priv) return container_of(priv, struct drm_bridge, base); } =20 +bool drm_bridge_enter(struct drm_bridge *bridge, int *idx); +void drm_bridge_exit(int idx); +void drm_bridge_unplug(struct drm_bridge *bridge); + struct drm_bridge *drm_bridge_get(struct drm_bridge *bridge); void drm_bridge_put(struct drm_bridge *bridge); =20 --=20 2.50.1 From nobody Sun Dec 14 02:02:12 2025 Received: from mslow3.mail.gandi.net (mslow3.mail.gandi.net [217.70.178.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E04EC13A3F7 for ; Fri, 8 Aug 2025 13:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.178.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754661184; cv=none; b=Nqk7JKusvxCX0rl77ZiyJ56usYGDuCqAUsi1sqVLWh1AiDIClclE5HymwRR6Vjbf6CTVjkNLh05qNq9JJ40ULcZSXtcBjQ7RoL2D8Sgwde8OMvAYNOb/MBXu/Ai0tL5MMP9B+WwJP7I8e+DcqZHI5pw8n3mib0wvn7J5kdKlPWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754661184; c=relaxed/simple; bh=MUNeu498HS7QU4YBQORfiN+5EbXPP320FBkpYtkIyVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i5XsaXeNTL1UVEyXFfiiEUKJzCamxvqruZl7QlnO4wDIihLDYxCv9iO/eNLoF0s069dVGJ4grxgwWp7MBuk1Gx0iSbXXQtVOEFtRI7VHEtlKu9x9rJ6fX1xPRwNfOD/1MbxWvQTz6oac+PG1EJjbRZTvVg2rzDC53Yb9y4OY/Hg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=XejCrbEn; arc=none smtp.client-ip=217.70.178.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XejCrbEn" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by mslow3.mail.gandi.net (Postfix) with ESMTP id 59654583E34 for ; Fri, 8 Aug 2025 13:24:47 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0966044325; Fri, 8 Aug 2025 13:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1754659479; 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=Q3dxBTvYDc023lk4xf7xQvavR9Sed93h6eShZ8+/P+k=; b=XejCrbEnpOHx7vxn9eWzaG/FcgZaAm6TjjQ7Iz848DW8G0DrZcwvUkf8WSXsvi/GOQIVJy ACvEIqtleZ/JiHgXQqM2o8yUIKHnQhK93KBdgY+Eo5yPO10M+Ubw0PSkegH7yjL7ZCueZR LOtUfZ9wYZ3niUGrOniRNqLs7xCaWNQ+VxWzsbuYcLu/8HO1x3ohf5o+Vj4PCbH8OQKcSX 89u1sdIvFTDBKb5sQ4vYBMAupI8jG4yyVvKsSqmO8iQlfs9fvVGx9rf31yOXlTAbxctu0z UVEkbMPWR+Hpxaz0G7TNEPFC/XBlA55YU4EYoyt1oQ7pRV3BdBsyama+HCS0UQ== From: Luca Ceresoli Date: Fri, 08 Aug 2025 15:24:29 +0200 Subject: [PATCH 2/2] drm/bridge: ti-sn65dsi83: protect device resources on unplug Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250808-drm-bridge-atomic-vs-remove-v1-2-a52e933b08a8@bootlin.com> References: <20250808-drm-bridge-atomic-vs-remove-v1-0-a52e933b08a8@bootlin.com> In-Reply-To: <20250808-drm-bridge-atomic-vs-remove-v1-0-a52e933b08a8@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduvdefleefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepnfhutggrucevvghrvghsohhlihcuoehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeeiieeuvdfftefgueduleehueetgffgjeeitedtteetkeeuueeuueekveevvdeuveenucfkphepjeekrddvuddvrddvjedrudduheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeejkedrvdduvddrvdejrdduudehpdhhvghloheplgdujedvrdduiedrtddrudgnpdhmrghilhhfrhhomheplhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepudejpdhrtghpthhtoheprghnughriigvjhdrhhgrjhgurgesihhnthgvlhdrtghomhdprhgtphhtthhopefnrghurhgvnhhtrdhpihhntghhrghrthesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhhonhgrsheskhifihgsohhordhsvgdprhgtphhtthhopehnvghilhdrrghrm hhsthhrohhngheslhhinhgrrhhordhorhhgpdhrtghpthhtohepjhgvrhhnvghjrdhskhhrrggsvggtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvg X-GND-Sasl: luca.ceresoli@bootlin.com To support hot-unplug of this bridge we need to protect access to device resources in case sn65dsi83_remove() happens concurrently to other code. Some care is needed for the case when the unplug happens before sn65dsi83_atomic_disable() has a chance to enter the critical section (i.e. a successful drm_bridge_enter() call), which occurs whenever the hardware is removed while the display is active. When that happens, sn65dsi83_atomic_disable() in unable to release some resources, thus this needs to be done in sn65dsi83_remove() after drm_bridge_unplug(). Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 53 +++++++++++++++++++++++++++++++= ++++ 1 file changed, 53 insertions(+) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge= /ti-sn65dsi83.c index 033c44326552ab167d4e8d9b74957c585e4c6fb7..9e4cecf4f7cb056f0c34e87007f= cebf50780e49c 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -157,6 +157,7 @@ struct sn65dsi83 { struct drm_bridge *panel_bridge; struct gpio_desc *enable_gpio; struct regulator *vcc; + bool disable_resources_needed; bool lvds_dual_link; bool lvds_dual_link_even_odd_swap; int lvds_vod_swing_conf[2]; @@ -406,6 +407,10 @@ static void sn65dsi83_reset_work(struct work_struct *w= s) { struct sn65dsi83 *ctx =3D container_of(ws, struct sn65dsi83, reset_work); int ret; + int idx; + + if (!drm_bridge_enter(&ctx->bridge, &idx)) + return; =20 /* Reset the pipe */ ret =3D sn65dsi83_reset_pipe(ctx); @@ -415,12 +420,18 @@ static void sn65dsi83_reset_work(struct work_struct *= ws) } if (ctx->irq) enable_irq(ctx->irq); + + drm_bridge_exit(idx); } =20 static void sn65dsi83_handle_errors(struct sn65dsi83 *ctx) { unsigned int irq_stat; int ret; + int idx; + + if (!drm_bridge_enter(&ctx->bridge, &idx)) + return; =20 /* * Schedule a reset in case of: @@ -441,6 +452,8 @@ static void sn65dsi83_handle_errors(struct sn65dsi83 *c= tx) =20 schedule_work(&ctx->reset_work); } + + drm_bridge_exit(idx); } =20 static void sn65dsi83_monitor_work(struct work_struct *work) @@ -478,10 +491,15 @@ static void sn65dsi83_atomic_pre_enable(struct drm_br= idge *bridge, __le16 le16val; u16 val; int ret; + int idx; + + if (!drm_bridge_enter(bridge, &idx)) + return; =20 ret =3D regulator_enable(ctx->vcc); if (ret) { dev_err(ctx->dev, "Failed to enable vcc: %d\n", ret); + drm_bridge_exit(idx); return; } =20 @@ -625,6 +643,8 @@ static void sn65dsi83_atomic_pre_enable(struct drm_brid= ge *bridge, dev_err(ctx->dev, "failed to lock PLL, ret=3D%i\n", ret); /* On failure, disable PLL again and exit. */ regmap_write(ctx->regmap, REG_RC_PLL_EN, 0x00); + ctx->disable_resources_needed =3D true; + drm_bridge_exit(idx); return; } =20 @@ -633,6 +653,9 @@ static void sn65dsi83_atomic_pre_enable(struct drm_brid= ge *bridge, =20 /* Wait for 10ms after soft reset as specified in datasheet */ usleep_range(10000, 12000); + + ctx->disable_resources_needed =3D true; + drm_bridge_exit(idx); } =20 static void sn65dsi83_atomic_enable(struct drm_bridge *bridge, @@ -640,6 +663,10 @@ static void sn65dsi83_atomic_enable(struct drm_bridge = *bridge, { struct sn65dsi83 *ctx =3D bridge_to_sn65dsi83(bridge); unsigned int pval; + int idx; + + if (!drm_bridge_enter(bridge, &idx)) + return; =20 /* Clear all errors that got asserted during initialization. */ regmap_read(ctx->regmap, REG_IRQ_STAT, &pval); @@ -659,6 +686,8 @@ static void sn65dsi83_atomic_enable(struct drm_bridge *= bridge, /* Use the polling task */ sn65dsi83_monitor_start(ctx); } + + drm_bridge_exit(idx); } =20 static void sn65dsi83_atomic_disable(struct drm_bridge *bridge, @@ -666,6 +695,10 @@ static void sn65dsi83_atomic_disable(struct drm_bridge= *bridge, { struct sn65dsi83 *ctx =3D bridge_to_sn65dsi83(bridge); int ret; + int idx; + + if (!drm_bridge_enter(bridge, &idx)) + return; =20 if (ctx->irq) { /* Disable irq */ @@ -685,6 +718,9 @@ static void sn65dsi83_atomic_disable(struct drm_bridge = *bridge, dev_err(ctx->dev, "Failed to disable vcc: %d\n", ret); =20 regcache_mark_dirty(ctx->regmap); + + ctx->disable_resources_needed =3D false; + drm_bridge_exit(idx); } =20 static enum drm_mode_status @@ -1005,7 +1041,24 @@ static void sn65dsi83_remove(struct i2c_client *clie= nt) { struct sn65dsi83 *ctx =3D i2c_get_clientdata(client); =20 + drm_bridge_unplug(&ctx->bridge); drm_bridge_remove(&ctx->bridge); + + /* + * sn65dsi83_atomic_disable() should release some resources, but it + * cannot if we call drm_bridge_unplug() before it can + * drm_bridge_enter(). If that happens, let's release those + * resources now. + */ + if (ctx->disable_resources_needed) { + if (!ctx->irq) + sn65dsi83_monitor_stop(ctx); + + gpiod_set_value_cansleep(ctx->enable_gpio, 0); + usleep_range(10000, 11000); + + regulator_disable(ctx->vcc); + } } =20 static const struct i2c_device_id sn65dsi83_id[] =3D { --=20 2.50.1