stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Sasha Levin <sashal@kernel.org>,
	rafael@kernel.org, dakr@kernel.org
Subject: [PATCH AUTOSEL 5.15 06/12] drivers: base: devres: Allow to release group on device release
Date: Thu,  3 Apr 2025 15:19:55 -0400	[thread overview]
Message-ID: <20250403192001.2682149-6-sashal@kernel.org> (raw)
In-Reply-To: <20250403192001.2682149-1-sashal@kernel.org>

From: Lucas De Marchi <lucas.demarchi@intel.com>

[ Upstream commit 8e1ddfada4530939a8cb64ee9251aef780474274 ]

When releasing a device, if the release action causes a group to be
released, a warning is emitted because it can't find the group. This
happens because devres_release_all() moves the entire list to a todo
list and also move the group markers. Considering r* normal resource
nodes and g1 a group resource node:

		    g1 -----------.
		    v		  v
	r1 -> r2 -> g1[0] -> r3-> g[1] -> r4

After devres_release_all(), dev->devres_head becomes empty and the todo
list it iterates on becomes:

			       g1
			       v
	r1 -> r2 -> r3-> r4 -> g1[0]

When a call to component_del() is made and takes down the aggregate
device, a warning like this happen:

	RIP: 0010:devres_release_group+0x362/0x530
	...
	Call Trace:
	 <TASK>
	 component_unbind+0x156/0x380
	 component_unbind_all+0x1d0/0x270
	 mei_component_master_unbind+0x28/0x80 [mei_hdcp]
	 take_down_aggregate_device+0xc1/0x160
	 component_del+0x1c6/0x3e0
	 intel_hdcp_component_fini+0xf1/0x170 [xe]
	 xe_display_fini+0x1e/0x40 [xe]

Because the devres group corresponding to the hdcp component cannot be
found. Just ignore this corner case: if the dev->devres_head is empty
and the caller is trying to remove a group, it's likely in the process
of device cleanup so just ignore it instead of warning.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250222001051.3012936-2-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/base/devres.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index d3f59028dec73..58e8e2be26ac7 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -682,6 +682,13 @@ int devres_release_group(struct device *dev, void *id)
 		spin_unlock_irqrestore(&dev->devres_lock, flags);
 
 		release_nodes(dev, &todo);
+	} else if (list_empty(&dev->devres_head)) {
+		/*
+		 * dev is probably dying via devres_release_all(): groups
+		 * have already been removed and are on the process of
+		 * being released - don't touch and don't warn.
+		 */
+		spin_unlock_irqrestore(&dev->devres_lock, flags);
 	} else {
 		WARN_ON(1);
 		spin_unlock_irqrestore(&dev->devres_lock, flags);
-- 
2.39.5


  parent reply	other threads:[~2025-04-03 19:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 19:19 [PATCH AUTOSEL 5.15 01/12] drm: allow encoder mode_set even when connectors change for crtc Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 02/12] drm/amd/display: Update Cursor request mode to the beginning prefetch always Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 03/12] drm: panel-orientation-quirks: Add support for AYANEO 2S Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 04/12] drm: panel-orientation-quirks: Add new quirk for GPD Win 2 Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 05/12] drm/bridge: panel: forbid initializing a panel with unknown connector type Sasha Levin
2025-04-03 19:19 ` Sasha Levin [this message]
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 07/12] drm/amdkfd: clamp queue size to minimum Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 08/12] drm/amdkfd: Fix pqm_destroy_queue race with GPU reset Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 09/12] drm/mediatek: mtk_dpi: Explicitly manage TVD clock in power on/off Sasha Levin
2025-04-03 19:19 ` [PATCH AUTOSEL 5.15 10/12] PCI: vmd: Make vmd_dev::cfg_lock a raw_spinlock_t type Sasha Levin
2025-04-03 19:20 ` [PATCH AUTOSEL 5.15 11/12] fbdev: omapfb: Add 'plane' value check Sasha Levin
2025-04-03 19:20 ` [PATCH AUTOSEL 5.15 12/12] ktest: Fix Test Failures Due to Missing LOG_FILE Directories Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250403192001.2682149-6-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=rafael@kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).