Skip to content

Commit ad783b9

Browse files
Bartosz Golaszewskibjorn-helgaas
authored andcommitted
PCI/pwrctl: Abandon QCom WCN probe on pre-pwrseq device-trees
Old device trees for some platforms already define wifi nodes for the WCN family of chips since before power sequencing was added upstream. These nodes don't consume the regulator outputs from the PMU, and if we allow this driver to bind to one of such "incomplete" nodes, we'll see a kernel log error about the infinite probe deferral. Extend the driver by adding a platform data struct matched against the compatible. This struct contains the pwrseq target string as well as a validation function called right after entering probe(). For Qualcomm WCN models, check the existence of the regulator supply property that indicates the DT is already using power sequencing and return -ENODEV if it's not there, indicating to the driver model that the device should not be bound to the pwrctl driver. Link: https://lore.kernel.org/r/[email protected] Fixes: 6140d18 ("PCI/pwrctl: Add a PCI power control driver for power sequenced devices") Reported-by: Johan Hovold <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 1d59d47 commit ad783b9

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

drivers/pci/pwrctl/pci-pwrctl-pwrseq.c

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include <linux/device.h>
77
#include <linux/mod_devicetable.h>
88
#include <linux/module.h>
9-
#include <linux/of.h>
109
#include <linux/pci-pwrctl.h>
1110
#include <linux/platform_device.h>
11+
#include <linux/property.h>
1212
#include <linux/pwrseq/consumer.h>
1313
#include <linux/slab.h>
1414
#include <linux/types.h>
@@ -18,6 +18,40 @@ struct pci_pwrctl_pwrseq_data {
1818
struct pwrseq_desc *pwrseq;
1919
};
2020

21+
struct pci_pwrctl_pwrseq_pdata {
22+
const char *target;
23+
/*
24+
* Called before doing anything else to perform device-specific
25+
* verification between requesting the power sequencing handle.
26+
*/
27+
int (*validate_device)(struct device *dev);
28+
};
29+
30+
static int pci_pwrctl_pwrseq_qcm_wcn_validate_device(struct device *dev)
31+
{
32+
/*
33+
* Old device trees for some platforms already define wifi nodes for
34+
* the WCN family of chips since before power sequencing was added
35+
* upstream.
36+
*
37+
* These nodes don't consume the regulator outputs from the PMU, and
38+
* if we allow this driver to bind to one of such "incomplete" nodes,
39+
* we'll see a kernel log error about the indefinite probe deferral.
40+
*
41+
* Check the existence of the regulator supply that exists on all
42+
* WCN models before moving forward.
43+
*/
44+
if (!device_property_present(dev, "vddaon-supply"))
45+
return -ENODEV;
46+
47+
return 0;
48+
}
49+
50+
static const struct pci_pwrctl_pwrseq_pdata pci_pwrctl_pwrseq_qcom_wcn_pdata = {
51+
.target = "wlan",
52+
.validate_device = pci_pwrctl_pwrseq_qcm_wcn_validate_device,
53+
};
54+
2155
static void devm_pci_pwrctl_pwrseq_power_off(void *data)
2256
{
2357
struct pwrseq_desc *pwrseq = data;
@@ -27,15 +61,26 @@ static void devm_pci_pwrctl_pwrseq_power_off(void *data)
2761

2862
static int pci_pwrctl_pwrseq_probe(struct platform_device *pdev)
2963
{
64+
const struct pci_pwrctl_pwrseq_pdata *pdata;
3065
struct pci_pwrctl_pwrseq_data *data;
3166
struct device *dev = &pdev->dev;
3267
int ret;
3368

69+
pdata = device_get_match_data(dev);
70+
if (!pdata || !pdata->target)
71+
return -EINVAL;
72+
73+
if (pdata->validate_device) {
74+
ret = pdata->validate_device(dev);
75+
if (ret)
76+
return ret;
77+
}
78+
3479
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
3580
if (!data)
3681
return -ENOMEM;
3782

38-
data->pwrseq = devm_pwrseq_get(dev, of_device_get_match_data(dev));
83+
data->pwrseq = devm_pwrseq_get(dev, pdata->target);
3984
if (IS_ERR(data->pwrseq))
4085
return dev_err_probe(dev, PTR_ERR(data->pwrseq),
4186
"Failed to get the power sequencer\n");
@@ -64,17 +109,17 @@ static const struct of_device_id pci_pwrctl_pwrseq_of_match[] = {
64109
{
65110
/* ATH11K in QCA6390 package. */
66111
.compatible = "pci17cb,1101",
67-
.data = "wlan",
112+
.data = &pci_pwrctl_pwrseq_qcom_wcn_pdata,
68113
},
69114
{
70115
/* ATH11K in WCN6855 package. */
71116
.compatible = "pci17cb,1103",
72-
.data = "wlan",
117+
.data = &pci_pwrctl_pwrseq_qcom_wcn_pdata,
73118
},
74119
{
75120
/* ATH12K in WCN7850 package. */
76121
.compatible = "pci17cb,1107",
77-
.data = "wlan",
122+
.data = &pci_pwrctl_pwrseq_qcom_wcn_pdata,
78123
},
79124
{ }
80125
};

0 commit comments

Comments
 (0)