Commit 318130cc authored by Sibi Sankar's avatar Sibi Sankar Committed by Bjorn Andersson

remoteproc: qcom_q6v5_mss: Add MBA log extraction support

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.
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarSibi Sankar <sibis@codeaurora.org>
Link: https://lore.kernel.org/r/20200721112935.25716-3-sibis@codeaurora.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 3afdc59e
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/devcoredump.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -36,6 +37,8 @@ ...@@ -36,6 +37,8 @@
#define MPSS_CRASH_REASON_SMEM 421 #define MPSS_CRASH_REASON_SMEM 421
#define MBA_LOG_SIZE SZ_4K
/* RMB Status Register Values */ /* RMB Status Register Values */
#define RMB_PBL_SUCCESS 0x1 #define RMB_PBL_SUCCESS 0x1
...@@ -138,6 +141,7 @@ struct rproc_hexagon_res { ...@@ -138,6 +141,7 @@ struct rproc_hexagon_res {
int version; int version;
bool need_mem_protection; bool need_mem_protection;
bool has_alt_reset; bool has_alt_reset;
bool has_mba_logs;
bool has_spare_reg; bool has_spare_reg;
}; };
...@@ -198,6 +202,7 @@ struct q6v5 { ...@@ -198,6 +202,7 @@ struct q6v5 {
struct qcom_sysmon *sysmon; struct qcom_sysmon *sysmon;
bool need_mem_protection; bool need_mem_protection;
bool has_alt_reset; bool has_alt_reset;
bool has_mba_logs;
bool has_spare_reg; bool has_spare_reg;
int mpss_perm; int mpss_perm;
int mba_perm; int mba_perm;
...@@ -509,6 +514,26 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) ...@@ -509,6 +514,26 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)
return val; return val;
} }
static void q6v5_dump_mba_logs(struct q6v5 *qproc)
{
struct rproc *rproc = qproc->rproc;
void *data;
if (!qproc->has_mba_logs)
return;
if (q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, false, qproc->mba_phys,
qproc->mba_size))
return;
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) static int q6v5proc_reset(struct q6v5 *qproc)
{ {
u32 val; u32 val;
...@@ -829,6 +854,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) ...@@ -829,6 +854,7 @@ static int q6v5_mba_load(struct q6v5 *qproc)
{ {
int ret; int ret;
int xfermemop_ret; int xfermemop_ret;
bool mba_load_err = false;
qcom_q6v5_prepare(&qproc->q6v5); qcom_q6v5_prepare(&qproc->q6v5);
...@@ -918,7 +944,7 @@ static int q6v5_mba_load(struct q6v5 *qproc) ...@@ -918,7 +944,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_q6);
q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem);
q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc);
mba_load_err = true;
reclaim_mba: reclaim_mba:
xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,
false, qproc->mba_phys, false, qproc->mba_phys,
...@@ -926,6 +952,8 @@ static int q6v5_mba_load(struct q6v5 *qproc) ...@@ -926,6 +952,8 @@ static int q6v5_mba_load(struct q6v5 *qproc)
if (xfermemop_ret) { if (xfermemop_ret) {
dev_err(qproc->dev, dev_err(qproc->dev,
"Failed to reclaim mba buffer, system may become unstable\n"); "Failed to reclaim mba buffer, system may become unstable\n");
} else if (mba_load_err) {
q6v5_dump_mba_logs(qproc);
} }
disable_active_clks: disable_active_clks:
...@@ -1283,6 +1311,7 @@ static int q6v5_start(struct rproc *rproc) ...@@ -1283,6 +1311,7 @@ static int q6v5_start(struct rproc *rproc)
reclaim_mpss: reclaim_mpss:
q6v5_mba_reclaim(qproc); q6v5_mba_reclaim(qproc);
q6v5_dump_mba_logs(qproc);
return ret; return ret;
} }
...@@ -1702,6 +1731,7 @@ static int q6v5_probe(struct platform_device *pdev) ...@@ -1702,6 +1731,7 @@ static int q6v5_probe(struct platform_device *pdev)
qproc->version = desc->version; qproc->version = desc->version;
qproc->need_mem_protection = desc->need_mem_protection; 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, ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM,
qcom_msa_handover); qcom_msa_handover);
...@@ -1793,6 +1823,7 @@ static const struct rproc_hexagon_res sc7180_mss = { ...@@ -1793,6 +1823,7 @@ static const struct rproc_hexagon_res sc7180_mss = {
}, },
.need_mem_protection = true, .need_mem_protection = true,
.has_alt_reset = false, .has_alt_reset = false,
.has_mba_logs = true,
.has_spare_reg = true, .has_spare_reg = true,
.version = MSS_SC7180, .version = MSS_SC7180,
}; };
...@@ -1828,6 +1859,7 @@ static const struct rproc_hexagon_res sdm845_mss = { ...@@ -1828,6 +1859,7 @@ static const struct rproc_hexagon_res sdm845_mss = {
}, },
.need_mem_protection = true, .need_mem_protection = true,
.has_alt_reset = true, .has_alt_reset = true,
.has_mba_logs = false,
.has_spare_reg = false, .has_spare_reg = false,
.version = MSS_SDM845, .version = MSS_SDM845,
}; };
...@@ -1855,6 +1887,7 @@ static const struct rproc_hexagon_res msm8998_mss = { ...@@ -1855,6 +1887,7 @@ static const struct rproc_hexagon_res msm8998_mss = {
}, },
.need_mem_protection = true, .need_mem_protection = true,
.has_alt_reset = false, .has_alt_reset = false,
.has_mba_logs = false,
.has_spare_reg = false, .has_spare_reg = false,
.version = MSS_MSM8998, .version = MSS_MSM8998,
}; };
...@@ -1885,6 +1918,7 @@ static const struct rproc_hexagon_res msm8996_mss = { ...@@ -1885,6 +1918,7 @@ static const struct rproc_hexagon_res msm8996_mss = {
}, },
.need_mem_protection = true, .need_mem_protection = true,
.has_alt_reset = false, .has_alt_reset = false,
.has_mba_logs = false,
.has_spare_reg = false, .has_spare_reg = false,
.version = MSS_MSM8996, .version = MSS_MSM8996,
}; };
...@@ -1918,6 +1952,7 @@ static const struct rproc_hexagon_res msm8916_mss = { ...@@ -1918,6 +1952,7 @@ static const struct rproc_hexagon_res msm8916_mss = {
}, },
.need_mem_protection = false, .need_mem_protection = false,
.has_alt_reset = false, .has_alt_reset = false,
.has_mba_logs = false,
.has_spare_reg = false, .has_spare_reg = false,
.version = MSS_MSM8916, .version = MSS_MSM8916,
}; };
...@@ -1959,6 +1994,7 @@ static const struct rproc_hexagon_res msm8974_mss = { ...@@ -1959,6 +1994,7 @@ static const struct rproc_hexagon_res msm8974_mss = {
}, },
.need_mem_protection = false, .need_mem_protection = false,
.has_alt_reset = false, .has_alt_reset = false,
.has_mba_logs = false,
.has_spare_reg = false, .has_spare_reg = false,
.version = MSS_MSM8974, .version = MSS_MSM8974,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment