From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:11:53
This is a collection fixes / cleanups for the coresight driver.
Patches 1-5 are fixes, and the remaining patches are clean ups.
Changes since V2:
- Added a patch to limit the trace data
- Added a patch to fix tmc_read_unprepare_etr (another crash)
- Split the patch to remove erraneous dma_free_coherent.
- Use consistent error message format for coresight_timeout cleanup.
- Fixed checkpatch warnings on the commit description, there are
some errors reported on the "crash output" in the commit description.
May be the checkpatch needs to be fixed ?
Suzuki K Poulose (9):
coresight: Fix NULL pointer dereference in _coresight_build_path
coresight: Fix tmc_read_unprepare_etr
coresight: Remove erroneous dma_free_coherent in tmc_probe
coresight: Fix csdev connections initialisation
coresight: tmc: Limit the trace to available data
coresight: etmv4: Fix ETMv4x peripheral ID table
coresight: Cleanup TMC status check
coresight: Consolidate error handling path for tmc_probe
coresight: Add better messages for coresight_timeout
drivers/hwtracing/coresight/coresight-etb10.c | 7 ++--
drivers/hwtracing/coresight/coresight-etm4x.c | 14 +++----
drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +
drivers/hwtracing/coresight/coresight-tmc-etr.c | 14 +++++--
drivers/hwtracing/coresight/coresight-tmc.c | 52 +++++++++++--------------
drivers/hwtracing/coresight/coresight-tmc.h | 4 +-
drivers/hwtracing/coresight/coresight.c | 30 +++++++-------
7 files changed, 64 insertions(+), 59 deletions(-)
--
1.9.1
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:11:58
At the end of the trace capture, we free the allocated memory,
resetting the drvdata->buf to NULL, to indicate that trace data
was collected and the next trace session should allocate the
memory in tmc_enable_etr_sink_sysfs.
The tmc_enable_etr_sink_sysfs, we only allocate memory if drvdata->vaddr
is not NULL (which is not performed at the end of previous session).
This can cause, drvdata->vaddr getting assigned NULL and later we do
memset() which causes a crash as below :
Unable to handle kernel NULL pointer dereference at virtual
address 00000000
pgd = ffffffc9747f0000
[00000000] *pgd=00000009f402e003, *pud=00000009f402e003,
*pmd=0000000000000000
Internal error: Oops: 96000046 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 1592 Comm: bash Not tainted 4.7.0-rc1+ #1712
Hardware name: ARM Juno development board (r0) (DT)
task: ffffffc078fe0080 ti: ffffffc974178000 task.ti: ffffffc974178000
PC is at __memset+0x1ac/0x200
LR is at tmc_enable_etr_sink+0xf8/0x304
pc : [<ffffff80083a002c>] lr : [<ffffff800859be44>] pstate: 400001c5
sp : ffffffc97417bc00
x29: ffffffc97417bc00 x28: ffffffc974178000
Call trace:
Exception stack(0xffffffc97417ba40 to 0xffffffc97417bb60)
ba40: 0000000000000001 ffffffc974a5d098 ffffffc97417bc00 ffffff80083a002c
ba60: ffffffc974a5d118 0000000000000000 0000000000000000 0000000000000000
ba80: 0000000000000001 0000000000000000 ffffff800859bdec 0000000000000040
baa0: ffffff8008b45b58 00000000000001c0 ffffffc97417baf0 ffffff80080eddb4
bac0: 0000000000000003 ffffffc078fe0080 ffffffc078fe0960 ffffffc078fe0940
bae0: 0000000000000000 0000000000000000 00000000007fffc0 0000000000000004
bb00: 0000000000000000 0000000000000040 000000000000003f 0000000000000000
bb20: 0000000000000000 0000000000000000 0000000000000000 0000000000000001
bb40: ffffffc078fe0960 0000000000000018 ffffffffffffffff 0008669628000000
[<ffffff80083a002c>] __memset+0x1ac/0x200
[<ffffff8008599814>] coresight_enable_path+0xa8/0x1dc
[<ffffff8008599b10>] coresight_enable+0x88/0x1b8
[<ffffff8008599d88>] enable_source_store+0x3c/0x6c
[<ffffff800845eaf4>] dev_attr_store+0x18/0x28
[<ffffff80082829e8>] sysfs_kf_write+0x54/0x64
[<ffffff8008281c30>] kernfs_fop_write+0x148/0x1d8
[<ffffff8008200128>] __vfs_write+0x28/0x110
[<ffffff8008200e88>] vfs_write+0xa0/0x198
[<ffffff80082021b0>] SyS_write+0x44/0xa0
[<ffffff8008084e70>] el0_svc_naked+0x24/0x28
Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
This patch fixes the issue by clearing the drvdata->vaddr while we free
the allocated buffer at the end of a session, so that we allocate the
memory again.
Cc: mathieu.poirier at linaro.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:11:59
_coresight_build_path assumes that all the connections of a csdev
has the child_dev initialised. This may not be true if the particular
component is not supported by the kernel config(e.g TPIU) but is
present in the DT. In which case, building a path can cause a crash like
this :
Unable to handle kernel NULL pointer dereference at virtual
address 00000010
pgd = ffffffc9750dd000
[00000010] *pgd=00000009f5e90003, *pud=00000009f5e90003,
*pmd=0000000000000000
Internal error: Oops: 96000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 4 PID: 1348 Comm: bash Not tainted 4.6.0-next-20160517 #1646
Hardware name: ARM Juno development board (r0) (DT)
task: ffffffc97517a280 ti: ffffffc9762c4000 task.ti: ffffffc9762c4000
PC is at _coresight_build_path+0x18/0xe4
LR is at _coresight_build_path+0xc0/0xe4
pc : [<ffffff80083d5130>] lr : [<ffffff80083d51d8>] pstate: 20000145
sp : ffffffc9762c7ba0
[<ffffff80083d5130>] _coresight_build_path+0x18/0xe4
[<ffffff80083d51d8>] _coresight_build_path+0xc0/0xe4
[<ffffff80083d51d8>] _coresight_build_path+0xc0/0xe4
[<ffffff80083d51d8>] _coresight_build_path+0xc0/0xe4
[<ffffff80083d51d8>] _coresight_build_path+0xc0/0xe4
[<ffffff80083d51d8>] _coresight_build_path+0xc0/0xe4
[<ffffff80083d5cdc>] coresight_build_path+0x40/0x68
[<ffffff80083d5e14>] coresight_enable+0x74/0x1bc
[<ffffff80083d60a0>] enable_source_store+0x3c/0x6c
[<ffffff800830b17c>] dev_attr_store+0x18/0x28
[<ffffff80081ca9c4>] sysfs_kf_write+0x40/0x50
[<ffffff80081c9e38>] kernfs_fop_write+0x140/0x1cc
[<ffffff8008163ec8>] __vfs_write+0x28/0x110
[<ffffff8008164bf0>] vfs_write+0xa0/0x174
[<ffffff8008165d18>] SyS_write+0x44/0xa0
[<ffffff8008084e70>] el0_svc_naked+0x24/0x28
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -385,7 +385,6 @@ static int _coresight_build_path(struct coresight_device *csdev,inti;boolfound=false;structcoresight_node*node;-structcoresight_connection*conn;/* An activated sink has been found. Enqueue the element */if((csdev->type==CORESIGHT_DEV_TYPE_SINK||
@@ -394,8 +393,9 @@ static int _coresight_build_path(struct coresight_device *csdev,/* Not a sink - recursively explore each port found on this element */for(i=0;i<csdev->nr_outport;i++){-conn=&csdev->conns[i];-if(_coresight_build_path(conn->child_dev,path)==0){+structcoresight_device*child_dev=csdev->conns[i].child_dev;++if(child_dev&&_coresight_build_path(child_dev,path)==0){found=true;break;}
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:12:04
At present the ETF or ETR gives out the entire device
buffer, even if there is less or even no trace data
available. This patch limits the trace data given out to
the actual trace data collected.
Cc: mathieu.poirier at linaro.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 ++
drivers/hwtracing/coresight/coresight-tmc-etr.c | 12 +++++++++---
drivers/hwtracing/coresight/coresight-tmc.c | 6 +++---
drivers/hwtracing/coresight/coresight-tmc.h | 4 +++-
4 files changed, 17 insertions(+), 7 deletions(-)
@@ -64,11 +64,17 @@ static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata)rwp=readl_relaxed(drvdata->base+TMC_RWP);val=readl_relaxed(drvdata->base+TMC_STS);-/* How much memory do we still have */-if(val&BIT(0))+/*+*Adjustthebuffertopointtothebeginningofthetracedata+*andtheavailabletracedata.+*/+if(val&BIT(0)){drvdata->buf=drvdata->vaddr+rwp-drvdata->paddr;-else+drvdata->len=drvdata->size;+}else{drvdata->buf=drvdata->vaddr;+drvdata->len=rwp-drvdata->paddr;+}}staticvoidtmc_etr_disable_hw(structtmc_drvdata*drvdata)
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:12:06
This is a cleanup patch.
coresight_device->conns holds an array to point to the devices
connected to the OUT ports of a component. Sinks, e.g ETR, do not
have an OUT port (nr_outport = 0), as it streams the trace to
memory via AXI.
At coresight_register() we do :
conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL);
if (!conns) {
ret = -ENOMEM;
goto err_kzalloc_conns;
}
For ETR, since the total size requested for kcalloc is zero, the return
value is, ZERO_SIZE_PTR ( != NULL). Hence, csdev->conns = ZERO_SIZE_PTR
which cannot be verified later to contain a valid pointer. The code which
accesses the csdev->conns is bounded by the csdev->nr_outport check,
hence we don't try to dereference the ZERO_SIZE_PTR. This patch cleans
up the csdev->conns and csdev->refcnt, initialisation to make sure we
initialise it properly(i.e, either NULL or valid conns array).
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
@@ -918,16 +918,20 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)csdev->nr_inport=desc->pdata->nr_inport;csdev->nr_outport=desc->pdata->nr_outport;-conns=kcalloc(csdev->nr_outport,sizeof(*conns),GFP_KERNEL);-if(!conns){-ret=-ENOMEM;-gotoerr_kzalloc_conns;-}-for(i=0;i<csdev->nr_outport;i++){-conns[i].outport=desc->pdata->outports[i];-conns[i].child_name=desc->pdata->child_names[i];-conns[i].child_port=desc->pdata->child_ports[i];+/* Initialise connections if there is at least one outport */+if(csdev->nr_outport){+conns=kcalloc(csdev->nr_outport,sizeof(*conns),GFP_KERNEL);+if(!conns){+ret=-ENOMEM;+gotoerr_kzalloc_conns;+}++for(i=0;i<csdev->nr_outport;i++){+conns[i].outport=desc->pdata->outports[i];+conns[i].child_name=desc->pdata->child_names[i];+conns[i].child_port=desc->pdata->child_ports[i];+}}csdev->conns=conns;
On 6 June 2016 at 03:11, Suzuki K Poulose [off-list ref] wrote:
This is a cleanup patch.
coresight_device->conns holds an array to point to the devices
connected to the OUT ports of a component. Sinks, e.g ETR, do not
have an OUT port (nr_outport = 0), as it streams the trace to
memory via AXI.
At coresight_register() we do :
conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL);
if (!conns) {
ret = -ENOMEM;
goto err_kzalloc_conns;
}
For ETR, since the total size requested for kcalloc is zero, the return
value is, ZERO_SIZE_PTR ( != NULL). Hence, csdev->conns = ZERO_SIZE_PTR
which cannot be verified later to contain a valid pointer. The code which
accesses the csdev->conns is bounded by the csdev->nr_outport check,
hence we don't try to dereference the ZERO_SIZE_PTR. This patch cleans
up the csdev->conns and csdev->refcnt, initialisation to make sure we
This patch no longer deals with csdev->refcnt.
quoted hunk
initialise it properly(i.e, either NULL or valid conns array).
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
@@ -918,16 +918,20 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)csdev->nr_inport=desc->pdata->nr_inport;csdev->nr_outport=desc->pdata->nr_outport;-conns=kcalloc(csdev->nr_outport,sizeof(*conns),GFP_KERNEL);-if(!conns){-ret=-ENOMEM;-gotoerr_kzalloc_conns;-}-for(i=0;i<csdev->nr_outport;i++){-conns[i].outport=desc->pdata->outports[i];-conns[i].child_name=desc->pdata->child_names[i];-conns[i].child_port=desc->pdata->child_ports[i];+/* Initialise connections if there is at least one outport */+if(csdev->nr_outport){+conns=kcalloc(csdev->nr_outport,sizeof(*conns),GFP_KERNEL);+if(!conns){+ret=-ENOMEM;+gotoerr_kzalloc_conns;+}++for(i=0;i<csdev->nr_outport;i++){+conns[i].outport=desc->pdata->outports[i];+conns[i].child_name=desc->pdata->child_names[i];+conns[i].child_port=desc->pdata->child_ports[i];+}}csdev->conns=conns;--
From: Suzuki K Poulose <Suzuki.Poulose@arm.com> Date: 2016-06-13 08:54:38
On 12/06/16 21:39, Mathieu Poirier wrote:
On 6 June 2016 at 03:11, Suzuki K Poulose [off-list ref] wrote:
quoted
This is a cleanup patch.
coresight_device->conns holds an array to point to the devices
connected to the OUT ports of a component. Sinks, e.g ETR, do not
have an OUT port (nr_outport = 0), as it streams the trace to
memory via AXI.
At coresight_register() we do :
conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL);
if (!conns) {
ret = -ENOMEM;
goto err_kzalloc_conns;
}
For ETR, since the total size requested for kcalloc is zero, the return
value is, ZERO_SIZE_PTR ( != NULL). Hence, csdev->conns = ZERO_SIZE_PTR
which cannot be verified later to contain a valid pointer. The code which
accesses the csdev->conns is bounded by the csdev->nr_outport check,
hence we don't try to dereference the ZERO_SIZE_PTR. This patch cleans
up the csdev->conns and csdev->refcnt, initialisation to make sure we
This patch no longer deals with csdev->refcnt.
Ok, fill fix that. Btw, do we need that check ? I am tempted to keep it there,
just to make sure we don't end up in something similar in the future.
Cheers
Suzuki
On 13 June 2016 at 02:54, Suzuki K Poulose [off-list ref] wrote:
On 12/06/16 21:39, Mathieu Poirier wrote:
quoted
On 6 June 2016 at 03:11, Suzuki K Poulose [off-list ref] wrote:
quoted
This is a cleanup patch.
coresight_device->conns holds an array to point to the devices
connected to the OUT ports of a component. Sinks, e.g ETR, do not
have an OUT port (nr_outport = 0), as it streams the trace to
memory via AXI.
At coresight_register() we do :
conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL);
if (!conns) {
ret = -ENOMEM;
goto err_kzalloc_conns;
}
For ETR, since the total size requested for kcalloc is zero, the return
value is, ZERO_SIZE_PTR ( != NULL). Hence, csdev->conns = ZERO_SIZE_PTR
which cannot be verified later to contain a valid pointer. The code which
accesses the csdev->conns is bounded by the csdev->nr_outport check,
hence we don't try to dereference the ZERO_SIZE_PTR. This patch cleans
up the csdev->conns and csdev->refcnt, initialisation to make sure we
This patch no longer deals with csdev->refcnt.
Ok, fill fix that. Btw, do we need that check ? I am tempted to keep it
there,
just to make sure we don't end up in something similar in the future.
If it becomes an issue in the future we'll know what to do :o)
Thanks,
Mathieu
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:12:09
This patch cleans up the peripheral id table for different ETMv4
implementations.
As per Cortex-A53 TRM, the ETM has following id values:
Peripheral ID0 0x5D 0xFE0
Peripheral ID1 0xB9 0xFE4
Peripheral ID2 0x4B 0xFE8
Peripheral ID3 0x00 0xFEC
where, PID2: has the following format:
[7:4] Revision
[3] JEDEC 0b1 res1. Indicates a JEP106 identity code is used
[2:0] DES_1 0b011 ARM Limited. This is bits[6:4] of JEP106 ID code
The existing table entry checks only the bits [1:0], which is not
sufficient enough. Fix it to match bits [3:0], just like the other
entries do. While at it, correct the comment for A57 and the A53 entry.
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-etm4x.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:12:37
When we encounter a timeout waiting for a status change via
coresight_timeout, the caller always print the offset which
was tried. This is pretty much useless as it doesn't specify
the bit position we wait for. Also, one needs to lookup the
TRM to figure out, what was wrong. This patch changes all
such error messages to print something more meaningful.
Cc: joe at perches.com
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-etb10.c | 7 +++----
drivers/hwtracing/coresight/coresight-etm4x.c | 6 ++----
drivers/hwtracing/coresight/coresight-tmc.c | 7 +++----
3 files changed, 8 insertions(+), 12 deletions(-)
@@ -184,8 +184,8 @@ static void etb_disable_hw(struct etb_drvdata *drvdata)if(coresight_timeout(drvdata->base,ETB_FFCR,ETB_FFCR_BIT,0)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-ETB_FFCR);+"timeout while waiting for %s\n",+"completion of Manual Flush");}/* disable trace capture */
@@ -193,8 +193,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata)if(coresight_timeout(drvdata->base,ETB_FFSR,ETB_FFSR_BIT,1)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-ETB_FFCR);+"timeout while waiting for %s\n","Formatter to Stop");}CS_LOCK(drvdata->base);
@@ -111,8 +111,7 @@ static void etm4_enable_hw(void *info)/* wait for TRCSTATR.IDLE to go up */if(coresight_timeout(drvdata->base,TRCSTATR,TRCSTATR_IDLE_BIT,1))dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TRCSTATR);+"timeout while waiting for %s\n","Idle Trace Status");writel_relaxed(config->pe_sel,drvdata->base+TRCPROCSELR);writel_relaxed(config->cfg,drvdata->base+TRCCONFIGR);
@@ -184,8 +183,7 @@ static void etm4_enable_hw(void *info)/* wait for TRCSTATR.IDLE to go back down to '0' */if(coresight_timeout(drvdata->base,TRCSTATR,TRCSTATR_IDLE_BIT,0))dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TRCSTATR);+"timeout while waiting for %s\n","Idle Trace Status");CS_LOCK(drvdata->base);
@@ -38,8 +38,7 @@ void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata)if(coresight_timeout(drvdata->base,TMC_STS,TMC_STS_TMCREADY_BIT,1)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TMC_STS);+"timeout while waiting for %s\n","TMC to be Ready");}}
@@ -56,8 +55,8 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata)if(coresight_timeout(drvdata->base,TMC_FFCR,TMC_FFCR_FLUSHMAN_BIT,0)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TMC_FFCR);+"timeout while waiting for %s\n",+"completion of Manual Flush");}tmc_wait_for_tmcready(drvdata);
On 6 June 2016 at 03:11, Suzuki K Poulose [off-list ref] wrote:
quoted hunk
When we encounter a timeout waiting for a status change via
coresight_timeout, the caller always print the offset which
was tried. This is pretty much useless as it doesn't specify
the bit position we wait for. Also, one needs to lookup the
TRM to figure out, what was wrong. This patch changes all
such error messages to print something more meaningful.
Cc: joe at perches.com
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-etb10.c | 7 +++----
drivers/hwtracing/coresight/coresight-etm4x.c | 6 ++----
drivers/hwtracing/coresight/coresight-tmc.c | 7 +++----
3 files changed, 8 insertions(+), 12 deletions(-)
@@ -184,8 +184,8 @@ static void etb_disable_hw(struct etb_drvdata *drvdata)if(coresight_timeout(drvdata->base,ETB_FFCR,ETB_FFCR_BIT,0)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-ETB_FFCR);+"timeout while waiting for %s\n",+"completion of Manual Flush");
It seems like we misunderstood each other - the above format makes
string searching in the kernel difficult. Why not simply do:
dev_err(drvdata->dev, timeout while waiting for completion of Manual Flush);
quoted hunk
}
/* disable trace capture */
@@ -193,8 +193,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata) if (coresight_timeout(drvdata->base, ETB_FFSR, ETB_FFSR_BIT, 1)) { dev_err(drvdata->dev,- "timeout observed when probing at offset %#x\n",- ETB_FFCR);+ "timeout while waiting for %s\n", "Formatter to Stop"); } CS_LOCK(drvdata->base);
@@ -111,8 +111,7 @@ static void etm4_enable_hw(void *info)/* wait for TRCSTATR.IDLE to go up */if(coresight_timeout(drvdata->base,TRCSTATR,TRCSTATR_IDLE_BIT,1))dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TRCSTATR);+"timeout while waiting for %s\n","Idle Trace Status");writel_relaxed(config->pe_sel,drvdata->base+TRCPROCSELR);writel_relaxed(config->cfg,drvdata->base+TRCCONFIGR);
@@ -184,8 +183,7 @@ static void etm4_enable_hw(void *info)/* wait for TRCSTATR.IDLE to go back down to '0' */if(coresight_timeout(drvdata->base,TRCSTATR,TRCSTATR_IDLE_BIT,0))dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TRCSTATR);+"timeout while waiting for %s\n","Idle Trace Status");CS_LOCK(drvdata->base);
@@ -38,8 +38,7 @@ void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata)if(coresight_timeout(drvdata->base,TMC_STS,TMC_STS_TMCREADY_BIT,1)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TMC_STS);+"timeout while waiting for %s\n","TMC to be Ready");}}
@@ -56,8 +55,8 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata)if(coresight_timeout(drvdata->base,TMC_FFCR,TMC_FFCR_FLUSHMAN_BIT,0)){dev_err(drvdata->dev,-"timeout observed when probing at offset %#x\n",-TMC_FFCR);+"timeout while waiting for %s\n",+"completion of Manual Flush");}tmc_wait_for_tmcready(drvdata);--
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:12:38
This patch cleans up the error handling path for tmc_probe
as a side effect of the removal of the spurious dma_free_coherent().
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-tmc.c | 36 ++++++++++++++---------------
1 file changed, 17 insertions(+), 19 deletions(-)
@@ -309,22 +309,31 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)if(np){pdata=of_get_coresight_platform_data(dev,np);-if(IS_ERR(pdata))-returnPTR_ERR(pdata);+if(IS_ERR(pdata)){+ret=PTR_ERR(pdata);+gotoout;+}adev->dev.platform_data=pdata;}+ret=-ENOMEM;drvdata=devm_kzalloc(dev,sizeof(*drvdata),GFP_KERNEL);if(!drvdata)-return-ENOMEM;+gotoout;++desc=devm_kzalloc(dev,sizeof(*desc),GFP_KERNEL);+if(!desc)+gotoout;drvdata->dev=&adev->dev;dev_set_drvdata(dev,drvdata);/* Validity for the resource is already checked by the AMBA core */base=devm_ioremap_resource(dev,res);-if(IS_ERR(base))-returnPTR_ERR(base);+if(IS_ERR(base)){+ret=PTR_ERR(base);+gotoout;+}drvdata->base=base;
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:13:04
commit de5461970b3e9e194 ("coresight: tmc: allocating memory when needed")
removed the static allocation of buffer for the trace data in ETR mode in
tmc_probe. However it failed to remove the "devm_free_coherent" in
tmc_probe when the probe fails due to other reasons. This patch gets
rid of the incorrect dma_free_coherent() call. Also consolidates the
error return paths.
Fixes: commit de5461970b3e9e194 ("coresight: tmc: allocating memory when needed")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-tmc.c | 3 ---
1 file changed, 3 deletions(-)
On 6 June 2016 at 03:11, Suzuki K Poulose [off-list ref] wrote:
commit de5461970b3e9e194 ("coresight: tmc: allocating memory when needed")
removed the static allocation of buffer for the trace data in ETR mode in
tmc_probe. However it failed to remove the "devm_free_coherent" in
tmc_probe when the probe fails due to other reasons. This patch gets
rid of the incorrect dma_free_coherent() call. Also consolidates the
error return paths.
Since this set has to go for one more round, please remove the last
line in the commit message. The error path is consolidated in patch
8/9.
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-06 09:13:28
Use the defined symbol rather than hardcoding the value to
check whether the TMC buffer is full.
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Suzuki K Poulose <suzuki.poulose@arm.com> Date: 2016-06-10 10:31:51
At the end of a trace collection, we try to clear the entire buffer
and enable the ETR back if it was already enabled. But, we would have
adjusted the drvdata->buf to point to the beginning of the trace data
in the trace buffer @drvdata->vaddr. So, the following code which
clears the buffer is dangerous and can cause crashes, like below :
memset(drvdata->buf, 0, drvdata->size);
Unable to handle kernel paging request at virtual address ffffff800a145000
pgd = ffffffc974726000
*pgd=00000009f3e91003, *pud=00000009f3e91003, *pmd=0000000000000000
PREEMPT SMP
Modules linked in:
CPU: 4 PID: 1692 Comm: dd Not tainted 4.7.0-rc2+ #1721
Hardware name: ARM Juno development board (r0) (DT)
task: ffffffc9734a0080 ti: ffffffc974460000 task.ti: ffffffc974460000
PC is at __memset+0x1ac/0x200
LR is at tmc_read_unprepare_etr+0x144/0x1bc
pc : [<ffffff80083a05ac>] lr : [<ffffff800859c984>] pstate: 200001c5
...
[<ffffff80083a05ac>] __memset+0x1ac/0x200
[<ffffff800859b2e4>] tmc_release+0x90/0x94
[<ffffff8008202f58>] __fput+0xa8/0x1ec
[<ffffff80082030f4>] ____fput+0xc/0x14
[<ffffff80080c3ef8>] task_work_run+0xb0/0xe4
[<ffffff8008088bf4>] do_notify_resume+0x64/0x6c
[<ffffff8008084d5c>] work_pending+0x10/0x14
Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
Since we clear the buffer anyway in the following call to
tmc_etr_enable_hw(), remove the erroneous memset().
Fixes: commit de5461970b3e9e1 ("coresight: tmc: allocating memory when needed")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
Mathieu,
I think this should go to 4.7. Please push it.
---
drivers/hwtracing/coresight/coresight-tmc-etr.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
On 10 June 2016 at 04:31, Suzuki K Poulose [off-list ref] wrote:
At the end of a trace collection, we try to clear the entire buffer
and enable the ETR back if it was already enabled. But, we would have
adjusted the drvdata->buf to point to the beginning of the trace data
in the trace buffer @drvdata->vaddr. So, the following code which
clears the buffer is dangerous and can cause crashes, like below :
memset(drvdata->buf, 0, drvdata->size);
Unable to handle kernel paging request at virtual address ffffff800a145000
pgd = ffffffc974726000
*pgd=00000009f3e91003, *pud=00000009f3e91003, *pmd=0000000000000000
PREEMPT SMP
Modules linked in:
CPU: 4 PID: 1692 Comm: dd Not tainted 4.7.0-rc2+ #1721
Hardware name: ARM Juno development board (r0) (DT)
task: ffffffc9734a0080 ti: ffffffc974460000 task.ti: ffffffc974460000
PC is at __memset+0x1ac/0x200
LR is at tmc_read_unprepare_etr+0x144/0x1bc
pc : [<ffffff80083a05ac>] lr : [<ffffff800859c984>] pstate: 200001c5
...
[<ffffff80083a05ac>] __memset+0x1ac/0x200
[<ffffff800859b2e4>] tmc_release+0x90/0x94
[<ffffff8008202f58>] __fput+0xa8/0x1ec
[<ffffff80082030f4>] ____fput+0xc/0x14
[<ffffff80080c3ef8>] task_work_run+0xb0/0xe4
[<ffffff8008088bf4>] do_notify_resume+0x64/0x6c
[<ffffff8008084d5c>] work_pending+0x10/0x14
Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
Since we clear the buffer anyway in the following call to
tmc_etr_enable_hw(), remove the erroneous memset().
Fixes: commit de5461970b3e9e1 ("coresight: tmc: allocating memory when needed")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
Mathieu,
I think this should go to 4.7. Please push it.
If this [1] didn't make it, this one won't make it either. I've
applied it to my tree for merging in the 4.8 cycle.
Thanks,
Mathieu
[1]. https://patchwork.kernel.org/patch/9144589/
From: Suzuki K Poulose <Suzuki.Poulose@arm.com> Date: 2016-06-13 09:00:00
On 12/06/16 22:06, Mathieu Poirier wrote:
On 10 June 2016 at 04:31, Suzuki K Poulose [off-list ref] wrote:
quoted
At the end of a trace collection, we try to clear the entire buffer
and enable the ETR back if it was already enabled. But, we would have
adjusted the drvdata->buf to point to the beginning of the trace data
in the trace buffer @drvdata->vaddr. So, the following code which
clears the buffer is dangerous and can cause crashes, like below :
memset(drvdata->buf, 0, drvdata->size);
Unable to handle kernel paging request at virtual address ffffff800a145000
pgd = ffffffc974726000
*pgd=00000009f3e91003, *pud=00000009f3e91003, *pmd=0000000000000000
PREEMPT SMP
Modules linked in:
CPU: 4 PID: 1692 Comm: dd Not tainted 4.7.0-rc2+ #1721
Hardware name: ARM Juno development board (r0) (DT)
task: ffffffc9734a0080 ti: ffffffc974460000 task.ti: ffffffc974460000
PC is at __memset+0x1ac/0x200
LR is at tmc_read_unprepare_etr+0x144/0x1bc
pc : [<ffffff80083a05ac>] lr : [<ffffff800859c984>] pstate: 200001c5
...
[<ffffff80083a05ac>] __memset+0x1ac/0x200
[<ffffff800859b2e4>] tmc_release+0x90/0x94
[<ffffff8008202f58>] __fput+0xa8/0x1ec
[<ffffff80082030f4>] ____fput+0xc/0x14
[<ffffff80080c3ef8>] task_work_run+0xb0/0xe4
[<ffffff8008088bf4>] do_notify_resume+0x64/0x6c
[<ffffff8008084d5c>] work_pending+0x10/0x14
Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428)
Since we clear the buffer anyway in the following call to
tmc_etr_enable_hw(), remove the erroneous memset().
Fixes: commit de5461970b3e9e1 ("coresight: tmc: allocating memory when needed")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
Mathieu,
I think this should go to 4.7. Please push it.
If this [1] didn't make it, this one won't make it either.
applied it to my tree for merging in the 4.8 cycle.