coresight: take care of tmc etr wrap around & offset calculation

Ensure that buffer pointer points to the right location while
trying to read TMC in ETR circular buffer mode when we wrap
around.

TMC in ETR circular buffer mode tracks the physical address
in the RWP register (in contrast to pure offsets). Hence
subtract it from the base physical address to get the offset.

Change-Id: Ice1170dcd63928dd8304c421800848e036386b88
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
This commit is contained in:
Pratik Patel 2012-08-10 10:47:08 -07:00 committed by Iliyan Malchev
parent fcfcf7f75b
commit 5afc00b736

View file

@ -505,7 +505,7 @@ static void __tmc_etr_dump(struct tmc_drvdata *drvdata)
rwphi = tmc_readl(drvdata, TMC_RWPHI);
if (BVAL(tmc_readl(drvdata, TMC_STS), 0))
drvdata->buf = drvdata->vaddr + rwp;
drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr;
else
drvdata->buf = drvdata->vaddr;
}
@ -751,6 +751,8 @@ static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
if (bufp == (char *)(drvdata->vaddr + drvdata->size))
bufp = drvdata->vaddr;
else if (bufp > (char *)(drvdata->vaddr + drvdata->size))
bufp -= drvdata->size;
if ((bufp + len) > (char *)(drvdata->vaddr + drvdata->size))
len = (char *)(drvdata->vaddr + drvdata->size) - bufp;
}