From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B80E33C3C1E; Tue, 16 Jun 2026 17:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781632460; cv=none; b=Ssu4zIeLU9s74EqFUMzm2r5IE2jdYNFx3Z4a3Qstp6wpwgK+m2ry1fjTTD+C4Zg8gzVuXyuH4Nk+80aYQ8gIM75v6f+m7N+m2fzjlpS4VhObU0nKiydtlzTEyj6YZk/4rE0h8R0VlQKZozGL5Me4/41x7UJkdh6UEYh9He6K8SU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781632460; c=relaxed/simple; bh=7rKu0ZZS7f4/RsHWd7LR4mMEMUQrg6JyGDL5WQ/VyBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=suCWZC0Xm0NG2meGqODzqzFZ9UjYSSPHEu+en2+rEuxqxxrJu1Lx2REKMduQaco3U3ULIBxRGXZ8B/ts2PlIVtF1cCbYx/pW8JxVzHaVpW2uh5jhY1XBNHLVyHytIJRYlUjOQTrpuYU4Vf5+8lpdpeCDYSZTianwTrbxGgPM9UM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=g6dAhMGR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="g6dAhMGR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0DEC1F000E9; Tue, 16 Jun 2026 17:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781632459; bh=ZVGRkU6CaAzPE1p1COUVVSMGONPZHmHtmf6Aypxb5T0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g6dAhMGR2e4j8O29B7kfgVb2sJs9u6dXZtqgJonLssyMPIS92tS0CXyowKkNMoENX FZi5q6JuyM7qexId3qsVDxbkOEMtVbWnYQoo8KzvANPn+GlsKfEoz5fGNpqWmhJFcB YAxmtC56QOW0zv2XWIC2FDPs17c8Up7nA2LyHd1w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Geert Uytterhoeven , Geert Uytterhoeven , Ulf Hansson , Sasha Levin Subject: [PATCH 6.1 416/522] pmdomain: core: Fix detach procedure for virtual devices in genpd Date: Tue, 16 Jun 2026 20:29:23 +0530 Message-ID: <20260616145145.487491269@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ulf Hansson [ Upstream commit 26735dfdd8930d9ef1fa92e590a9bf77726efdf6 ] If a device is attached to a PM domain through genpd_dev_pm_attach_by_id(), genpd calls pm_runtime_enable() for the corresponding virtual device that it registers. While this avoids boilerplate code in drivers, there is no corresponding call to pm_runtime_disable() in genpd_dev_pm_detach(). This means these virtual devices are typically detached from its genpd, while runtime PM remains enabled for them, which is not how things are designed to work. In worst cases it may lead to critical errors, like a NULL pointer dereference bug in genpd_runtime_suspend(), which was recently reported. For another case, we may end up keeping an unnecessary vote for a performance state for the device. To fix these problems, let's add this missing call to pm_runtime_disable() in genpd_dev_pm_detach(). Reported-by: Geert Uytterhoeven Closes: https://lore.kernel.org/all/CAMuHMdWapT40hV3c+CSBqFOW05aWcV1a6v_NiJYgoYi0i9_PDQ@mail.gmail.com/ Fixes: 3c095f32a92b ("PM / Domains: Add support for multi PM domains per device to genpd") Cc: stable@vger.kernel.org Tested-by: Geert Uytterhoeven Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/base/power/domain.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2667,6 +2667,7 @@ static struct bus_type genpd_bus_type = static void genpd_dev_pm_detach(struct device *dev, bool power_off) { struct generic_pm_domain *pd; + bool is_virt_dev; unsigned int i; int ret = 0; @@ -2676,6 +2677,13 @@ static void genpd_dev_pm_detach(struct d dev_dbg(dev, "removing from PM domain %s\n", pd->name); + /* Check if the device was created by genpd at attach. */ + is_virt_dev = dev->bus == &genpd_bus_type; + + /* Disable runtime PM if we enabled it at attach. */ + if (is_virt_dev) + pm_runtime_disable(dev); + /* Drop the default performance state */ if (dev_gpd_data(dev)->default_pstate) { dev_pm_genpd_set_performance_state(dev, 0); @@ -2701,7 +2709,7 @@ static void genpd_dev_pm_detach(struct d genpd_queue_power_off_work(pd); /* Unregister the device if it was created by genpd. */ - if (dev->bus == &genpd_bus_type) + if (is_virt_dev) device_unregister(dev); }