Add modemsmem for Google phones
Subsystems (4)
v4 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 v4:
- Replace dev_err_probe() with dev_err() in q6v5_socinfo_publish(), as it runs from q6v5_start() rather than probe. (Konrad)
- Validate SMEM item sizes returned by qcom_smem_get() for both socinfo and SMEM_ID_VENDOR0. (Konrad)
- Drop alignment padding around '=' in struct modem_smem_info initializer. (Konrad)
- Pick up Reviewed-by tags.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- 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 | 93 ++++++++++++++++++++++ 3 files changed, 104 insertions(+)
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20260906-modemsmem-9a1dc1070f7b
Best regards,
Signature · 1 line
David Heidelberg <[email protected]>
PATCH v4 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
PATCH v4 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 | 93 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)
drivers/remoteproc/qcom_q6v5_mss.c +93 -0
@@ -23,27 +23,36 @@#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 <linux/stddef.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 +256,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 +1678,103 @@ 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; +size_t size; +u32 plat_ver; +int ret; + + socinfo =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_HW_SW_BUILD_ID , &size); +if (IS_ERR (socinfo)) { +dev_err (qproc->dev,"could not get socinfo: %pe\n" , socinfo); +return PTR_ERR (socinfo); + } + + if (size < offsetofend(struct socinfo, hw_plat_subtype)) { +dev_err (qproc->dev,"socinfo item too small: %zu\n" , size); +return -EINVAL ; + } + +/* hw_plat_subtype was added in socinfo format 0.6 */ +if (le32_to_cpu (socinfo->fmt) <SOCINFO_VERSION (0 ,6 )) { +dev_err (qproc->dev,"socinfo format too old\n" ); +return -EOPNOTSUPP ; + } + +/* -EEXIST: the item survived an earlier boot */ + ret =qcom_smem_alloc (QCOM_SMEM_HOST_ANY ,SMEM_ID_VENDOR0 , +sizeof (*info)); +if (ret && ret != -EEXIST ) { +dev_err (qproc->dev,"could not allocate modem smem: %d\n" , ret); +return ret; + } + + info =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_ID_VENDOR0 , &size); +if (IS_ERR (info)) { +dev_err (qproc->dev,"could not get modem smem: %pe\n" , info); +return PTR_ERR (info); + } + +if (size !=sizeof (*info)) { +dev_err (qproc->dev,"modem smem has size %zu, expected %zu\n" , + size,sizeof (*info)); +return -EINVAL ; + } + + 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 +2218,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
PATCH v4 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