#define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
#define to_pdm_subdev(d) container_of(d, struct qcom_rproc_pdm, subdev)
-#define MAX_NUM_OF_SS 10
#define MAX_REGION_NAME_LENGTH 16
#define SBL_MINIDUMP_SMEM_ID 602
#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
__le32 status;
__le32 md_revision;
__le32 enabled;
- struct minidump_subsystem subsystems[MAX_NUM_OF_SS];
+ struct minidump_subsystem subsystems[];
};
struct qcom_ssr_subsystem {
int ret;
struct minidump_subsystem *subsystem;
struct minidump_global_toc *toc;
+ unsigned int num_ss;
+ size_t toc_size;
/* Get Global minidump ToC*/
- toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
+ toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &toc_size);
/* check if global table pointer exists and init is set */
if (IS_ERR(toc) || !toc->status) {
return;
}
+ /* Derive the number of subsystems from the actual SMEM item size */
+ num_ss = (toc_size - offsetof(struct minidump_global_toc, subsystems)) /
+ sizeof(struct minidump_subsystem);
+
+ if (minidump_id >= num_ss) {
+ dev_err(&rproc->dev, "Minidump id %d is out of range: %d\n",
+ minidump_id, num_ss);
+ return;
+ }
+
/* Get subsystem table of contents using the minidump id */
subsystem = &toc->subsystems[minidump_id];