cpufreq: qcom: handle ipq806x with no SMEM
Subsystems (3)
v3 cover cpufreq: qcom: handle ipq806x with no SMEM
This small series handle a small device family of ipq806x devices (Google OnHub) that doesn't have SMEM init.
We improve the SMEM driver and apply a workaround in the cpufreq driver.
(I didn't add the review tag as the patch changed
with the new implementation)
Changes v3:
- Drop first 2 patch as they got merged
- Use of_match_node
Changes v2:
- Rename error macro to INIT_ERR_PTR
- Return -ENODEV from smem probe
- Restructure if condition in cpufreq driver
Christian Marangi (1):
cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
drivers/cpufreq/qcom-cpufreq-nvmem.c | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
PATCH v3 1/1 cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the case for some Google devices (the OnHub family) that can't make use of SMEM to detect the SoC ID.
To handle these specific case, check if the SMEM is not initialized (by checking if the qcom_smem_get_soc_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.
--- drivers/cpufreq/qcom-cpufreq-nvmem.c | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
drivers/cpufreq/qcom-cpufreq-nvmem.c +33 -2
@@ -252,13 +252,22 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,return ret; } +static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = { + { .compatible ="qcom,ipq8062" , .data = (const void *)QCOM_ID_IPQ8062 }, + { .compatible ="qcom,ipq8064" , .data = (const void *)QCOM_ID_IPQ8064 }, + { .compatible ="qcom,ipq8065" , .data = (const void *)QCOM_ID_IPQ8065 }, + { .compatible ="qcom,ipq8066" , .data = (const void *)QCOM_ID_IPQ8066 }, + { .compatible ="qcom,ipq8068" , .data = (const void *)QCOM_ID_IPQ8068 }, + { .compatible ="qcom,ipq8069" , .data = (const void *)QCOM_ID_IPQ8069 }, +}; +static int qcom_cpufreq_ipq8064_name_version (struct device *cpu_dev,struct nvmem_cell *speedbin_nvmem,char **pvs_name,struct qcom_cpufreq_drv *drv) { +int msm_id =-1 , ret =0 ;int speed =0 , pvs =0 ; -int msm_id, ret =0 ;u8 *speedbin;size_t len;
@@ -275,8 +284,30 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,get_krait_bin_format_a (cpu_dev, &speed, &pvs, speedbin); ret =qcom_smem_get_soc_id (&msm_id); -if (ret) +if (ret == -ENODEV ) { +const struct of_device_id *match; +struct device_node *root; + + root =of_find_node_by_path ("/" ); +if (!root) { + ret = -ENODEV ; + goto exit; + } + +/* Fallback to compatible match with no SMEM initialized */ + match =of_match_node (qcom_cpufreq_ipq806x_match_list, root); +of_node_put (root); +if (!match) { + ret = -ENODEV ; + goto exit; + } + +/* We found a matching device, get the msm_id from the data entry */ + msm_id = (int )match->data; + ret =0 ; + }else if (ret) { goto exit; + }switch (msm_id) {case QCOM_ID_IPQ8062 :
Signature · 1 line
2.51.0
Re: [PATCH v3 1/1] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
Quoted 11 lines · Christian Marangi
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the case for some Google devices (the OnHub family) that can't make use of SMEM to detect the SoC ID.
To handle these specific case, check if the SMEM is not initialized (by checking if the
qcom_smem_get_soc_idreturns-ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.Suggested-by Dmitry Baryshkov <[email protected]>Signed-off-by Christian Marangi <[email protected]>---
Konrad
Re: [PATCH v3 1/1] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
In reply to Christian MarangiQuoted 49 lines · Christian Marangi
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the case for some Google devices (the OnHub family) that can't make use of SMEM to detect the SoC ID.
To handle these specific case, check if the SMEM is not initialized (by checking if the
qcom_smem_get_soc_idreturns-ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.Suggested-by Dmitry Baryshkov <[email protected]>Signed-off-by Christian Marangi <[email protected]>--- drivers/cpufreq/qcom-cpufreq-nvmem.c | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)drivers/cpufreq/qcom-cpufreq-nvmem.c +12
-2@@ -252,13 +252,22 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,return ret; } +static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = { + { .compatible ="qcom,ipq8062" , .data = (const void *)QCOM_ID_IPQ8062 }, + { .compatible ="qcom,ipq8064" , .data = (const void *)QCOM_ID_IPQ8064 }, + { .compatible ="qcom,ipq8065" , .data = (const void *)QCOM_ID_IPQ8065 }, + { .compatible ="qcom,ipq8066" , .data = (const void *)QCOM_ID_IPQ8066 }, + { .compatible ="qcom,ipq8068" , .data = (const void *)QCOM_ID_IPQ8068 }, + { .compatible ="qcom,ipq8069" , .data = (const void *)QCOM_ID_IPQ8069 }, +}; +static int qcom_cpufreq_ipq8064_name_version (struct device *cpu_dev,struct nvmem_cell *speedbin_nvmem,char **pvs_name,struct qcom_cpufreq_drv *drv) { +int msm_id =-1 , ret =0 ;int speed =0 , pvs =0 ; -int msm_id, ret =0 ;u8 *speedbin;size_t len;@@ -275,8 +284,30 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,get_krait_bin_format_a (cpu_dev, &speed, &pvs, speedbin); ret =qcom_smem_get_soc_id (&msm_id); -if (ret) +if (ret == -ENODEV ) { +const struct of_device_id *match;
drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 298
Quoted 10 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +10
-0+struct device_node *root; + + root =of_find_node_by_path ("/" ); +if (!root) { + ret = -ENODEV ; + goto exit; + } + +/* Fallback to compatible match with no SMEM initialized */ + match =of_match_node (qcom_cpufreq_ipq806x_match_list, root);
Aren't you re-implementing matching machine? Or actually - the socinfo driver? You are doing the matching of compatible into SOC ID second time. Just do it once - via socinfo driver.
Best regards,
Krzysztof
Re: [PATCH v3 1/1] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
Quoted 56 lines · Krzysztof Kozlowski
Quoted 55 lines · Christian Marangi
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the case for some Google devices (the OnHub family) that can't make use of SMEM to detect the SoC ID.
To handle these specific case, check if the SMEM is not initialized (by checking if the
qcom_smem_get_soc_idreturns-ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.Suggested-by Dmitry Baryshkov <[email protected]>Signed-off-by Christian Marangi <[email protected]>--- drivers/cpufreq/qcom-cpufreq-nvmem.c | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)drivers/cpufreq/qcom-cpufreq-nvmem.c +18
-2@@ -252,13 +252,22 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,return ret; } +static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = { + { .compatible ="qcom,ipq8062" , .data = (const void *)QCOM_ID_IPQ8062 }, + { .compatible ="qcom,ipq8064" , .data = (const void *)QCOM_ID_IPQ8064 }, + { .compatible ="qcom,ipq8065" , .data = (const void *)QCOM_ID_IPQ8065 }, + { .compatible ="qcom,ipq8066" , .data = (const void *)QCOM_ID_IPQ8066 }, + { .compatible ="qcom,ipq8068" , .data = (const void *)QCOM_ID_IPQ8068 }, + { .compatible ="qcom,ipq8069" , .data = (const void *)QCOM_ID_IPQ8069 }, +}; +static int qcom_cpufreq_ipq8064_name_version (struct device *cpu_dev,struct nvmem_cell *speedbin_nvmem,char **pvs_name,struct qcom_cpufreq_drv *drv) { +int msm_id =-1 , ret =0 ;int speed =0 , pvs =0 ; -int msm_id, ret =0 ;u8 *speedbin;size_t len;@@ -275,8 +284,30 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,get_krait_bin_format_a (cpu_dev, &speed, &pvs, speedbin); ret =qcom_smem_get_soc_id (&msm_id); -if (ret) +if (ret == -ENODEV ) { +const struct of_device_id *match; +struct device_node *root; + + root =of_find_node_by_path ("/" ); +if (!root) { + ret = -ENODEV ; + goto exit;
Quoted 8 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 298
Quoted 4 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +4
-0+ } + +/* Fallback to compatible match with no SMEM initialized */ + match =of_match_node (qcom_cpufreq_ipq806x_match_list, root);Aren't you re-implementing matching machine? Or actually - the socinfo driver? You are doing the matching of compatible into SOC ID second time. Just do it once - via socinfo driver.
The issue here is that if SMEM is absent, the socinfo driver can not function and this is a contained workaround
Konrad
Re: [PATCH v3 1/1] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
Quoted 66 lines · Konrad Dybcio
Quoted 56 lines · Krzysztof Kozlowski
Quoted 55 lines · Christian Marangi
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the case for some Google devices (the OnHub family) that can't make use of SMEM to detect the SoC ID.
To handle these specific case, check if the SMEM is not initialized (by checking if the
qcom_smem_get_soc_idreturns-ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.Suggested-by Dmitry Baryshkov <[email protected]>Signed-off-by Christian Marangi <[email protected]>--- drivers/cpufreq/qcom-cpufreq-nvmem.c | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)drivers/cpufreq/qcom-cpufreq-nvmem.c +18
-2@@ -252,13 +252,22 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,return ret; } +static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = { + { .compatible ="qcom,ipq8062" , .data = (const void *)QCOM_ID_IPQ8062 }, + { .compatible ="qcom,ipq8064" , .data = (const void *)QCOM_ID_IPQ8064 }, + { .compatible ="qcom,ipq8065" , .data = (const void *)QCOM_ID_IPQ8065 }, + { .compatible ="qcom,ipq8066" , .data = (const void *)QCOM_ID_IPQ8066 }, + { .compatible ="qcom,ipq8068" , .data = (const void *)QCOM_ID_IPQ8068 }, + { .compatible ="qcom,ipq8069" , .data = (const void *)QCOM_ID_IPQ8069 }, +}; +static int qcom_cpufreq_ipq8064_name_version (struct device *cpu_dev,struct nvmem_cell *speedbin_nvmem,char **pvs_name,struct qcom_cpufreq_drv *drv) { +int msm_id =-1 , ret =0 ;int speed =0 , pvs =0 ; -int msm_id, ret =0 ;u8 *speedbin;size_t len;@@ -275,8 +284,30 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,get_krait_bin_format_a (cpu_dev, &speed, &pvs, speedbin); ret =qcom_smem_get_soc_id (&msm_id); -if (ret) +if (ret == -ENODEV ) { +const struct of_device_id *match; +struct device_node *root; + + root =of_find_node_by_path ("/" ); +if (!root) { + ret = -ENODEV ; + goto exit;Quoted 8 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 298
Quoted 4 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +4
-0+ } + +/* Fallback to compatible match with no SMEM initialized */ + match =of_match_node (qcom_cpufreq_ipq806x_match_list, root);Aren't you re-implementing matching machine? Or actually - the socinfo driver? You are doing the matching of compatible into SOC ID second time. Just do it once - via socinfo driver.
Quoted 2 lines
The issue here is that if SMEM is absent, the socinfo driver can not function and this is a contained workaround
OK, some short paragraph about this should be in commit msg though.
Best regards,
Krzysztof
kernel test robot
build botRe: [PATCH v3 1/1] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
In reply to Christian Marangikernel test robot noticed the following build warnings:
Hi Christian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/bleeding-edge linus/master v6.18-rc4 next-20251105] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/cpufreq-qcom-nvmem-add-compatible-fallback-for-ipq806x-for-no-SMEM/20251104-221546 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20251104140635.25965-2-ansuelsmth%40gmail.com patch subject: [PATCH v3 1/1] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM config: arm64-defconfig (https://download.01.org/0day-ci/archive/20251105/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251105/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/cpufreq/qcom-cpufreq-nvmem.c: In function 'qcom_cpufreq_ipq8064_name_version':
>> drivers/cpufreq/qcom-cpufreq-nvmem.c:310:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
310 | msm_id = (int)match->data;
| ^vim +310 drivers/cpufreq/qcom-cpufreq-nvmem.c
267
268 static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
269 struct nvmem_cell *speedbin_nvmem,
270 char **pvs_name,
271 struct qcom_cpufreq_drv *drv)
272 {
273 int msm_id = -1, ret = 0;
274 int speed = 0, pvs = 0;
275 u8 *speedbin;
276 size_t len;
277
278 speedbin = nvmem_cell_read(speedbin_nvmem, &len);
279 if (IS_ERR(speedbin))
280 return PTR_ERR(speedbin);
281
282 if (len != 4) {
283 dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
284 ret = -ENODEV;
285 goto exit;
286 }
287
288 get_krait_bin_format_a(cpu_dev, &speed, &pvs, speedbin);
289
290 ret = qcom_smem_get_soc_id(&msm_id);
291 if (ret == -ENODEV) {
292 const struct of_device_id *match;
293 struct device_node *root;
294
295 root = of_find_node_by_path("/");
296 if (!root) {
297 ret = -ENODEV;
298 goto exit;
299 }
300
301 /* Fallback to compatible match with no SMEM initialized */
302 match = of_match_node(qcom_cpufreq_ipq806x_match_list, root);
303 of_node_put(root);
304 if (!match) {
305 ret = -ENODEV;
306 goto exit;
307 }
308
309 /* We found a matching device, get the msm_id from the data entry */
> 310 msm_id = (int)match->data; 311 ret = 0;
312 } else if (ret) {
313 goto exit;
314 }
315
316 switch (msm_id) {
317 case QCOM_ID_IPQ8062:
318 drv->versions = BIT(IPQ8062_VERSION);
319 break;
320 case QCOM_ID_IPQ8064:
321 case QCOM_ID_IPQ8066:
322 case QCOM_ID_IPQ8068:
323 drv->versions = BIT(IPQ8064_VERSION);
324 break;
325 case QCOM_ID_IPQ8065:
326 case QCOM_ID_IPQ8069:
327 drv->versions = BIT(IPQ8065_VERSION);
328 break;
329 default:
330 dev_err(cpu_dev,
331 "SoC ID %u is not part of IPQ8064 family, limiting to 1.0GHz!\n",
332 msm_id);
333 drv->versions = BIT(IPQ8062_VERSION);
334 break;
335 }
336
337 /* IPQ8064 speed is never fused. Only pvs values are fused. */
338 snprintf(*pvs_name, sizeof("speed0-pvsXX"), "speed0-pvs%d", pvs);
339
340 exit:
341 kfree(speedbin);
342 return ret;
343 }
344
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki