Add modem debug features
Subsystems (2)
cover Add modem debug features
The series adds support for the following modem debug features:
* Modem debug policy which enables coredumps/live debug on secure devices
* MBA text logs extraction on SC7180 SoCs
Sibi Sankar (3):
remoteproc: qcom_q6v5_mss: Add modem debug policy support
remoteproc: qcom_q6v5_mss: Add MBA log extraction support
remoteproc: qcom_q6v5_mss: Update MBA log info
drivers/remoteproc/qcom_q6v5_mss.c | 59 +++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 1/3 remoteproc: qcom_q6v5_mss: Add modem debug policy support
Add modem debug policy support which will enable coredumps and live debug support when the msadp firmware is present on secure devices.
--- drivers/remoteproc/qcom_q6v5_mss.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_q6v5_mss.c +14 -1
@@ -187,6 +187,7 @@ struct q6v5 {phys_addr_t mba_phys;void *mba_region;size_t mba_size; +size_t dp_size;phys_addr_t mpss_phys;phys_addr_t mpss_reloc;
@@ -406,6 +407,13 @@ static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,static int q6v5_load (struct rproc *rproc,const struct firmware *fw) {struct q6v5 *qproc = rproc->priv; +const struct firmware *dp_fw; + +if (!request_firmware (&dp_fw,"msadp" , qproc->dev) && fw->size <=SZ_1M ) { +memcpy (qproc->mba_region +SZ_1M , dp_fw->data, dp_fw->size); + qproc->dp_size = dp_fw->size; +release_firmware (dp_fw); + }memcpy (qproc->mba_region, fw->data, fw->size);
@@ -896,6 +904,10 @@ static int q6v5_mba_load(struct q6v5 *qproc) }writel (qproc->mba_phys, qproc->rmb_base +RMB_MBA_IMAGE_REG ); +if (qproc->dp_size) { +writel (qproc->mba_phys +SZ_1M , qproc->rmb_base +RMB_PMI_CODE_START_REG ); +writel (qproc->dp_size, qproc->rmb_base +RMB_PMI_CODE_LENGTH_REG ); + } ret =q6v5proc_reset (qproc);if (ret)
@@ -1258,7 +1270,8 @@ static int q6v5_start(struct rproc *rproc)if (ret)return ret; -dev_info (qproc->dev,"MBA booted, loading mpss\n" ); +dev_info (qproc->dev,"MBA booted, debug policy %s, loading mpss\n" , + qproc->dp_size ?"enabled" :"disabled" ); ret =q6v5_mpss_load (qproc);if (ret)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 1/3] remoteproc: qcom_q6v5_mss: Add modem debug policy support
Quoted 21 lines · Sibi Sankar
Add modem debug policy support which will enable coredumps and live debug support when the msadp firmware is present on secure devices.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -187,6 +187,7 @@ struct q6v5 {phys_addr_t mba_phys;void *mba_region;size_t mba_size; +size_t dp_size;phys_addr_t mpss_phys;phys_addr_t mpss_reloc;
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm, · line 412
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_mss.c +3
-0@@ -406,6 +407,13 @@ static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,static int q6v5_load (struct rproc *rproc,const struct firmware *fw) {struct q6v5 *qproc = rproc->priv; +const struct firmware *dp_fw; + +if (!request_firmware (&dp_fw,"msadp" , qproc->dev) && fw->size <=SZ_1M ) {
Can we change this to a request_firmware_direct() to avoid the fact that as written here devices lacking this file will pause here for 60 seconds waiting for userspace to assist in loading it (which at least none of my systems do).
I also think that while it's nice to check that fw->size <= SZ_1M, to avoid overwriting the tail of it, you should check that SZ_1M + dp_fw->size < mba_size. To ensure that the memcpy doesn't go out of bounds.
Quoted 19 lines
drivers/remoteproc/qcom_q6v5_mss.c +8
-0+memcpy (qproc->mba_region +SZ_1M , dp_fw->data, dp_fw->size); + qproc->dp_size = dp_fw->size; +release_firmware (dp_fw); + }memcpy (qproc->mba_region, fw->data, fw->size);@@ -896,6 +904,10 @@ static int q6v5_mba_load(struct q6v5 *qproc) }writel (qproc->mba_phys, qproc->rmb_base +RMB_MBA_IMAGE_REG ); +if (qproc->dp_size) { +writel (qproc->mba_phys +SZ_1M , qproc->rmb_base +RMB_PMI_CODE_START_REG ); +writel (qproc->dp_size, qproc->rmb_base +RMB_PMI_CODE_LENGTH_REG ); + } ret =q6v5proc_reset (qproc);if (ret)
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_start(struct rproc *rproc) · line 1274
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_mss.c +2
-1@@ -1258,7 +1270,8 @@ static int q6v5_start(struct rproc *rproc)if (ret)return ret; -dev_info (qproc->dev,"MBA booted, loading mpss\n" ); +dev_info (qproc->dev,"MBA booted, debug policy %s, loading mpss\n" , + qproc->dp_size ?"enabled" :"disabled" );
"MBA booted with%s debug policy, loading mpss\n", qproc->dp_size ? "" : "out"
Please.
Regards,
Bjorn
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_mss.c +0
-1ret =q6v5_mpss_load (qproc);if (ret) --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 1/3] remoteproc: qcom_q6v5_mss: Add modem debug policy support
Hey Bjorn,
Thanks for taking time to review
the series.
Quoted 37 lines · Bjorn Andersson
Quoted 21 lines · Sibi Sankar
Add modem debug policy support which will enable coredumps and live debug support when the msadp firmware is present on secure devices.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -187,6 +187,7 @@ struct q6v5 {phys_addr_t mba_phys;void *mba_region;size_t mba_size; +size_t dp_size;phys_addr_t mpss_phys;phys_addr_t mpss_reloc;drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_xfer_mem_ownership(struct q6v5 · line 414
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_mss.c +3
-0@@ -406,6 +407,13 @@ static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm, static int q6v5_load(struct rproc *rproc, const struct firmware *fw) {struct q6v5 *qproc = rproc->priv; +const struct firmware *dp_fw; + +if (!request_firmware (&dp_fw,"msadp" , qproc->dev) && fw->size <=SZ_1M ) {Can we change this to a
request_firmware_direct()to avoid the fact that as written here devices lacking this file will pause here for 60 seconds waiting for userspace to assist in loading it (which at least none of my systems do).
Quoted 4 lines
I also think that while it's nice to check that
fw->size<=SZ_1M, to avoid overwriting the tail of it, you should check thatSZ_1M+dp_fw->size<mba_size. To ensure that the memcpy doesn't go out of bounds.
Sure I'll get ^^ done in the
next re-spin.
Quoted 24 lines
Quoted 24 lines
drivers/remoteproc/qcom_q6v5_mss.c +4
-0+memcpy (qproc->mba_region +SZ_1M , dp_fw->data, dp_fw->size); + qproc->dp_size = dp_fw->size; +release_firmware (dp_fw); + }drivers/remoteproc/qcom_q6v5_mss.c +4
-0memcpy (qproc->mba_region, fw->data, fw->size);@@ -896,6 +904,10 @@ static int q6v5_mba_load(struct q6v5 *qproc) }writel (qproc->mba_phys, qproc->rmb_base +RMB_MBA_IMAGE_REG ); +if (qproc->dp_size) { +writel (qproc->mba_phys +SZ_1M , qproc->rmb_base +RMB_PMI_CODE_START_REG ); +writel (qproc->dp_size, qproc->rmb_base +RMB_PMI_CODE_LENGTH_REG ); + } ret =q6v5proc_reset (qproc);drivers/remoteproc/qcom_q6v5_mss.c +0
-0if (ret)@@ -1258,7 +1270,8 @@ static int q6v5_start(struct rproc *rproc)if (ret)return ret;
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_start(struct rproc *rproc) · line 1274
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_mss.c +2
-1-dev_info (qproc->dev,"MBA booted, loading mpss\n" ); +dev_info (qproc->dev,"MBA booted, debug policy %s, loading mpss\n" , + qproc->dp_size ?"enabled" :"disabled" );"MBA booted with%s debug policy, loading mpss\n",
qproc->dp_size? "" : "out"Please.
Sure I'll use your template instead.
Quoted 11 lines
Regards,
BjornQuoted 7 lines
drivers/remoteproc/qcom_q6v5_mss.c +0
-1ret =q6v5_mpss_load (qproc);if (ret) --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH 2/3 remoteproc: qcom_q6v5_mss: Add MBA log extraction support
In reply to Sibi SankarOn SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +36 -5
@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h>
@@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1
@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };
@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;
@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)return val; } +static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE ); +if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {u32 val;
@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);
@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, false, qproc->mba_phys,
@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:
@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;
@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret); +if (qproc->has_mba_logs && err_path && !ret) +q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,
@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } } }
@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }
@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }
@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret =qcom_q6v5_init (&qproc->q6v5, pdev, rproc,MPSS_CRASH_REASON_SMEM , qcom_msa_handover);
@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180, };
@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845, };
@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998, };
@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996, };
@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916, };
@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974, };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/3] remoteproc: qcom_q6v5_mss: Add MBA log extraction support
Hi Sibi,
Quoted 47 lines · Sibi Sankar
On SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/remoteproc/qcom_q6v5_mss.c +5
-0@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 531
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_mss.c +6
-0@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)return val; } +static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE );
Is there any specific reason to use vmalloc for the size of 4K?
Thanks,
Mani
Quoted 142 lines
drivers/remoteproc/qcom_q6v5_mss.c +25
-5+if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {u32 val;@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, false, qproc->mba_phys,@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret); +if (qproc->has_mba_logs && err_path && !ret) +q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } } }@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret =qcom_q6v5_init (&qproc->q6v5, pdev, rproc,MPSS_CRASH_REASON_SMEM , qcom_msa_handover);@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180, };@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845, };@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998, };@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996, };@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916, };@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974, };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/3] remoteproc: qcom_q6v5_mss: Add MBA log extraction support
Quoted 55 lines · Manivannan Sadhasivam
Hi Sibi,
Quoted 52 lines · Sibi Sankar
On SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/remoteproc/qcom_q6v5_mss.c +5
-0@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) return val; }
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 531
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_mss.c +6
-0+static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE );Is there any specific reason to use vmalloc for the size of 4K?
data is passed onto dev_coredumpv
which takes ownership of the memory
and would eventually do a vfree of the
data.
Quoted 156 lines
Thanks,
ManiQuoted 152 lines
drivers/remoteproc/qcom_q6v5_mss.c +7
-0+if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {drivers/remoteproc/qcom_q6v5_mss.c +2
-1u32 val;@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,drivers/remoteproc/qcom_q6v5_mss.c +7
-2false, qproc->mba_phys,@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret); +if (qproc->has_mba_logs && err_path && !ret) +q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } }}
drivers/remoteproc/qcom_q6v5_mss.c +3
-2@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc,
MPSS_CRASH_REASON_SMEM,drivers/remoteproc/qcom_q6v5_mss.c +1
-0qcom_msa_handover);@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974,};
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH 2/3] remoteproc: qcom_q6v5_mss: Add MBA log extraction support
Quoted 66 lines · Sibi Sankar
Quoted 56 lines · Manivannan Sadhasivam
Hi Sibi,
Quoted 53 lines · Sibi Sankar
On SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/remoteproc/qcom_q6v5_mss.c +5
-0@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)return val; }Quoted 8 lines
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 531
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_mss.c +6
-0+static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE );Is there any specific reason to use vmalloc for the size of 4K?
Quoted 5 lines
data is passed onto
dev_coredumpv
which takes ownership of the memory
and would eventually do a vfree of the
data.
Ah, okay.
Thanks,
Mani
Quoted 161 lines
Quoted 157 lines
Thanks,
ManiQuoted 153 lines
drivers/remoteproc/qcom_q6v5_mss.c +7
-0+if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {drivers/remoteproc/qcom_q6v5_mss.c +2
-1u32 val;@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,drivers/remoteproc/qcom_q6v5_mss.c +7
-2false, qproc->mba_phys,@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret); +if (qproc->has_mba_logs && err_path && !ret) +q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } }}
drivers/remoteproc/qcom_q6v5_mss.c +3
-2@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc,
MPSS_CRASH_REASON_SMEM,drivers/remoteproc/qcom_q6v5_mss.c +1
-0qcom_msa_handover);@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974,};
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative ProjectSignature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH 2/3] remoteproc: qcom_q6v5_mss: Add MBA log extraction support
In reply to Sibi SankarQuoted 102 lines · Sibi Sankar
On SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/remoteproc/qcom_q6v5_mss.c +23
-2@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)return val; } +static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE ); +if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {u32 val;@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, false, qproc->mba_phys,@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;
drivers/remoteproc/qcom_q6v5_mss.c static void q6v5_mba_reclaim(struct q6v5 *qproc) · line 1030
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret); +if (qproc->has_mba_logs && err_path && !ret)
Wouldn't it be possible to just call q6v5_dump_mba_logs() directly after the return from q6v5_mba_reclaim()? That way we can avoid passing the bool to indicate if the reclaim should also dump some stuff.
Sure we don't have a way to tell if the assign_mem failed, but we're going to crash shortly anyways (which is something we should change).
I think you should move the has_mba_logs into q6v5_dump_mba_logs(), making it cause an early return.
Regards,
Bjorn
Quoted 92 lines
drivers/remoteproc/qcom_q6v5_mss.c +12
-3+q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } } }@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret =qcom_q6v5_init (&qproc->q6v5, pdev, rproc,MPSS_CRASH_REASON_SMEM , qcom_msa_handover);@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180, };@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845, };@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998, };@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996, };@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916, };@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974, };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/3] remoteproc: qcom_q6v5_mss: Add MBA log extraction support
Quoted 110 lines · Bjorn Andersson
Quoted 108 lines · Sibi Sankar
On SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/remoteproc/qcom_q6v5_mss.c +18
-0@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) return val; } +static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE ); +if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {drivers/remoteproc/qcom_q6v5_mss.c +2
-1u32 val;@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,drivers/remoteproc/qcom_q6v5_mss.c +3
-1false, qproc->mba_phys,@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret);
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_mss.c static void q6v5_mba_reclaim(struct q6v5 *qproc) · line 1030
Quoted 1 line
drivers/remoteproc/qcom_q6v5_mss.c +1
-0+if (qproc->has_mba_logs && err_path && !ret)Wouldn't it be possible to just call
q6v5_dump_mba_logs()directly after the return fromq6v5_mba_reclaim()? That way we can avoid passing the bool to indicate if the reclaim should also dump some stuff.Sure we don't have a way to tell if the
assign_memfailed, but we're going to crash shortly anyways (which is something we should change).
We wont crash as long as we dont touch
the mba region though. Trying a mba
logs dump in such a case will ensure
that we crash lol.
Quoted 5 lines
I think you should move the
has_mba_logsintoq6v5_dump_mba_logs(), making it cause an early return.
cool sure I'll do that.
Quoted 105 lines
Regards,
BjornQuoted 101 lines
drivers/remoteproc/qcom_q6v5_mss.c +3
-1+q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } }}
drivers/remoteproc/qcom_q6v5_mss.c +3
-2@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc,
MPSS_CRASH_REASON_SMEM,drivers/remoteproc/qcom_q6v5_mss.c +1
-0qcom_msa_handover);@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974,};
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH 2/3] remoteproc: qcom_q6v5_mss: Add MBA log extraction support
Quoted 118 lines · Sibi Sankar
Quoted 117 lines · Bjorn Andersson
Quoted 106 lines · Sibi Sankar
On SC7180 the MBA firmware stores the bootup text logs in a 4K segment at the beginning of the MBA region. Add support to extract the logs which will be useful to debug mba boot/authentication issues.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/remoteproc/qcom_q6v5_mss.c +18
-0@@ -9,6 +9,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/devcoredump.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -37,6 +38,8 @@#define MPSS_CRASH_REASON_SMEM 421 +#define MBA_LOG_SIZE SZ_4K +/* RMB Status Register Values */ #define RMB_PBL_SUCCESS 0x1@@ -139,6 +142,7 @@ struct rproc_hexagon_res {int version;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg; };@@ -200,6 +204,7 @@ struct q6v5 {struct qcom_sysmon *sysmon;bool need_mem_protection;bool has_alt_reset; +bool has_mba_logs;bool has_spare_reg;int mpss_perm;int mba_perm;@@ -518,6 +523,19 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)return val; } +static void q6v5_dump_mba_logs (struct q6v5 *qproc) +{ +struct rproc *rproc = qproc->rproc; +void *data; + + data =vmalloc (MBA_LOG_SIZE ); +if (!data) +return ; + +memcpy (data, qproc->mba_region,MBA_LOG_SIZE ); +dev_coredumpv (&rproc->dev, data,MBA_LOG_SIZE ,GFP_KERNEL ); +} +static int q6v5proc_reset (struct q6v5 *qproc) {drivers/remoteproc/qcom_q6v5_mss.c +2
-1u32 val;@@ -838,6 +856,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) {int ret;int xfermemop_ret; +bool mba_load_err = false;qcom_q6v5_prepare (&qproc->q6v5);@@ -931,7 +950,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - + mba_load_err = true; reclaim_mba: xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,drivers/remoteproc/qcom_q6v5_mss.c +3
-1false, qproc->mba_phys,@@ -939,6 +958,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (xfermemop_ret) {dev_err (qproc->dev,"Failed to reclaim mba buffer, system may become unstable\n" ); + }else if (qproc->has_mba_logs & mba_load_err) { +q6v5_dump_mba_logs (qproc); } disable_active_clks:@@ -968,7 +989,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)return ret; } -static void q6v5_mba_reclaim (struct q6v5 *qproc) +static void q6v5_mba_reclaim (struct q6v5 *qproc,bool err_path) {int ret;u32 val;drivers/remoteproc/qcom_q6v5_mss.c static void q6v5_mba_reclaim(struct q6v5 *qproc) · line 1030
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1006,6 +1027,9 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->mba_size);WARN_ON (ret); +if (qproc->has_mba_logs && err_path && !ret)Wouldn't it be possible to just call
q6v5_dump_mba_logs()directly after the return fromq6v5_mba_reclaim()? That way we can avoid passing the bool to indicate if the reclaim should also dump some stuff.
Quoted 8 lines
Quoted 2 lines
Sure we don't have a way to tell if the
assign_memfailed, but we're going to crash shortly anyways (which is something we should change).We wont crash as long as we dont touch
the mba region though. Trying a mba
logs dump in such a case will ensure
that we crash lol.
Right, but that means that if we ever try to start the remoteproc again it will crash on us.
So what I meant at the end there is that we should either have a mechanism to ensure that no further accesses are attempted (e.g. prohibit a subsequent "start") or this might actually be a valid case for a BUG_ON().
Regards,
Bjorn
Quoted 118 lines
Quoted 5 lines
I think you should move the
has_mba_logsintoq6v5_dump_mba_logs(), making it cause an early return.cool sure I'll do that.
Quoted 106 lines
Regards,
BjornQuoted 102 lines
drivers/remoteproc/qcom_q6v5_mss.c +3
-1+q6v5_dump_mba_logs (qproc); + ret =qcom_q6v5_unprepare (&qproc->q6v5);if (ret) { q6v5_pds_disable(qproc, qproc->proxy_pds,@@ -1255,7 +1279,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, false, true, qproc->mpss_phys, qproc->mpss_size); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false); } }}
drivers/remoteproc/qcom_q6v5_mss.c +3
-2@@ -1297,7 +1321,7 @@ static int q6v5_start(struct rproc *rproc)return 0 ; reclaim_mpss: -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, true);return ret; }@@ -1313,7 +1337,7 @@ static int q6v5_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (qproc->dev,"timed out on wait\n" ); -q6v5_mba_reclaim (qproc); +q6v5_mba_reclaim (qproc, false);return 0 ; }@@ -1717,6 +1741,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; + qproc->has_mba_logs = desc->has_mba_logs; ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc,
MPSS_CRASH_REASON_SMEM,drivers/remoteproc/qcom_q6v5_mss.c +1
-0qcom_msa_handover);@@ -1808,6 +1833,7 @@ static const struct rproc_hexagon_res sc7180_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = true, .has_spare_reg = true, .version = MSS_SC7180,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1843,6 +1869,7 @@ static const struct rproc_hexagon_res sdm845_mss = { }, .need_mem_protection = true, .has_alt_reset = true, + .has_mba_logs = true, .has_spare_reg = false, .version = MSS_SDM845,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1870,6 +1897,7 @@ static const struct rproc_hexagon_res msm8998_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8998,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1900,6 +1928,7 @@ static const struct rproc_hexagon_res msm8996_mss = { }, .need_mem_protection = true, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8996,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1933,6 +1962,7 @@ static const struct rproc_hexagon_res msm8916_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8916,};
drivers/remoteproc/qcom_q6v5_mss.c +1
-0@@ -1974,6 +2004,7 @@ static const struct rproc_hexagon_res msm8974_mss = { }, .need_mem_protection = false, .has_alt_reset = false, + .has_mba_logs = false, .has_spare_reg = false, .version = MSS_MSM8974,};
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative ProjectSignature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH 3/3 remoteproc: qcom_q6v5_mss: Update MBA log info
In reply to Sibi SankarUpdate MBA text logs location/size in IMEM to aid tools extract them after ramdump collection.
--- drivers/remoteproc/qcom_q6v5_mss.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/qcom_q6v5_mss.c +3 -0
@@ -932,6 +932,9 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (ret) goto reclaim_mba; +if (qproc->has_mba_logs) +qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE ); + ret =q6v5_rmb_mba_wait (qproc,0 ,5000 );if (ret == -ETIMEDOUT ) {dev_err (qproc->dev,"MBA boot timed out\n" );
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 3/3] remoteproc: qcom_q6v5_mss: Update MBA log info
Quoted 13 lines · Sibi Sankar
Update MBA text logs location/size in IMEM to aid tools extract them after ramdump collection.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 3 +++ 1 file changed, 3 insertions(+)drivers/remoteproc/qcom_q6v5_mss.c +0
-0
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_mba_load(struct q6v5 *qproc) · line 936
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_mss.c +2
-0@@ -932,6 +932,9 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (ret) goto reclaim_mba; +if (qproc->has_mba_logs) +qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE );
Is there a reason why we don't unconditionally write this to the PIL info? And why it shouldn't be mba_size?
Regards,
Bjorn
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_mss.c +1
-0+ ret =q6v5_rmb_mba_wait (qproc,0 ,5000 );if (ret == -ETIMEDOUT ) {dev_err (qproc->dev,"MBA boot timed out\n" );Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 3/3] remoteproc: qcom_q6v5_mss: Update MBA log info
Quoted 18 lines · Bjorn Andersson
Quoted 16 lines · Sibi Sankar
Update MBA text logs location/size in IMEM to aid tools extract them after ramdump collection.
Signed-off-by Sibi Sankar <[email protected]>--- drivers/remoteproc/qcom_q6v5_mss.c | 3 +++ 1 file changed, 3 insertions(+)drivers/remoteproc/qcom_q6v5_mss.c +0
-0@@ -932,6 +932,9 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (ret) goto reclaim_mba;
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_mba_load(struct q6v5 *qproc) · line 936
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_mss.c +2
-0+if (qproc->has_mba_logs) +qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE );Is there a reason why we don't unconditionally write this to the PIL info? And why it shouldn't be
mba_size?
MBA text logs of size specified are the
only things extracted from MBA region by
the postmortem tools (the tool assumes
that the entire region is text). The MBA
log feature was only added to SC7180 MSS
firmware.
Quoted 12 lines
Regards,
BjornQuoted 8 lines
drivers/remoteproc/qcom_q6v5_mss.c +1
-1+ ret =q6v5_rmb_mba_wait (qproc,0 ,5000 );if (ret == -ETIMEDOUT ) {dev_err (qproc->dev,"MBA boot timed out\n" ); --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.