* [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro
2025-10-31 13:08 [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM Christian Marangi
@ 2025-10-31 13:08 ` Christian Marangi
2025-10-31 13:23 ` Andy Shevchenko
2025-10-31 13:08 ` [PATCH v2 2/3] soc: qcom: smem: better track SMEM uninitialized state Christian Marangi
` (2 subsequent siblings)
3 siblings, 1 reply; 15+ messages in thread
From: Christian Marangi @ 2025-10-31 13:08 UTC (permalink / raw)
To: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Andy Shevchenko, Christian Marangi,
Raag Jadav, linux-arm-msm, linux-pm, linux-kernel
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.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
include/linux/err.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/err.h b/include/linux/err.h
index 1d60aa86db53..8c37be0620ab 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -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))
--
2.51.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro
2025-10-31 13:08 ` [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro Christian Marangi
@ 2025-10-31 13:23 ` Andy Shevchenko
0 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2025-10-31 13:23 UTC (permalink / raw)
To: Christian Marangi
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Raag Jadav, linux-arm-msm, linux-pm,
linux-kernel
On Fri, Oct 31, 2025 at 02:08:32PM +0100, Christian Marangi wrote:
> Add INIT_ERR_PTR macro to initialize static variables with error
INIT_ERR_PTR()
> 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,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 2/3] soc: qcom: smem: better track SMEM uninitialized state
2025-10-31 13:08 [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM Christian Marangi
2025-10-31 13:08 ` [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro Christian Marangi
@ 2025-10-31 13:08 ` Christian Marangi
2025-10-31 13:08 ` [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Christian Marangi
2025-11-02 18:09 ` (subset) [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with " Bjorn Andersson
3 siblings, 0 replies; 15+ messages in thread
From: Christian Marangi @ 2025-10-31 13:08 UTC (permalink / raw)
To: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Andy Shevchenko, Christian Marangi,
Raag Jadav, linux-arm-msm, linux-pm, linux-kernel
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.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/soc/qcom/smem.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index 592819701809..5b7626528284 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -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);
--
2.51.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 13:08 [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM Christian Marangi
2025-10-31 13:08 ` [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro Christian Marangi
2025-10-31 13:08 ` [PATCH v2 2/3] soc: qcom: smem: better track SMEM uninitialized state Christian Marangi
@ 2025-10-31 13:08 ` Christian Marangi
2025-10-31 13:26 ` Andy Shevchenko
` (2 more replies)
2025-11-02 18:09 ` (subset) [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with " Bjorn Andersson
3 siblings, 3 replies; 15+ messages in thread
From: Christian Marangi @ 2025-10-31 13:08 UTC (permalink / raw)
To: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Andy Shevchenko, Christian Marangi,
Raag Jadav, linux-arm-msm, linux-pm, linux-kernel
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").
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
index 3a8ed723a23e..5a9bd780a4f3 100644
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -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:
--
2.51.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 13:08 ` [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Christian Marangi
@ 2025-10-31 13:26 ` Andy Shevchenko
2025-10-31 14:19 ` Christian Marangi
2025-10-31 13:27 ` Andy Shevchenko
2025-11-01 17:42 ` Bjorn Andersson
2 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2025-10-31 13:26 UTC (permalink / raw)
To: Christian Marangi
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Raag Jadav, linux-arm-msm, linux-pm,
linux-kernel
On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
> 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").
...
> + 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;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 13:26 ` Andy Shevchenko
@ 2025-10-31 14:19 ` Christian Marangi
2025-10-31 14:34 ` Andy Shevchenko
0 siblings, 1 reply; 15+ messages in thread
From: Christian Marangi @ 2025-10-31 14:19 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Raag Jadav, linux-arm-msm, linux-pm,
linux-kernel
On Fri, Oct 31, 2025 at 03:26:46PM +0200, Andy Shevchenko wrote:
> On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
> > 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").
>
> ...
>
> > + 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;
>
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.
> --
> With Best Regards,
> Andy Shevchenko
>
>
--
Ansuel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 14:19 ` Christian Marangi
@ 2025-10-31 14:34 ` Andy Shevchenko
2025-11-01 11:50 ` Christian Marangi
0 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2025-10-31 14:34 UTC (permalink / raw)
To: Christian Marangi
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Raag Jadav, linux-arm-msm, linux-pm,
linux-kernel
On Fri, Oct 31, 2025 at 03:19:12PM +0100, Christian Marangi wrote:
> On Fri, Oct 31, 2025 at 03:26:46PM +0200, Andy Shevchenko wrote:
> > On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
...
> > > + 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;
> >
>
> 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.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 14:34 ` Andy Shevchenko
@ 2025-11-01 11:50 ` Christian Marangi
2025-11-02 20:23 ` Dmitry Baryshkov
0 siblings, 1 reply; 15+ messages in thread
From: Christian Marangi @ 2025-11-01 11:50 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Raag Jadav, linux-arm-msm, linux-pm,
linux-kernel
On Fri, Oct 31, 2025 at 04:34:22PM +0200, Andy Shevchenko wrote:
> On Fri, Oct 31, 2025 at 03:19:12PM +0100, Christian Marangi wrote:
> > On Fri, Oct 31, 2025 at 03:26:46PM +0200, Andy Shevchenko wrote:
> > > On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
>
> ...
>
> > > > + 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;
> > >
> >
> > 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.
>
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.
--
Ansuel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-11-01 11:50 ` Christian Marangi
@ 2025-11-02 20:23 ` Dmitry Baryshkov
0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Baryshkov @ 2025-11-02 20:23 UTC (permalink / raw)
To: Christian Marangi
Cc: Andy Shevchenko, Ilia Lin, Rafael J. Wysocki, Viresh Kumar,
Bjorn Andersson, Konrad Dybcio, Arnd Bergmann, Raag Jadav,
linux-arm-msm, linux-pm, linux-kernel
On Sat, Nov 01, 2025 at 12:50:09PM +0100, Christian Marangi wrote:
> On Fri, Oct 31, 2025 at 04:34:22PM +0200, Andy Shevchenko wrote:
> > On Fri, Oct 31, 2025 at 03:19:12PM +0100, Christian Marangi wrote:
> > > On Fri, Oct 31, 2025 at 03:26:46PM +0200, Andy Shevchenko wrote:
> > > > On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
> >
> > ...
> >
> > > > > + 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;
> > > >
> > >
> > > 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.
> >
>
> 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.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 13:08 ` [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Christian Marangi
2025-10-31 13:26 ` Andy Shevchenko
@ 2025-10-31 13:27 ` Andy Shevchenko
2025-11-01 17:42 ` Bjorn Andersson
2 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2025-10-31 13:27 UTC (permalink / raw)
To: Christian Marangi
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Bjorn Andersson,
Konrad Dybcio, Arnd Bergmann, Raag Jadav, linux-arm-msm, linux-pm,
linux-kernel
On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
> 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,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-10-31 13:08 ` [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Christian Marangi
2025-10-31 13:26 ` Andy Shevchenko
2025-10-31 13:27 ` Andy Shevchenko
@ 2025-11-01 17:42 ` Bjorn Andersson
2025-11-04 11:59 ` Christian Marangi
2 siblings, 1 reply; 15+ messages in thread
From: Bjorn Andersson @ 2025-11-01 17:42 UTC (permalink / raw)
To: Christian Marangi
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Konrad Dybcio,
Arnd Bergmann, Andy Shevchenko, Raag Jadav, linux-arm-msm,
linux-pm, linux-kernel
On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
> 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").
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
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
> ---
> drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
> index 3a8ed723a23e..5a9bd780a4f3 100644
> --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
> +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
> @@ -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:
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-11-01 17:42 ` Bjorn Andersson
@ 2025-11-04 11:59 ` Christian Marangi
2025-11-04 12:13 ` Konrad Dybcio
0 siblings, 1 reply; 15+ messages in thread
From: Christian Marangi @ 2025-11-04 11:59 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Konrad Dybcio,
Arnd Bergmann, Andy Shevchenko, Raag Jadav, linux-arm-msm,
linux-pm, linux-kernel
On Sat, Nov 01, 2025 at 12:42:55PM -0500, Bjorn Andersson wrote:
> On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
> > 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").
> >
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
>
> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
>
> 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?
>
> > ---
> > drivers/cpufreq/qcom-cpufreq-nvmem.c | 17 +++++++++++++++--
> > 1 file changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
> > index 3a8ed723a23e..5a9bd780a4f3 100644
> > --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
> > +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
> > @@ -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:
> > --
> > 2.51.0
> >
--
Ansuel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
2025-11-04 11:59 ` Christian Marangi
@ 2025-11-04 12:13 ` Konrad Dybcio
0 siblings, 0 replies; 15+ messages in thread
From: Konrad Dybcio @ 2025-11-04 12:13 UTC (permalink / raw)
To: Christian Marangi, Bjorn Andersson
Cc: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Konrad Dybcio,
Arnd Bergmann, Andy Shevchenko, Raag Jadav, linux-arm-msm,
linux-pm, linux-kernel
On 11/4/25 12:59 PM, Christian Marangi wrote:
> On Sat, Nov 01, 2025 at 12:42:55PM -0500, Bjorn Andersson wrote:
>> On Fri, Oct 31, 2025 at 02:08:34PM +0100, Christian Marangi wrote:
>>> 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").
>>>
>>> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
>>
>> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
>>
>> 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: (subset) [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM
2025-10-31 13:08 [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM Christian Marangi
` (2 preceding siblings ...)
2025-10-31 13:08 ` [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Christian Marangi
@ 2025-11-02 18:09 ` Bjorn Andersson
3 siblings, 0 replies; 15+ messages in thread
From: Bjorn Andersson @ 2025-11-02 18:09 UTC (permalink / raw)
To: Ilia Lin, Rafael J. Wysocki, Viresh Kumar, Konrad Dybcio,
Arnd Bergmann, Andy Shevchenko, Raag Jadav, linux-arm-msm,
linux-pm, linux-kernel, Christian Marangi
On Fri, 31 Oct 2025 14:08:31 +0100, Christian Marangi wrote:
> 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
>
> [...]
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,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 15+ messages in thread