[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251125105617.1564725-1-macpaul.lin@mediatek.com>
Date: Tue, 25 Nov 2025 18:56:17 +0800
From: Macpaul Lin <macpaul.lin@...iatek.com>
To: Ulf Hansson <ulf.hansson@...aro.org>, Matthias Brugger
<matthias.bgg@...il.com>, AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
NĂcolas F . R . A . Prado
<nfraprado@...labora.com>, Macpaul Lin <macpaul.lin@...iatek.com>, "Chen-Yu
Tsai" <wenst@...omium.org>, <linux-pm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>
CC: Weiyi Lu <Weiyi.Lu@...iatek.com>, Jian Hui Lee
<jianhui.lee@...onical.com>, Irving-CH Lin <Irving-CH.Lin@...iatek.com>,
<conor@...nel.org>, <krzk@...nel.org>, Louis-Alexis Eyraud
<louisalexis.eyraud@...labora.com>, Bear Wang <bear.wang@...iatek.com>,
"Pablo Sun" <pablo.sun@...iatek.com>, Ramax Lo <ramax.lo@...iatek.com>,
Macpaul Lin <macpaul@...il.com>, MediaTek Chromebook Upstream
<Project_Global_Chrome_Upstream_Group@...iatek.com>
Subject: [PATCH] pmdomains: mtk-pm-domains: improve spinlock recursion fix in probe
Remove scpsys_get_legacy_regmap() and update usages with
of_find_node_with_property(). Use an explicit of_node_get(np) to ensure
correct node referencing against of_node_put() and ensuring it is called
in a safe context (i.e., not while holding devtree_lock).
If fwnode_count_parents() obtains parent nodes via
fwnode_for_each_parent_node() and this process requires device tree
operations, it may result in repeated acquisition of devtree_lock in
the same thread/context, leading to spinlock recursion errors.
Signed-off-by: Macpaul Lin <macpaul.lin@...iatek.com>
---
drivers/pmdomain/mediatek/mtk-pm-domains.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c
index 80561d27f2b2..f64f24d520dd 100644
--- a/drivers/pmdomain/mediatek/mtk-pm-domains.c
+++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c
@@ -984,18 +984,6 @@ static void scpsys_domain_cleanup(struct scpsys *scpsys)
}
}
-static struct device_node *scpsys_get_legacy_regmap(struct device_node *np, const char *pn)
-{
- struct device_node *local_node;
-
- for_each_child_of_node(np, local_node) {
- if (of_property_present(local_node, pn))
- return local_node;
- }
-
- return NULL;
-}
-
static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *scpsys)
{
const u8 bp_blocks[3] = {
@@ -1017,7 +1005,8 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
* this makes it then possible to allocate the array of bus_prot
* regmaps and convert all to the new style handling.
*/
- node = scpsys_get_legacy_regmap(np, "mediatek,infracfg");
+ of_node_get(np);
+ node = of_find_node_with_property(np, "mediatek,infracfg");
if (node) {
regmap[0] = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg");
of_node_put(node);
@@ -1030,7 +1019,8 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
regmap[0] = NULL;
}
- node = scpsys_get_legacy_regmap(np, "mediatek,smi");
+ of_node_get(np);
+ node = of_find_node_with_property(np, "mediatek,smi");
if (node) {
smi_np = of_parse_phandle(node, "mediatek,smi", 0);
of_node_put(node);
@@ -1048,7 +1038,8 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
regmap[1] = NULL;
}
- node = scpsys_get_legacy_regmap(np, "mediatek,infracfg-nao");
+ of_node_get(np);
+ node = of_find_node_with_property(np, "mediatek,infracfg-nao");
if (node) {
regmap[2] = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg-nao");
num_regmaps++;
--
2.45.2
Powered by blists - more mailing lists