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 3742421A455; Tue, 29 Apr 2025 17:42:41 +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=1745948561; cv=none; b=SOPerIe62NoL74rWBYDKiZ8FS2rBoQnCMzDU53qGhPptmjhF3M3XWRtDxjd7uL2y0TkgAI1CF+FTdXBkTj5dENHM3d8rvrbteY7EsfYI1OpHF8Bqh0SkSGSlaAX+ELJzrcAsCNfb6w3B5IZIhenlm+XDKpX+1dqSxhk3QNSDAbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948561; c=relaxed/simple; bh=7vYiiYb/oFXxIUQ5Smc+Ylk3SdYJCJHvo7YjtvBC8GA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QHM1UEZdztNEx1Njt0B+Kv6+M38sPF/NL4iTudbmSR2LJdmgjZRElKi1xBAfMaDaVKQ42P8MJoQvGX02dQcXFAgXAHZM35qAbyVms/Ev+CBfdnizP55frXj0+UNWNNGtbE8hpzjEOP1IU3MThAh0ue7iECiIAP34o/B6Ozyc6hY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=a76gdbmL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="a76gdbmL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6206AC4CEE3; Tue, 29 Apr 2025 17:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745948561; bh=7vYiiYb/oFXxIUQ5Smc+Ylk3SdYJCJHvo7YjtvBC8GA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a76gdbmLvr3ACrp4b73KK+7cdkhITfDU+s0zTWEcoyoj4B7qXW7Bh4nHnygFFWA6l tQ6eYIaZ5lMg2L61OrRJpqweqmR+NwlsvL39uk6IUEB8lFIEIp2UQCA7RlbGpqisPj 79py+kqakJCgGqdDLJHy4JRE3lCWmqceOVaH/ZVo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rodrigo Vivi , Lucas De Marchi , Sasha Levin Subject: [PATCH 5.15 044/373] drivers: base: devres: Allow to release group on device release Date: Tue, 29 Apr 2025 18:38:41 +0200 Message-ID: <20250429161124.939160529@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ 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 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