Skip to content

Commit 807aa8f

Browse files
coresight: tmc: keep track of memory width
Accessing the HW configuration register each time the memory width is needed simply doesn't make sense. It is much more efficient to read the value once and keep a reference for later use. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 4f1ff3de925d741b0b77c59bc1387cb940ad7c73)
1 parent 6b21a3e commit 807aa8f

3 files changed

Lines changed: 41 additions & 17 deletions

File tree

drivers/hwtracing/coresight/coresight-tmc-etf.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,13 @@ void tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
4141

4242
static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
4343
{
44-
enum tmc_mem_intf_width memwidth;
45-
u8 memwords;
4644
char *bufp;
4745
u32 read_data;
4846
int i;
4947

50-
memwidth = BMVAL(readl_relaxed(drvdata->base + CORESIGHT_DEVID), 8, 10);
51-
if (memwidth == TMC_MEM_INTF_WIDTH_32BITS)
52-
memwords = 1;
53-
else if (memwidth == TMC_MEM_INTF_WIDTH_64BITS)
54-
memwords = 2;
55-
else if (memwidth == TMC_MEM_INTF_WIDTH_128BITS)
56-
memwords = 4;
57-
else
58-
memwords = 8;
59-
6048
bufp = drvdata->buf;
6149
while (1) {
62-
for (i = 0; i < memwords; i++) {
50+
for (i = 0; i < drvdata->memwidth; i++) {
6351
read_data = readl_relaxed(drvdata->base + TMC_RRD);
6452
if (read_data == 0xFFFFFFFF)
6553
return;

drivers/hwtracing/coresight/coresight-tmc.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,39 @@ static const struct file_operations tmc_fops = {
186186
.llseek = no_llseek,
187187
};
188188

189+
static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
190+
{
191+
enum tmc_mem_intf_width memwidth;
192+
193+
/*
194+
* Excerpt from the TRM:
195+
*
196+
* DEVID::MEMWIDTH[10:8]
197+
* 0x2 Memory interface databus is 32 bits wide.
198+
* 0x3 Memory interface databus is 64 bits wide.
199+
* 0x4 Memory interface databus is 128 bits wide.
200+
* 0x5 Memory interface databus is 256 bits wide.
201+
*/
202+
switch (BMVAL(devid, 8, 10)) {
203+
case 0x2:
204+
memwidth = TMC_MEM_INTF_WIDTH_32BITS;
205+
break;
206+
case 0x3:
207+
memwidth = TMC_MEM_INTF_WIDTH_64BITS;
208+
break;
209+
case 0x4:
210+
memwidth = TMC_MEM_INTF_WIDTH_128BITS;
211+
break;
212+
case 0x5:
213+
memwidth = TMC_MEM_INTF_WIDTH_256BITS;
214+
break;
215+
default:
216+
memwidth = 0;
217+
}
218+
219+
return memwidth;
220+
}
221+
189222
#define coresight_tmc_simple_func(name, offset) \
190223
coresight_simple_func(struct tmc_drvdata, name, offset)
191224

@@ -299,6 +332,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
299332

300333
devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
301334
drvdata->config_type = BMVAL(devid, 6, 7);
335+
drvdata->memwidth = tmc_get_memwidth(devid);
302336

303337
if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
304338
if (np)

drivers/hwtracing/coresight/coresight-tmc.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ enum tmc_mode {
8181
};
8282

8383
enum tmc_mem_intf_width {
84-
TMC_MEM_INTF_WIDTH_32BITS = 0x2,
85-
TMC_MEM_INTF_WIDTH_64BITS = 0x3,
86-
TMC_MEM_INTF_WIDTH_128BITS = 0x4,
87-
TMC_MEM_INTF_WIDTH_256BITS = 0x5,
84+
TMC_MEM_INTF_WIDTH_32BITS = 1,
85+
TMC_MEM_INTF_WIDTH_64BITS = 2,
86+
TMC_MEM_INTF_WIDTH_128BITS = 4,
87+
TMC_MEM_INTF_WIDTH_256BITS = 8,
8888
};
8989

9090
/**
@@ -100,6 +100,7 @@ enum tmc_mem_intf_width {
100100
* @size: @buf size.
101101
* @mode: how this TMC is being used.
102102
* @config_type: TMC variant, must be of type @tmc_config_type.
103+
* @memwidth: width of the memory interface databus, in bytes.
103104
* @trigger_cntr: amount of words to store after a trigger.
104105
*/
105106
struct tmc_drvdata {
@@ -115,6 +116,7 @@ struct tmc_drvdata {
115116
u32 size;
116117
local_t mode;
117118
enum tmc_config_type config_type;
119+
enum tmc_mem_intf_width memwidth;
118120
u32 trigger_cntr;
119121
};
120122

0 commit comments

Comments
 (0)