Skip to contentSkip to conversation

cpufreq: qcom: handle ipq806x with no SMEM

PATCH Applied Christian Marangi 5 participants 15 messages Oct 31, 2025 – Nov 4, 2025

Subsystems (4)

v2 of 4 Applied Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 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.

Changes v2:
- Rename error macro to INIT_ERR_PTR
- Return -ENODEV from smem probe
- Restructure if condition in cpufreq driver

Christian Marangi (3):
err.h: add INIT_ERR_PTR macro
soc: qcom: smem: better track SMEM uninitialized state
cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

 drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
 drivers/soc/qcom/smem.c              | 26 +++++++++++++++-----------
 include/linux/err.h                  |  8 ++++++++
 3 files changed, 38 insertions(+), 13 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/3 err.h: add INIT_ERR_PTR macro

Add INIT_ERR_PTR macro to initialize static variables with error pointers. This might be useful for specific case where there is a static variable initialized to an error condition and then later set to the real handle once probe finish/completes.

This is to handle compilation problems like:

error: initializer element is not constant

where ERR_PTR can't be used.

---
 include/linux/err.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/err.h +8 -0
index 1d60aa86db53..8c37be0620ab 100644
@@ -41,6 +41,14 @@ static inline void * __must_check ERR_PTR(long error)
 	return (void *) error;
 }
 
+/**
+ * INIT_ERR_PTR - Init a const error pointer.
+ * @error: A negative error code.
+ *
+ * Like ERR_PTR(), but usable to initialize static variables.
+ */
+#define INIT_ERR_PTR(error) ((void *)(error))
+
 /* Return the pointer in the percpu address space. */
 #define ERR_PTR_PCPU(error) ((void __percpu *)(unsigned long)ERR_PTR(error))
 
Signature · 1 line
2.51.0
#3 lore raw

PATCH v2 2/3 soc: qcom: smem: better track SMEM uninitialized state

In reply to Christian Marangi

There is currently a problem where, in the specific case of SMEM not initialized by SBL, any SMEM API wrongly returns PROBE_DEFER communicating wrong info to any user of this API.

A better way to handle this would be to track the SMEM state and return a different kind of error than PROBE_DEFER.

Rework the __smem handle to always init it to the error pointer -EPROBE_DEFER following what is already done by the SMEM API. If we detect that the SBL didn't initialized SMEM, set the __smem handle to the error pointer -ENODEV.
Also rework the SMEM API to handle the __smem handle to be an error pointer and return it appropriately.

This way user of the API can react and return a proper error or use fallback way for the failing API.

While at it, change the return error when SMEM is not initialized by SBL also to -ENODEV to make it consistent with the __smem handle and use dev_err_probe() helper to return the message.

---
 drivers/soc/qcom/smem.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/soc/qcom/smem.c +15 -11
index 592819701809..5b7626528284 100644
@@ -353,8 +353,12 @@ static void *cached_entry_to_item(struct smem_private_entry *e)
 	return p - le32_to_cpu(e->size);
 }
 
-/* Pointer to the one and only smem handle */
-static struct qcom_smem *__smem;
+/*
+ * Pointer to the one and only smem handle.
+ * Init to -EPROBE_DEFER to signal SMEM still has to be probed.
+ * Can be set to -ENODEV if SMEM is not initialized by SBL.
+ */
+static struct qcom_smem *__smem = INIT_ERR_PTR(-EPROBE_DEFER);
 
 /* Timeout (ms) for the trylock of remote spinlocks */
 #define HWSPINLOCK_TIMEOUT	1000
@@ -508,8 +512,8 @@ int qcom_smem_alloc(unsigned host, unsigned item, size_t size)
 	unsigned long flags;
 	int ret;
 
-	if (!__smem)
-		return -EPROBE_DEFER;
+	if (IS_ERR(__smem))
+		return PTR_ERR(__smem);
 
 	if (item < SMEM_ITEM_LAST_FIXED) {
 		dev_err(__smem->dev,
@@ -685,10 +689,10 @@ static void *qcom_smem_get_private(struct qcom_smem *smem,
 void *qcom_smem_get(unsigned host, unsigned item, size_t *size)
 {
 	struct smem_partition *part;
-	void *ptr = ERR_PTR(-EPROBE_DEFER);
+	void *ptr;
 
-	if (!__smem)
-		return ptr;
+	if (IS_ERR(__smem))
+		return __smem;
 
 	if (WARN_ON(item >= __smem->item_count))
 		return ERR_PTR(-EINVAL);
@@ -723,8 +727,8 @@ int qcom_smem_get_free_space(unsigned host)
 	struct smem_header *header;
 	unsigned ret;
 
-	if (!__smem)
-		return -EPROBE_DEFER;
+	if (IS_ERR(__smem))
+		return PTR_ERR(__smem);
 
 	if (host < SMEM_HOST_COUNT && __smem->partitions[host].virt_base) {
 		part = &__smem->partitions[host];
@@ -1181,8 +1185,8 @@ static int qcom_smem_probe(struct platform_device *pdev)
 	header = smem->regions[0].virt_base;
 	if (le32_to_cpu(header->initialized) != 1 ||
 	    le32_to_cpu(header->reserved)) {
-		dev_err(&pdev->dev, "SMEM is not initialized by SBL\n");
-		return -EINVAL;
+		__smem = ERR_PTR(-ENODEV);
+		return dev_err_probe(&pdev->dev, PTR_ERR(__smem), "SMEM is not initialized by SBL\n");
 	}
 
 	hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0);
Signature · 1 line
2.51.0
#4 lore raw

PATCH v2 3/3 cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to 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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

---
 drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/cpufreq/qcom-cpufreq-nvmem.c +15 -2
index 3a8ed723a23e..5a9bd780a4f3 100644
@@ -257,8 +257,8 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
 					     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 +275,21 @@ 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) {
+		/* Fallback to compatible match with no SMEM initialized */
+		ret = 0;
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;
+	} else if (ret) {
 		goto exit;
+	}
 
 	switch (msm_id) {
 	case QCOM_ID_IPQ8062:
Signature · 1 line
2.51.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro

In reply to Christian Marangi
Quoted 1 line · Christian Marangi

Add INIT_ERR_PTR macro to initialize static variables with error

INIT_ERR_PTR()

Quoted 9 lines

pointers. This might be useful for specific case where there is a static variable initialized to an error condition and then later set to the real handle once probe finish/completes.

This is to handle compilation problems like:

error: initializer element is not constant

where ERR_PTR can't be used.

ERR_PTR()

In case you need a new version, please address the above. Anyways, LGTM now,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to Christian Marangi
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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

...

drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 289

Quoted 9 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +9 -0
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;

A nit-pick (in case you need a new version of the series): I would expect the conditionals be sorted by assigned value.

		if (of_machine_is_compatible("qcom,ipq8062"))
			msm_id = QCOM_ID_IPQ8062;
		else if (of_machine_is_compatible("qcom,ipq8064") ||
			 of_machine_is_compatible("qcom,ipq8066") ||
			 of_machine_is_compatible("qcom,ipq8068"))
			msm_id = QCOM_ID_IPQ8064;
		else if (of_machine_is_compatible("qcom,ipq8065") ||
			 of_machine_is_compatible("qcom,ipq8069"))
			msm_id = QCOM_ID_IPQ8065;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v2 3/3
#10 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to Christian Marangi
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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

FWIW,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to Andy Shevchenko
Quoted 28 lines · Andy Shevchenko
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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

...

drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 289

Quoted 9 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +9 -0
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;

A nit-pick (in case you need a new version of the series): I would expect the conditionals be sorted by assigned value.

Quoted 10 lines
		if (of_machine_is_compatible("qcom,ipq8062"))
			msm_id = QCOM_ID_IPQ8062;
		else if (of_machine_is_compatible("qcom,ipq8064") ||
			 of_machine_is_compatible("qcom,ipq8066") ||
			 of_machine_is_compatible("qcom,ipq8068"))
			msm_id = QCOM_ID_IPQ8064;
		else if (of_machine_is_compatible("qcom,ipq8065") ||
			 of_machine_is_compatible("qcom,ipq8069"))
			msm_id = QCOM_ID_IPQ8065;

Hi as said in the commit, parsing 65/69 before 64 is needed as we might have compatible like

"qcom,ipq8065","qcom,ipq8064" so we might incorrectly parse msm_id ipq8064.

Quoted 5 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Signature · 1 line
	Ansuel
#7 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

Quoted 2 lines · Christian Marangi
Quoted 1 line · Andy Shevchenko

On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:

...

Quoted 24 lines
Quoted 13 lines

drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 289

Quoted 9 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +9 -0
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;

A nit-pick (in case you need a new version of the series): I would expect the conditionals be sorted by assigned value.

Quoted 10 lines
		if (of_machine_is_compatible("qcom,ipq8062"))
			msm_id = QCOM_ID_IPQ8062;
		else if (of_machine_is_compatible("qcom,ipq8064") ||
			 of_machine_is_compatible("qcom,ipq8066") ||
			 of_machine_is_compatible("qcom,ipq8068"))
			msm_id = QCOM_ID_IPQ8064;
		else if (of_machine_is_compatible("qcom,ipq8065") ||
			 of_machine_is_compatible("qcom,ipq8069"))
			msm_id = QCOM_ID_IPQ8065;
Quoted 5 lines

Hi as said in the commit, parsing 65/69 before 64 is needed as we might have compatible like

"qcom,ipq8065","qcom,ipq8064" so we might incorrectly parse msm_id ipq8064.

Oh, this is unfortunate. Wouldn't it be possible to use some API that returns an index (or an error if not found) of the compatible? I believe we have a such for the regular 'compatible' properties.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

Quoted 33 lines · Andy Shevchenko
Quoted 2 lines · Christian Marangi
Quoted 1 line · Andy Shevchenko

On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:

...

Quoted 27 lines
Quoted 13 lines

drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 289

Quoted 9 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +9 -0
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;

A nit-pick (in case you need a new version of the series): I would expect the conditionals be sorted by assigned value.

Quoted 10 lines
		if (of_machine_is_compatible("qcom,ipq8062"))
			msm_id = QCOM_ID_IPQ8062;
		else if (of_machine_is_compatible("qcom,ipq8064") ||
			 of_machine_is_compatible("qcom,ipq8066") ||
			 of_machine_is_compatible("qcom,ipq8068"))
			msm_id = QCOM_ID_IPQ8064;
		else if (of_machine_is_compatible("qcom,ipq8065") ||
			 of_machine_is_compatible("qcom,ipq8069"))
			msm_id = QCOM_ID_IPQ8065;

Hi as said in the commit, parsing 65/69 before 64 is needed as we might have compatible like

Quoted 7 lines
Quoted 2 lines

"qcom,ipq8065","qcom,ipq8064" so we might incorrectly parse msm_id ipq8064.

Oh, this is unfortunate. Wouldn't it be possible to use some API that returns an index (or an error if not found) of the compatible? I believe we have a such for the regular 'compatible' properties.

Well also using something like checking for the virst compatible might be problematic as real device have something like "netgear,r7800", "qcom,ipq8065","qcom,ipq8064".

I will check if I can implement some alternative logic to have consistent order.

Signature · 1 line
	Ansuel
maintainer Reviewed-by on v2 3/3
#11 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to Christian Marangi
Quoted 8 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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Quoted 5 lines

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

And as mentioned in v1, this (cpufreq) patch can be merged independently of the first two patches. So please merge it through the cpufreq tree.

Regards,
Bjorn

Quoted 44 lines
---
 drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/cpufreq/qcom-cpufreq-nvmem.c +15 -2
index 3a8ed723a23e..5a9bd780a4f3 100644
@@ -257,8 +257,8 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
 					     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 +275,21 @@ 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) {
+		/* Fallback to compatible match with no SMEM initialized */
+		ret = 0;
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;
+	} else if (ret) {
 		goto exit;
+	}
 
 	switch (msm_id) {
 	case QCOM_ID_IPQ8062:
Signature · 1 line
2.51.0
maintainer Applied
#14 lore raw

Re: (subset) [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM

In reply to Christian Marangi
Quoted 6 lines · Christian Marangi

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.

Quoted 6 lines

Changes v2:
- Rename error macro to INIT_ERR_PTR
- Return -ENODEV from smem probe
- Restructure if condition in cpufreq driver

[...]

Applied, thanks!

[1/3] err.h: add INIT_ERR_PTR macro

      commit: 652a86b24c5ac444afaf7625c9340d55aab7f105
[2/3] soc: qcom: smem: better track SMEM uninitialized state
      commit: 7a94d5f31b549e18f908cb669c59f066f45a21c7

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>
#9 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to Christian Marangi
Quoted 42 lines · Christian Marangi
Quoted 33 lines · Andy Shevchenko
Quoted 2 lines · Christian Marangi
Quoted 1 line · Andy Shevchenko

On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:

...

Quoted 27 lines
Quoted 13 lines

drivers/cpufreq/qcom-cpufreq-nvmem.c static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev, · line 289

Quoted 9 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +9 -0
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;

A nit-pick (in case you need a new version of the series): I would expect the conditionals be sorted by assigned value.

Quoted 10 lines
		if (of_machine_is_compatible("qcom,ipq8062"))
			msm_id = QCOM_ID_IPQ8062;
		else if (of_machine_is_compatible("qcom,ipq8064") ||
			 of_machine_is_compatible("qcom,ipq8066") ||
			 of_machine_is_compatible("qcom,ipq8068"))
			msm_id = QCOM_ID_IPQ8064;
		else if (of_machine_is_compatible("qcom,ipq8065") ||
			 of_machine_is_compatible("qcom,ipq8069"))
			msm_id = QCOM_ID_IPQ8065;

Hi as said in the commit, parsing 65/69 before 64 is needed as we might have compatible like

Quoted 7 lines
Quoted 2 lines

"qcom,ipq8065","qcom,ipq8064" so we might incorrectly parse msm_id ipq8064.

Oh, this is unfortunate. Wouldn't it be possible to use some API that returns an index (or an error if not found) of the compatible? I believe we have a such for the regular 'compatible' properties.

Quoted 6 lines

Well also using something like checking for the virst compatible might be problematic as real device have something like "netgear,r7800", "qcom,ipq8065","qcom,ipq8064".

I will check if I can implement some alternative logic to have consistent order.

See drivers/soc/qcom/qcom_pd_mapper.c. You can use of_match_node() on the root device.

Signature · 2 lines
With best wishes
Dmitry
#12 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

In reply to Bjorn Andersson
Quoted 13 lines · Bjorn Andersson
Quoted 12 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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

Quoted 7 lines
Quoted 1 line

And as mentioned in v1, this (cpufreq) patch can be merged independently of the first two patches. So please merge it through the cpufreq tree.

I will send a new revision just for this patch so I can use of_match_node()

Should be ok since it hasn't been picked right?

Quoted 45 lines
Quoted 45 lines
---
 drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/cpufreq/qcom-cpufreq-nvmem.c +15 -2
index 3a8ed723a23e..5a9bd780a4f3 100644
@@ -257,8 +257,8 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
 					     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 +275,21 @@ 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) {
+		/* Fallback to compatible match with no SMEM initialized */
+		ret = 0;
+		if (of_machine_is_compatible("qcom,ipq8062"))
+			msm_id = QCOM_ID_IPQ8062;
+		else if (of_machine_is_compatible("qcom,ipq8065") ||
+			 of_machine_is_compatible("qcom,ipq8069"))
+			msm_id = QCOM_ID_IPQ8065;
+		else if (of_machine_is_compatible("qcom,ipq8064") ||
+			 of_machine_is_compatible("qcom,ipq8066") ||
+			 of_machine_is_compatible("qcom,ipq8068"))
+			msm_id = QCOM_ID_IPQ8064;
+	} else if (ret) {
 		goto exit;
+	}
 
 	switch (msm_id) {
 	case QCOM_ID_IPQ8062:
Signature · 1 line
2.51.0
Signature · 1 line
	Ansuel
#13 lore raw

Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM

Quoted 18 lines · Christian Marangi
Quoted 17 lines · Bjorn Andersson
Quoted 8 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_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant.

Quoted 5 lines

Notice that the checking order is important as the machine compatible are normally defined with the specific one following the generic SoC (for example compatible = "qcom,ipq8065", "qcom,ipq8064").

Quoted 8 lines
Quoted 3 lines

And as mentioned in v1, this (cpufreq) patch can be merged independently of the first two patches. So please merge it through the cpufreq tree.

I will send a new revision just for this patch so I can use of_match_node()

Should be ok since it hasn't been picked right?

Yes, this is desired, even

Konrad