Re: [v0 2/2] cpufreq: qcom-fw: Add support for QCOM cpufreq FW driver

From: kbuild test robot
Date: Fri May 18 2018 - 20:28:36 EST


Hi Taniya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Taniya-Das/Add-support-for-QCOM-cpufreq-FW-driver/20180519-050902
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

drivers/cpufreq/qcom-cpufreq-fw.c: In function 'qcom_cpufreq_fw_cpu_init':
>> drivers/cpufreq/qcom-cpufreq-fw.c:77:8: error: 'struct cpufreq_policy' has no member named 'table'
policy->table = c->table;
^~
drivers/cpufreq/qcom-cpufreq-fw.c: In function 'qcom_cpu_resources_init':
>> drivers/cpufreq/qcom-cpufreq-fw.c:187:37: error: passing argument 1 of 'platform_get_resource_byname' from incompatible pointer type [-Werror=incompatible-pointer-types]
res = platform_get_resource_byname(dev, IORESOURCE_MEM, "en_base");
^~~
In file included from include/linux/of_device.h:6:0,
from include/linux/of_platform.h:12,
from drivers/cpufreq/qcom-cpufreq-fw.c:11:
include/linux/platform_device.h:56:25: note: expected 'struct platform_device *' but argument is of type 'struct device *'
extern struct resource *platform_get_resource_byname(struct platform_device *,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/cpufreq/qcom-cpufreq-fw.c:187:6: error: incompatible types when assigning to type 'struct resource' from type 'struct resource *'
res = platform_get_resource_byname(dev, IORESOURCE_MEM, "en_base");
^
>> drivers/cpufreq/qcom-cpufreq-fw.c:188:6: error: wrong type argument to unary exclamation mark
if (!res) {
^
>> drivers/cpufreq/qcom-cpufreq-fw.c:193:33: error: invalid type argument of '->' (have 'struct resource')
en_base = devm_ioremap(dev, res->start, resource_size(res));
^~
>> drivers/cpufreq/qcom-cpufreq-fw.c:193:56: error: incompatible type for argument 1 of 'resource_size'
en_base = devm_ioremap(dev, res->start, resource_size(res));
^~~
In file included from include/linux/of_address.h:4:0,
from drivers/cpufreq/qcom-cpufreq-fw.c:10:
include/linux/ioport.h:196:31: note: expected 'const struct resource *' but argument is of type 'struct resource'
static inline resource_size_t resource_size(const struct resource *res)
^~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +77 drivers/cpufreq/qcom-cpufreq-fw.c

> 11 #include <linux/of_platform.h>
12
13 #define INIT_RATE 300000000UL
14 #define XO_RATE 19200000UL
15 #define LUT_MAX_ENTRIES 40U
16 #define CORE_COUNT_VAL(val) ((val & GENMASK(18, 16)) >> 16)
17 #define LUT_ROW_SIZE 32
18
19 struct cpufreq_qcom {
20 struct cpufreq_frequency_table *table;
21 struct device *dev;
22 void __iomem *perf_base;
23 void __iomem *lut_base;
24 cpumask_t related_cpus;
25 unsigned int max_cores;
26 };
27
28 static struct cpufreq_qcom *qcom_freq_domain_map[NR_CPUS];
29
30 static int
31 qcom_cpufreq_fw_target_index(struct cpufreq_policy *policy, unsigned int index)
32 {
33 struct cpufreq_qcom *c = policy->driver_data;
34
35 if (index >= LUT_MAX_ENTRIES) {
36 dev_err(c->dev,
37 "Passing an index (%u) that's greater than max (%d)\n",
38 index, LUT_MAX_ENTRIES - 1);
39 return -EINVAL;
40 }
41
42 writel_relaxed(index, c->perf_base);
43
44 /* Make sure the write goes through before proceeding */
45 mb();
46 return 0;
47 }
48
49 static unsigned int qcom_cpufreq_fw_get(unsigned int cpu)
50 {
51 struct cpufreq_qcom *c;
52 unsigned int index;
53
54 c = qcom_freq_domain_map[cpu];
55 if (!c)
56 return -ENODEV;
57
58 index = readl_relaxed(c->perf_base);
59 index = min(index, LUT_MAX_ENTRIES - 1);
60
61 return c->table[index].frequency;
62 }
63
64 static int qcom_cpufreq_fw_cpu_init(struct cpufreq_policy *policy)
65 {
66 struct cpufreq_qcom *c;
67 int ret;
68
69 c = qcom_freq_domain_map[policy->cpu];
70 if (!c) {
71 pr_err("No scaling support for CPU%d\n", policy->cpu);
72 return -ENODEV;
73 }
74
75 cpumask_copy(policy->cpus, &c->related_cpus);
76
> 77 policy->table = c->table;
78 policy->driver_data = c;
79
80 return ret;
81 }
82
83 static struct freq_attr *qcom_cpufreq_fw_attr[] = {
84 &cpufreq_freq_attr_scaling_available_freqs,
85 &cpufreq_freq_attr_scaling_boost_freqs,
86 NULL
87 };
88
89 static struct cpufreq_driver cpufreq_qcom_fw_driver = {
90 .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
91 CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
92 .verify = cpufreq_generic_frequency_table_verify,
93 .target_index = qcom_cpufreq_fw_target_index,
94 .get = qcom_cpufreq_fw_get,
95 .init = qcom_cpufreq_fw_cpu_init,
96 .name = "qcom-cpufreq-fw",
97 .attr = qcom_cpufreq_fw_attr,
98 .boost_enabled = true,
99 };
100
101 static int qcom_read_lut(struct platform_device *pdev,
102 struct cpufreq_qcom *c)
103 {
104 struct device *dev = &pdev->dev;
105 u32 data, src, lval, i, core_count, prev_cc = 0;
106
107 c->table = devm_kcalloc(dev, LUT_MAX_ENTRIES + 1,
108 sizeof(*c->table), GFP_KERNEL);
109 if (!c->table)
110 return -ENOMEM;
111
112 for (i = 0; i < LUT_MAX_ENTRIES; i++) {
113 data = readl_relaxed(c->lut_base + i * LUT_ROW_SIZE);
114 src = ((data & GENMASK(31, 30)) >> 30);
115 lval = (data & GENMASK(7, 0));
116 core_count = CORE_COUNT_VAL(data);
117
118 if (!src)
119 c->table[i].frequency = INIT_RATE / 1000;
120 else
121 c->table[i].frequency = XO_RATE * lval / 1000;
122
123 c->table[i].driver_data = c->table[i].frequency;
124
125 dev_dbg(dev, "index=%d freq=%d, core_count %d\n",
126 i, c->table[i].frequency, core_count);
127
128 if (core_count != c->max_cores)
129 c->table[i].frequency = CPUFREQ_ENTRY_INVALID;
130
131 /*
132 * Two of the same frequencies with the same core counts means
133 * end of table.
134 */
135 if (i > 0 && c->table[i - 1].driver_data ==
136 c->table[i].driver_data
137 && prev_cc == core_count) {
138 struct cpufreq_frequency_table *prev = &c->table[i - 1];
139
140 if (prev->frequency == CPUFREQ_ENTRY_INVALID) {
141 prev->flags = CPUFREQ_BOOST_FREQ;
142 prev->frequency = prev->driver_data;
143 }
144
145 break;
146 }
147 prev_cc = core_count;
148 }
149 c->table[i].frequency = CPUFREQ_TABLE_END;
150
151 return 0;
152 }
153
154 static int qcom_get_related_cpus(struct device_node *np, struct cpumask *m)
155 {
156 struct device_node *dev_phandle;
157 struct device *cpu_dev;
158 int cpu, i = 0, ret = -ENOENT;
159
160 dev_phandle = of_parse_phandle(np, "qcom,cpulist", i++);
161 while (dev_phandle) {
162 for_each_possible_cpu(cpu) {
163 cpu_dev = get_cpu_device(cpu);
164 if (cpu_dev && cpu_dev->of_node == dev_phandle) {
165 cpumask_set_cpu(cpu, m);
166 ret = 0;
167 break;
168 }
169 }
170 dev_phandle = of_parse_phandle(np, "qcom,cpulist", i++);
171 }
172
173 return ret;
174 }
175
176 static int qcom_cpu_resources_init(struct platform_device *pdev,
177 struct device_node *np)
178 {
179 struct cpufreq_qcom *c;
180 struct resource res;
181 struct device *dev = &pdev->dev;
182 void __iomem *en_base;
183 int cpu, index = 0, ret;
184
185 c = devm_kzalloc(dev, sizeof(*c), GFP_KERNEL);
186
> 187 res = platform_get_resource_byname(dev, IORESOURCE_MEM, "en_base");
> 188 if (!res) {
189 dev_err(dev, "Enable base not defined for %s\n", np->name);
190 return ret;
191 }
192
> 193 en_base = devm_ioremap(dev, res->start, resource_size(res));
194 if (!en_base) {
195 dev_err(dev, "Unable to map %s en-base\n", np->name);
196 return -ENOMEM;
197 }
198
199 /* FW should be enabled state to proceed */
200 if (!(readl_relaxed(en_base) & 0x1)) {
201 dev_err(dev, "%s firmware not enabled\n", np->name);
202 return -ENODEV;
203 }
204
205 devm_iounmap(&pdev->dev, en_base);
206
207 index = of_property_match_string(np, "reg-names", "perf_base");
208 if (index < 0)
209 return index;
210
211 if (of_address_to_resource(np, index, &res))
212 return -ENOMEM;
213
214 c->perf_base = devm_ioremap(dev, res.start, resource_size(&res));
215 if (!c->perf_base) {
216 dev_err(dev, "Unable to map %s perf-base\n", np->name);
217 return -ENOMEM;
218 }
219
220 index = of_property_match_string(np, "reg-names", "lut_base");
221 if (index < 0)
222 return index;
223
224 if (of_address_to_resource(np, index, &res))
225 return -ENOMEM;
226
227 c->lut_base = devm_ioremap(dev, res.start, resource_size(&res));
228 if (!c->lut_base) {
229 dev_err(dev, "Unable to map %s lut-base\n", np->name);
230 return -ENOMEM;
231 }
232
233 ret = qcom_get_related_cpus(np, &c->related_cpus);
234 if (ret) {
235 dev_err(dev, "%s failed to get core phandles\n", np->name);
236 return ret;
237 }
238
239 c->max_cores = cpumask_weight(&c->related_cpus);
240
241 ret = qcom_read_lut(pdev, c);
242 if (ret) {
243 dev_err(dev, "%s failed to read LUT\n", np->name);
244 return ret;
245 }
246
247 for_each_cpu(cpu, &c->related_cpus)
248 qcom_freq_domain_map[cpu] = c;
249
250 return 0;
251 }
252

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip