Re: [PATCH v4 3/3] arm64: dts: qcom: sc8280xp-x13s: model the PMU of the on-board wcn6855

From: Bartosz Golaszewski
Date: Thu Oct 03 2024 - 08:17:24 EST


On Thu, 3 Oct 2024 13:38:35 +0200, Bartosz Golaszewski <brgl@xxxxxxxx> said:
> On Thu, Oct 3, 2024 at 1:07 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
>>
>> Without this patch I'm seeing an indefinite probe deferral with
>> 6.12-rc1:
>>
>> platform 1c00000.pcie:pcie@0:wifi@0: deferred probe pending: pci-pwrctl-pwrseq: Failed to get the power sequencer
>>
>> Can you please look into that and make sure that the existing DT
>> continues to work without such warnings.
>>
>
> Ah, dammit, I missed the fact that X13s already has this node defined
> so PCI pwrctl will consume it and try to get the power sequencer
> handle. I'm wondering how to tackle it though... It will most likely
> require some kind of a driver quirk where we check if we have the PMU
> node and if not, then don't try to set up power sequencing. Any other
> ideas?
>

This is untested but would it make sense?

diff --git a/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c
b/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c
index a23a4312574b..071ee77c763d 100644
--- a/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c
+++ b/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c
@@ -3,6 +3,7 @@
* Copyright (C) 2024 Linaro Ltd.
*/

+#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
@@ -87,7 +88,31 @@ static struct platform_driver pci_pwrctl_pwrseq_driver = {
},
.probe = pci_pwrctl_pwrseq_probe,
};
-module_platform_driver(pci_pwrctl_pwrseq_driver);
+
+static int __init pci_pwrctl_pwrseq_init(void)
+{
+ /*
+ * Old device trees for the Lenovo X13s have the "pci17cb,1103" node
+ * defined but don't use power sequencing yet. If we register this
+ * driver, it will match against this node and lead to emitting of
+ * a warning in the kernel log when we cannot get the power sequencing
+ * handle. Let's skip registering the platform driver if we're on X13s
+ * but don't have the PMU node.
+ */
+ if (of_machine_is_compatible("lenovo,thinkpad-x13s")) {
+ struct device_node *dn __free(device_node) =
+ of_find_compatible_node(NULL, NULL, "qcom,wcn6855-pmu");
+ if (!dn)
+ return 0;
+ }
+
+ return platform_driver_register(&pci_pwrctl_pwrseq_driver);
+}
+
+static void __exit pci_pwrctl_pwrseq_exit(void)
+{
+ platform_driver_unregister(&pci_pwrctl_pwrseq_driver);
+}

MODULE_AUTHOR("Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>");
MODULE_DESCRIPTION("Generic PCI Power Control module for power
sequenced devices");

X13s is the only platform that would use one of the compatibles supported by
this driver before power sequencing so it should be a one-off quirk.

Bart