Skip to contentSkip to conversation

interconnect: Restore sync state by ignoring ipa-virt in provider count

PATCH In review Stephen Boyd 5 participants 7 messages Apr 27, 2022 – May 3, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 interconnect: Restore sync state by ignoring ipa-virt in provider count

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")
---
 drivers/interconnect/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/interconnect/core.c +7 -1
index 9050ca1f4285..c52915a58b22 100644
@@ -1087,9 +1087,15 @@ static int of_count_icc_providers(struct device_node *np)
 {
 	struct device_node *child;
 	int count = 0;
+	const struct of_device_id ignore_list[] = {
+		{ .compatible = "qcom,sc7180-ipa-virt" },
+		{ .compatible = "qcom,sdx55-ipa-virt" },
+		{}
+	};
 
 	for_each_available_child_of_node(np, child) {
-		if (of_property_read_bool(child, "#interconnect-cells"))
+		if (of_property_read_bool(child, "#interconnect-cells") &&
+		    likely(!of_match_node(ignore_list, child)))
 			count++;
 		count += of_count_icc_providers(child);
 	}

base-commit: 2fb251c265608636fc961b7d38e1a03937e57371

Signature · 1 line
https://chromeos.dev
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Stephen Boyd

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Quoted 8 lines
Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")

So of_count_icc_providers() counts the number of interconnect providers defined in the DTB, regardless of whether anything in the code supports it.

This seems to be a more general problem, but I suppose in practice it's not likely to occur.

I think your solution looks fine, but I'm interested in what Georgi has to say.

Quoted 27 lines
---
  drivers/interconnect/core.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/interconnect/core.c +7 -1
index 9050ca1f4285..c52915a58b22 100644
@@ -1087,9 +1087,15 @@ static int of_count_icc_providers(struct device_node *np)
  {
  	struct device_node *child;
  	int count = 0;
+	const struct of_device_id ignore_list[] = {
+		{ .compatible = "qcom,sc7180-ipa-virt" },
+		{ .compatible = "qcom,sdx55-ipa-virt" },
+		{}
+	};
 
  	for_each_available_child_of_node(np, child) {
-		if (of_property_read_bool(child, "#interconnect-cells"))
+		if (of_property_read_bool(child, "#interconnect-cells") &&
+		    likely(!of_match_node(ignore_list, child)))
  			count++;
  		count += of_count_icc_providers(child);
  	}

base-commit: 2fb251c265608636fc961b7d38e1a03937e57371

maintainer
#2 lore raw
Quoted 20 lines · Alex Elder
Quoted 10 lines · Stephen Boyd

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Quoted 8 lines
Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")
Quoted 3 lines

So of_count_icc_providers() counts the number of interconnect providers defined in the DTB, regardless of whether anything in the code supports it.

Yes, that's the case currently. There could be multiple provider drivers in different modules, and the modules may be loaded even not during boot, but later. So we rely on DT.

Thanks,
Georgi

Quoted 36 lines

This seems to be a more general problem, but I suppose in practice it's not likely to occur.

I think your solution looks fine, but I'm interested in what Georgi has to say.

Quoted 26 lines

---
  drivers/interconnect/core.c | 8 +++++++-

  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/interconnect/core.c +7 -1
index 9050ca1f4285..c52915a58b22 100644
@@ -1087,9 +1087,15 @@ static int of_count_icc_providers(struct device_node *np)
   {
       struct device_node *child;
       int count = 0;
+    const struct of_device_id ignore_list[] = {
+        { .compatible = "qcom,sc7180-ipa-virt" },
+        { .compatible = "qcom,sdx55-ipa-virt" },
+        {}
+    };
       for_each_available_child_of_node(np, child) {
-        if (of_property_read_bool(child, "#interconnect-cells"))
+        if (of_property_read_bool(child, "#interconnect-cells") &&
+            likely(!of_match_node(ignore_list, child)))
               count++;
           count += of_count_icc_providers(child);
       }
 

base-commit: 2fb251c265608636fc961b7d38e1a03937e57371

#3 lore raw
Quoted 21 lines · Georgi Djakov
Quoted 20 lines · Alex Elder
Quoted 18 lines · Stephen Boyd

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")
Quoted 7 lines
Quoted 3 lines

So of_count_icc_providers() counts the number of interconnect providers defined in the DTB, regardless of whether anything in the code supports it.

Yes, that's the case currently. There could be multiple provider drivers in different modules, and the modules may be loaded even not during boot, but later. So we rely on DT.

Georgi, do you have any other ideas about how to improve this?

What you say makes sense--you figure out the total number of providers at init time based on what's defined in DT.

But when all is said and done, what if even *one* of those has no provider driver? Isn't that what causes the problem here, that icc_sync_state assumes all providers specified in DT will eventually have a driver that calls icc_sync_state()?

(I don't claim to know the interconnect code in detail, so I might not be quite understanding how this works.)

-Alex

Quoted 41 lines

Thanks,
Georgi

Quoted 37 lines

This seems to be a more general problem, but I suppose in practice it's not likely to occur.

I think your solution looks fine, but I'm interested in what Georgi has to say.

Quoted 27 lines

---
  drivers/interconnect/core.c | 8 +++++++-

  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/interconnect/core.c +7 -1
index 9050ca1f4285..c52915a58b22 100644
@@ -1087,9 +1087,15 @@ static int of_count_icc_providers(struct 
 device_node *np)
   {
       struct device_node *child;
       int count = 0;
+    const struct of_device_id ignore_list[] = {
+        { .compatible = "qcom,sc7180-ipa-virt" },
+        { .compatible = "qcom,sdx55-ipa-virt" },
+        {}
+    };
       for_each_available_child_of_node(np, child) {
-        if (of_property_read_bool(child, "#interconnect-cells"))
+        if (of_property_read_bool(child, "#interconnect-cells") &&
+            likely(!of_match_node(ignore_list, child)))
               count++;
           count += of_count_icc_providers(child);
       }

base-commit: 2fb251c265608636fc961b7d38e1a03937e57371

Reviewed-by on v1 1/1
#4 lore raw
In reply to Stephen Boyd

Hi,

Quoted 19 lines · Stephen Boyd

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")
Quoted 3 lines
---
 drivers/interconnect/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Ick, but seems like an expedient fix to get us back to working while we try to come up with something better.

#5 lore raw
In reply to Stephen Boyd

Hi Stephen,

Quoted 10 lines · Stephen Boyd

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Quoted 8 lines
Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")

This patch as commit ad3cc2f05fda ("interconnect: Restore sync state by ignoring ipa-virt in provider count") in -next causes the following build warning when CONFIG_OF is disabled because of_match_node is just NULL:

drivers/interconnect/core.c:1090:28: warning: unused variable 'ignore_list' [-Wunused-variable]

        const struct of_device_id ignore_list[] = {
                                  ^

1 warning generated.

Should it just be marked as __maybe_unused or is there a different fix that would be more appropriate?

Cheers,
Nathan

#6 lore raw

Quoting Nathan Chancellor (2022-05-02 08:18:24)

Quoted 27 lines

Hi Stephen,

Quoted 10 lines · Stephen Boyd

Ignore compatible strings for the IPA virt drivers that were removed in commits 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects") and 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects") so that the sync state logic can kick in again. Otherwise all the interconnects in the system will stay pegged at max speeds because 'providers_count' is always going to be one larger than the number of drivers that will ever probe on sc7180 or sdx55. This fixes suspend on sc7180 and sdx55 devices when you don't have a devicetree patch to remove the ipa-virt compatible node.

Quoted 8 lines
Cc Bjorn Andersson <[email protected]>
Cc Doug Anderson <[email protected]>
Cc Alex Elder <[email protected]>
Cc Taniya Das <[email protected]>
Cc Mike Tipton <[email protected]>
Fixes 2fb251c26560 ("interconnect: qcom: sdx55: Drop IP0 interconnects")
Fixes 2f3724930eb4 ("interconnect: qcom: sc7180: Drop IP0 interconnects")

This patch as commit ad3cc2f05fda ("interconnect: Restore sync state by ignoring ipa-virt in provider count") in -next causes the following build warning when CONFIG_OF is disabled because of_match_node is just NULL:

Quoted 7 lines

drivers/interconnect/core.c:1090:28: warning: unused variable 'ignore_list' [-Wunused-variable]

        const struct of_device_id ignore_list[] = {
                                  ^

1 warning generated.

Should it just be marked as __maybe_unused or is there a different fix that would be more appropriate?

Yeah I think __maybe_unused would work. The other approach would be to make of_match_node() a static inline that returns false with CONFIG_OF=n but that's probably a super large change. I hope the compiler would be able to optimize that whole thing away because the arguments are const pointers but I don't know.