ARM: etm: Add some missing locks and error checks
Arve Hjønnevåg [Mon, 16 Apr 2012 07:55:42 +0000 (12:55 +0530)]
It is not safe to call etm_lock or etb_lock without holding the
mutex since another thread may also have unlocked the registers.

Also add some missing checks for valid etb_regs in the etm sysfs
entries.

Change-Id: I939f76a6ea7546a8fc0d4ddafa2fd2b6f38103bb
Signed-off-by: Arve Hjønnevåg <arve@android.com>

Conflicts:

arch/arm/kernel/etm.c

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>

arch/arm/kernel/etm.c

index 3fdcb8f..6f55728 100644 (file)
@@ -569,6 +569,12 @@ static ssize_t trace_info_show(struct kobject *kobj,
                datalen = -1;
        }
 
+       etm_unlock(&tracer);
+       etm_ctrl = etm_readl(&tracer, ETMR_CTRL);
+       etm_st = etm_readl(&tracer, ETMR_STATUS);
+       etm_lock(&tracer);
+       mutex_unlock(&tracer.mutex);
+
        ret = sprintf(buf, "Trace buffer len: %d\nComparator pairs: %d\n"
                        "ETBR_WRITEADDR:\t%08x\n"
                        "ETBR_READADDR:\t%08x\n"
@@ -737,7 +743,6 @@ static int __devinit etm_probe(struct amba_device *dev, const struct amba_id *id
 
        amba_set_drvdata(dev, t->etm_regs[t->etm_regs_count]);
 
-       mutex_init(&t->mutex);
        t->dev = &dev->dev;
        t->flags = TRACER_CYCLE_ACC | TRACER_TRACE_DATA;
        t->etm_portsz = 1;