summaryrefslogtreecommitdiff
path: root/drivers/iommu
diff options
context:
space:
mode:
authorChintan Pandya <cpandya@codeaurora.org>2014-05-28 11:22:34 +0530
committerChintan Pandya <cpandya@codeaurora.org>2014-05-30 15:36:12 +0530
commit3118c155acadeea98af7774f8d98940fcba1dc8a (patch)
treeedb50068830024c9f6e2793af2bd161ad4b43404 /drivers/iommu
parentd2ca20981fdcc44583c1f6d6df85ce1ba7a23fdb (diff)
iommu: msm: fix secure fault handler debug logs
Present debug log mechanism of secure context bank fault handler doesn't behave well when it tries to obtain register dumps from secure environment and fails to get a sane response. It is observed that the secure environment doesn't fill up the register dump structure passed by the kernel correctly. This leads to secure fault handler constantly dumping default initialized values for these register making no sense. This patch intends to address this issue and fixes following. * initialize dump holding structure and response variable to 0 * return IRQ_NONE and do not proceed if secure environment response is 0 length * replace incorrect CB register address prints by actual context numbers and register offsets. Change-Id: I07f329fd5dcb4fc56f7bb9a6dc182b73b806005c Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/msm_iommu_sec.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/iommu/msm_iommu_sec.c b/drivers/iommu/msm_iommu_sec.c
index 80ed1704d3b5..7ae762e51237 100644
--- a/drivers/iommu/msm_iommu_sec.c
+++ b/drivers/iommu/msm_iommu_sec.c
@@ -128,7 +128,7 @@ static int msm_iommu_dump_fault_regs(int smmu_id, int cb_num,
uint32_t buff;
uint32_t len;
} req_info;
- int resp;
+ int resp = 0;
req_info.id = smmu_id;
req_info.cb_num = cb_num;
@@ -155,6 +155,9 @@ static int msm_iommu_reg_dump_to_regs(
phys_addr_t phys_base = drvdata->phys_base;
int ctx = ctx_drvdata->num;
+ if (!nvals)
+ return -EINVAL;
+
for (i = 1; it < end; it += 2, i += 2) {
unsigned int reg_offset;
uint32_t addr = *it;
@@ -222,12 +225,10 @@ static int msm_iommu_reg_dump_to_regs(
for (i = 0; i < MAX_DUMP_REGS; ++i) {
if (!ctx_regs[i].valid) {
if (dump_regs_tbl[i].must_be_present) {
- pr_err("Register missing from dump: %s, 0x%x (0x%lx)\n",
+ pr_err("Register missing from dump for ctx %d: %s, 0x%x\n",
+ ctx,
dump_regs_tbl[i].name,
- dump_regs_tbl[i].reg_offset,
- (unsigned long)
- (phys_base +
- dump_regs_tbl[i].reg_offset));
+ dump_regs_tbl[i].reg_offset);
ret = 1;
}
ctx_regs[i].val = 0xd00dfeed;
@@ -255,7 +256,7 @@ irqreturn_t msm_iommu_secure_fault_handler_v2(int irq, void *dev_id)
ctx_drvdata = dev_get_drvdata(&pdev->dev);
BUG_ON(!ctx_drvdata);
- regs = kmalloc(sizeof(*regs), GFP_KERNEL);
+ regs = kzalloc(sizeof(*regs), GFP_KERNEL);
if (!regs) {
pr_err("%s: Couldn't allocate memory\n", __func__);
goto lock_release;
@@ -287,6 +288,12 @@ irqreturn_t msm_iommu_secure_fault_handler_v2(int irq, void *dev_id)
memset(ctx_regs, 0, sizeof(ctx_regs));
tmp = msm_iommu_reg_dump_to_regs(
ctx_regs, regs, drvdata, ctx_drvdata);
+ if (tmp < 0) {
+ ret = IRQ_NONE;
+ pr_err("Incorrect response from secure environment\n");
+ goto free_regs;
+ }
+
if (ctx_regs[DUMP_REG_FSR].val) {
if (tmp)
pr_err("Incomplete fault register dump. Printout will be incomplete.\n");