From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4B3F0261E63; Thu, 3 Apr 2025 19:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707661; cv=none; b=Eba5gXnFCqjsFOBpxlWipNYpVi0kTpBDpNN3F/WKGTRpvhZp1CPPjyEwb/KlDPaJBdnAt7PAMJyQI6O37QPlYez2uKUevB8U3EiA+ftm9I7EwnPuql/xuqiEZ5Cd63msH+J2NtYvHQlAvGFfKCFrw13F8iU74dRDqKT1eaBwS3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707661; c=relaxed/simple; bh=/K7f4ovmNvqf3FtNeaVe7cZYQY+aKaFFpne9P+lP7wk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o4tsrT2ksme7cKAsV2rCwctt/M1w0/Up08s8TPw1W76mW0zW1t4onjt+wldPGPhgQyBSsoX0IaxVRDKtSTEV8C5o1e7USpUj0cAIY7E1yvMDB0XUZdtuiJU8IPuMDKRSCx6P3/6LTSvHO40/U0GnDpwzaKY9FHGXHUjwZ71yfi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=btlJYrRI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="btlJYrRI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD9A2C4CEE8; Thu, 3 Apr 2025 19:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743707660; bh=/K7f4ovmNvqf3FtNeaVe7cZYQY+aKaFFpne9P+lP7wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btlJYrRIiLJeiMeFuGYyz9tCmgskBBQN52Z+zCcENg+0ZPkdt3zs3p+pQn66/UXRo 5hujXDZVslxHj4KBwsCabs/2AyJx1n8Mqn0faCqn50tbq5A/6B0e6hARRB7fo6y5eT XZLpC07YOfzY8ZQ9lZr7KAh8m0S5OeHXFgGmzq3w7jblBwHjVUP5SPmRQ9VB4L6r5L syHXL7FZyGb0kdhm6Wy+DPgT2zp2+eCkrrP+5gz84+aIpbYq9U4e19PKyVPxpVpPSy vhDuPGl+OQqbidpMj80aLOxc8N2zuDpijQsSh62B86QXp2wXm7iVt1CYdEMi83gU+P VSHeNuhrQSm8A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lucas De Marchi , Greg Kroah-Hartman , Rodrigo Vivi , Sasha Levin , rafael@kernel.org, dakr@kernel.org Subject: [PATCH AUTOSEL 6.14 21/44] drivers: base: devres: Allow to release group on device release Date: Thu, 3 Apr 2025 15:12:50 -0400 Message-Id: <20250403191313.2679091-21-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250403191313.2679091-1-sashal@kernel.org> References: <20250403191313.2679091-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14 Content-Transfer-Encoding: 8bit From: Lucas De Marchi [ 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: 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 Reviewed-by: Rodrigo Vivi Link: https://patchwork.freedesktop.org/patch/msgid/20250222001051.3012936-2-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi Signed-off-by: Sasha Levin --- drivers/base/devres.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 93e7779ef21e8..b955a2f9520bf 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -687,6 +687,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