Add modemsmem for Google phones
Subsystems (4)
v3 cover Add modemsmem for Google phones
The modem on the Pixel 3 family will not come up without the SoC information Google's downstream kernel publishes in SMEM item 134. This is the upstream version, modelled per review feedback as a property of the modem remoteproc node rather than a standalone node and driver.
This replaces the standalone drivers/soc/qcom/modemsmem driver from the previous revision: per review feedback the requirement is better modelled as a property of the modem remoteproc node, with the conditional snippet in the remoteproc driver.
Changes in v2:
- Represent the requirement as a "google,require-socinfo" property on the MSS remoteproc node instead of a standalone node and driver. (Bjorn)
- Move the SMEM publish code into the qcom_q6v5_mss remoteproc driver, gated by the property. (Bjorn)
- Hard-code SMEM item id 134, no qcom,smem-id property. (Bjorn, Konrad)
- Drop the RFC prefix.
- Link to v1: https://patch.msgid.link/[email protected]
---
David Heidelberg (3):
dt-bindings: remoteproc: qcom,msm8996-mss-pil: Document google,require-socinfo
remoteproc: qcom_q6v5_mss: Publish socinfo for Pixel modems
arm64: dts: qcom: sdm845-google: Require modem socinfo
.../bindings/remoteproc/qcom,msm8996-mss-pil.yaml | 9 +++ arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi | 2 + drivers/remoteproc/qcom_q6v5_mss.c | 75 ++++++++++++++++++++++ 3 files changed, 86 insertions(+)
---
base-commit: aaa2f954c21b205a0bcd0961e5b2be4e82e58455
change-id: 20260906-modemsmem-9a1dc1070f7b
Best regards,
Signature · 1 line
David Heidelberg <[email protected]>
PATCH v3 1/3 dt-bindings: remoteproc: qcom,msm8996-mss-pil: Document google,require-socinfo
The modem firmware on Google Pixel boards (Pixel 3 through Pixel 5a) expects the application processor to publish the SoC platform type, subtype and revision in the first vendor-reserved SMEM item before the modem is started. Represent that requirement as a boolean property on the MSS remoteproc node so the MSS driver can publish the data before booting the modem, instead of carrying a separate node and driver for it.
This patch was written with assistance from a large language model.
--- .../devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml +9 -0
@@ -91,16 +91,25 @@ properties: - const: mss_restart - const: pdc_reset # only valid for qcom,sdm845-mss-pil minItems: 1 qcom,qmp: $ref: /schemas/types.yaml#/definitions/phandle description: Reference to the AOSS side-channel message RAM. + google,require-socinfo: + type: boolean + description: + The modem firmware on Google Pixel boards (Pixel 3 through Pixel 5a) + expects the application processor to publish the SoC platform type, + subtype and revision in the first vendor-reserved SMEM item (item 134) + before the modem is started. When present, the MSS driver fills that + item from the socinfo SMEM data before booting the modem. + qcom,smem-states: $ref: /schemas/types.yaml#/definitions/phandle-array description: States used by the AP to signal the Hexagon core items: - description: Stop modem items: - description: Phandle to the Shared Memory Point 2 Point or Shared Memory Manager device handling the communication with a remote
Signature · 1 line
2.55.0
Re: [PATCH v3 1/3] dt-bindings: remoteproc: qcom,msm8996-mss-pil: Document google,require-socinfo
Quoted 8 lines · David Heidelberg
The modem firmware on Google Pixel boards (Pixel 3 through Pixel 5a) expects the application processor to publish the SoC platform type, subtype and revision in the first vendor-reserved SMEM item before the modem is started. Represent that requirement as a boolean property on the MSS remoteproc node so the MSS driver can publish the data before booting the modem, instead of carrying a separate node and driver for it.
Quoted 7 lines
This patch was written with assistance from a large language model.
Signed-off-by David Heidelberg <[email protected]>--- .../devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)
PATCH v3 2/3 remoteproc: qcom_q6v5_mss: Publish socinfo for Pixel modems
In reply to David HeidelbergThe modem firmware on Google Pixel boards (Pixel 3 through Pixel 5a) reads the SoC platform type, subtype and revision from the first vendor-reserved SMEM item (item 134) when it boots, and refuses to come up unless the application processor has filled it in.
When the "google,require-socinfo" property is present on the MSS remoteproc node, copy the relevant socinfo fields into that item from the socinfo SMEM data before starting the modem. The SMEM item id and layout are a contract between Google's downstream kernel and the modem firmware rather than hardware, so they are hard-coded in the driver.
The item is written in full: modem_flag, efs_magic and ftm_magic are left zero. Downstream fills modem_flag from a bootloader-provided /chosen/cdt/cdb2 property that is not always present, and the two magic values only matter for factory test mode.
Based on work of: Richard Acayan.
Adapted from the original form using both human & LLM work.
--- drivers/remoteproc/qcom_q6v5_mss.c | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
drivers/remoteproc/qcom_q6v5_mss.c +75 -0
@@ -23,27 +23,35 @@#include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/remoteproc.h> #include <linux/reset.h> #include <linux/soc/qcom/mdt_loader.h> #include <linux/iopoll.h> #include <linux/slab.h> +#include <linux/soc/qcom/smem.h> +#include <linux/soc/qcom/socinfo.h> #include "remoteproc_internal.h" #include "qcom_common.h" #include "qcom_pil_info.h" #include "qcom_q6v5.h" #include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #define MPSS_CRASH_REASON_SMEM 421 +/* +* First vendor-reserved SMEM item; Google's modem firmware reads the SoC +* platform information from it when the modem boots. +*/ +#define SMEM_ID_VENDOR0 134 +#define MBA_LOG_SIZE SZ_4K#define MPSS_PAS_ID 5/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1#define RMB_MBA_XPU_UNLOCKED 0x1
@@ -247,16 +255,17 @@ struct q6v5 {bool need_pas_mem_setup;bool has_alt_reset;bool has_mba_logs;bool has_spare_reg;bool has_qaccept_regs;bool has_ext_bhs_reg;bool has_ext_cntl_regs;bool has_vq6; +bool need_socinfo;u64 mpss_perm;u64 mba_perm;const char *hexagon_mdt_image;int version; };enum {MSS_MDM9607 ,
@@ -1668,22 +1677,86 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size);q6v5_mba_reclaim (qproc); } } } +/* Layout of the vendor-defined SMEM item read by the Pixel modem firmware */ +struct modem_smem_info { +__le32 version; +__le32 modem_flag; +__le32 major_id; +__le32 minor_id; +__le32 subtype; +__le32 platform; +__le32 efs_magic; +__le32 ftm_magic; +}; + +#define MODEM_SMEM_VERSION 0 +#define PLAT_VER_TO_MAJOR_ID (v) (((v) >> 16) & 0xff) +#define PLAT_VER_TO_MINOR_ID (v) ((v) & 0xff) + +static int q6v5_socinfo_publish (struct q6v5 *qproc) +{ +struct modem_smem_info *info; +struct socinfo *socinfo; +u32 plat_ver; +int ret; + + socinfo =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_HW_SW_BUILD_ID ,NULL ); +if (IS_ERR (socinfo)) +return dev_err_probe (qproc->dev,PTR_ERR (socinfo), +"could not get socinfo\n" ); + +/* hw_plat_subtype was added in socinfo format 0.6 */ +if (le32_to_cpu (socinfo->fmt) <SOCINFO_VERSION (0 ,6 )) +return dev_err_probe (qproc->dev, -EOPNOTSUPP , +"socinfo format too old\n" ); + +/* -EEXIST: the item survived an earlier boot */ + ret =qcom_smem_alloc (QCOM_SMEM_HOST_ANY ,SMEM_ID_VENDOR0 ,sizeof (*info)); +if (ret && ret != -EEXIST ) +return dev_err_probe (qproc->dev, ret, +"could not allocate modem smem\n" ); + + info =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_ID_VENDOR0 ,NULL ); +if (IS_ERR (info)) +return dev_err_probe (qproc->dev,PTR_ERR (info), +"could not get modem smem\n" ); + + plat_ver =le32_to_cpu (socinfo->plat_ver); + +/* modem_flag, efs_magic and ftm_magic are left zero */ + *info = (struct modem_smem_info ) { + .version =cpu_to_le32 (MODEM_SMEM_VERSION ), + .major_id =cpu_to_le32 (PLAT_VER_TO_MAJOR_ID (plat_ver)), + .minor_id =cpu_to_le32 (PLAT_VER_TO_MINOR_ID (plat_ver)), + .subtype = socinfo->hw_plat_subtype, + .platform = socinfo->hw_plat, + }; + +return 0 ; +} +static int q6v5_start (struct rproc *rproc) {struct q6v5 *qproc = rproc->priv;int xfermemop_ret;int ret; +if (qproc->need_socinfo) { + ret =q6v5_socinfo_publish (qproc); +if (ret) +return ret; + } + ret =q6v5_mba_load (qproc);if (ret)return ret;dev_info (qproc->dev,"MBA booted with%s debug policy, loading mpss\n" , qproc->dp_size ?"" :"out" ); ret =q6v5_mpss_load (qproc);
@@ -2127,16 +2200,18 @@ static int q6v5_probe(struct platform_device *pdev)platform_set_drvdata (pdev, qproc); qproc->has_qaccept_regs = desc->has_qaccept_regs; qproc->has_ext_bhs_reg = desc->has_ext_bhs_reg; qproc->has_ext_cntl_regs = desc->has_ext_cntl_regs; qproc->has_vq6 = desc->has_vq6; qproc->has_spare_reg = desc->has_spare_reg; + qproc->need_socinfo = +of_property_read_bool (pdev->dev.of_node,"google,require-socinfo" ); ret =q6v5_init_mem (qproc, pdev);if (ret)return ret; ret =q6v5_alloc_memory_region (qproc);if (ret)return ret;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v3 2/3] remoteproc: qcom_q6v5_mss: Publish socinfo for Pixel modems
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] remoteproc: qcom_q6v5_mss: dev_err_probe() used in runtime q6v5_start() It also noticed 1 related…
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] remoteproc: qcom_q6v5_mss: dev_err_probe() used in runtime q6v5_start()
It also noticed 1 related pre-existing issue this patch does not introduce:
- [High] remoteproc: qcom_q6v5_mss: missing need_pas_mem_setup assignment in q6v5_probe() [1]
--
commit b9f47173917266b645cba443348a310e5cf36ef0
Author: David Heidelberg <[email protected]>
remoteproc: qcom_q6v5_mss: Publish socinfo for Pixel modems
This commit publishes SoC platform type, subtype, and revision fields from SMEM socinfo into vendor SMEM item 134 before starting the modem when the "google,require-socinfo" property is present.
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_mss.c +0
-0
[ ... ]
Quoted 63 lines
drivers/remoteproc/qcom_q6v5_mss.c +58
-0@@ -1673,12 +1682,76 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, } } +/* Layout of the vendor-defined SMEM item read by the Pixel modem firmware */ +struct modem_smem_info { +__le32 version; +__le32 modem_flag; +__le32 major_id; +__le32 minor_id; +__le32 subtype; +__le32 platform; +__le32 efs_magic; +__le32 ftm_magic; +}; + +#define MODEM_SMEM_VERSION 0 +#define PLAT_VER_TO_MAJOR_ID (v) (((v) >> 16) & 0xff) +#define PLAT_VER_TO_MINOR_ID (v) ((v) & 0xff) + +static int q6v5_socinfo_publish (struct q6v5 *qproc) +{ +struct modem_smem_info *info; +struct socinfo *socinfo; +u32 plat_ver; +int ret; + + socinfo =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_HW_SW_BUILD_ID ,NULL ); +if (IS_ERR (socinfo)) +return dev_err_probe (qproc->dev,PTR_ERR (socinfo), +"could not get socinfo\n" ); + +/* hw_plat_subtype was added in socinfo format 0.6 */ +if (le32_to_cpu (socinfo->fmt) <SOCINFO_VERSION (0 ,6 )) +return dev_err_probe (qproc->dev, -EOPNOTSUPP , +"socinfo format too old\n" ); + +/* -EEXIST: the item survived an earlier boot */ + ret =qcom_smem_alloc (QCOM_SMEM_HOST_ANY ,SMEM_ID_VENDOR0 ,sizeof (*info)); +if (ret && ret != -EEXIST ) +return dev_err_probe (qproc->dev, ret, +"could not allocate modem smem\n" ); + + info =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_ID_VENDOR0 ,NULL ); +if (IS_ERR (info)) +return dev_err_probe (qproc->dev,PTR_ERR (info), +"could not get modem smem\n" ); + + plat_ver =le32_to_cpu (socinfo->plat_ver); + +/* modem_flag, efs_magic and ftm_magic are left zero */ + *info = (struct modem_smem_info ) { + .version =cpu_to_le32 (MODEM_SMEM_VERSION ), + .major_id =cpu_to_le32 (PLAT_VER_TO_MAJOR_ID (plat_ver)), + .minor_id =cpu_to_le32 (PLAT_VER_TO_MINOR_ID (plat_ver)), + .subtype = socinfo->hw_plat_subtype, + .platform = socinfo->hw_plat, + }; + +return 0 ; +} +static int q6v5_start (struct rproc *rproc)
drivers/remoteproc/qcom_q6v5_mss.c static void qcom_q6v5_dump_segment(struct rproc *rproc, · line 1753
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_mss.c +5
-0{struct q6v5 *qproc = rproc->priv;int xfermemop_ret;int ret; +if (qproc->need_socinfo) { + ret =q6v5_socinfo_publish (qproc); +if (ret) +return ret; + }
[Severity: Medium]
Should q6v5_socinfo_publish() use dev_err() instead of dev_err_probe(), or be called from q6v5_probe()?
Because q6v5_probe() sets rproc->auto_boot = false, q6v5_start() -> q6v5_socinfo_publish() only runs at runtime when the remoteproc is booted or recovered. If qcom_smem_get() or qcom_smem_alloc() returns -EPROBE_DEFER at that point (q6v5_probe() does not check qcom_smem_is_available()), dev_err_probe() demotes the log to debug level, returns -EPROBE_DEFER to rproc_boot(), and allocates qproc->dev->p->deferred_probe_reason, which is leaked because the already-bound device is never placed on deferred_probe_pending_list. If qcom_smem_alloc() returns -ENOMEM when the SMEM heap is full, dev_err_probe() also suppresses the error message.
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_probe(struct platform_device *pdev) · line 2212
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_mss.c +2
-0@@ -2132,6 +2205,8 @@ static int q6v5_probe(struct platform_device *pdev) qproc->has_ext_cntl_regs = desc->has_ext_cntl_regs; qproc->has_vq6 = desc->has_vq6; qproc->has_spare_reg = desc->has_spare_reg; + qproc->need_socinfo = +of_property_read_bool (pdev->dev.of_node,"google,require-socinfo" ); ret =q6v5_init_mem (qproc, pdev);if (ret)return ret;
[Severity: High]
This problem wasn't introduced by this patch, but does q6v5_probe() forget to copy desc->need_pas_mem_setup into qproc->need_pas_mem_setup [1]?
q6v5_probe() checks desc->need_pas_mem_setup for early probe deferral, but never assigns it to qproc:
drivers/remoteproc/qcom_q6v5_mss.c:q6v5_probe() {
...
if (desc->need_pas_mem_setup && !qcom_pas_is_available())
return -EPROBE_DEFER;
...
qproc->version = desc->version;
qproc->need_mem_protection = desc->need_mem_protection;
qproc->has_mba_logs = desc->has_mba_logs;
...
}As a result, qproc->need_pas_mem_setup stays false in q6v5_mpss_init_image() and qcom_scm_pas_mem_setup() is skipped on platforms that set need_pas_mem_setup (such as SDM632), preventing the modem from authenticating and booting.
[1] https://sashiko.dev/#/bug/linux-83fcbc28-236c-48e4-a6bd-731f4361f9ae
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v3 3/3 arm64: dts: qcom: sdm845-google: Require modem socinfo
In reply to David HeidelbergThe modem firmware on the Google Pixel 3 and Pixel 3 XL reads the SoC platform information from the first vendor-reserved SMEM item before booting. Add the google,require-socinfo property to the MSS remoteproc node so the MSS driver publishes it.
--- arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi +2 -0
@@ -426,16 +426,18 @@ &ipa { &mdss { status = "okay"; }; &mss_pil { firmware-name = "qcom/sdm845/Google/blueline/mba.mbn", "qcom/sdm845/Google/blueline/modem.mbn"; + google,require-socinfo; + status = "okay"; }; &pm8998_gpios { volume_up_gpio: vol-up-active-state { pins = "gpio6"; function = "normal"; input-enable;
Signature · 1 line
2.55.0