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
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
>
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
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
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
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
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
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
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
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
© 2016 - 2026 Red Hat, Inc.