Skip to content

Commit 2ad91e4

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-cmn: Fix port detection for CMN-700
When the "extra device ports" configuration was first added, the additional mxp_device_port_connect_info registers were added around the existing mxp_mesh_port_connect_info registers. What I missed about CMN-700 is that it shuffled them around to remove this discontinuity. As such, tweak the definitions and factor out a helper for reading these registers so we can deal with this discrepancy easily, which does at least allow nicely tidying up the callsites. With this we can then also do the nice thing and skip accesses completely rather than relying on RES0 behaviour where we know the extra registers aren't defined. Fixes: 23760a0 ("perf/arm-cmn: Add CMN-700 support") Reported-by: Jing Zhang <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/71d129241d4d7923cde72a0e5b4c8d2f6084525f.1681295193.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent a30b87e commit 2ad91e4

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

drivers/perf/arm-cmn.c

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@
5757
#define CMN_INFO_REQ_VC_NUM GENMASK_ULL(1, 0)
5858

5959
/* XPs also have some local topology info which has uses too */
60-
#define CMN_MXP__CONNECT_INFO_P0 0x0008
61-
#define CMN_MXP__CONNECT_INFO_P1 0x0010
62-
#define CMN_MXP__CONNECT_INFO_P2 0x0028
63-
#define CMN_MXP__CONNECT_INFO_P3 0x0030
64-
#define CMN_MXP__CONNECT_INFO_P4 0x0038
65-
#define CMN_MXP__CONNECT_INFO_P5 0x0040
60+
#define CMN_MXP__CONNECT_INFO(p) (0x0008 + 8 * (p))
6661
#define CMN__CONNECT_INFO_DEVICE_TYPE GENMASK_ULL(4, 0)
6762

63+
#define CMN_MAX_PORTS 6
64+
#define CI700_CONNECT_INFO_P2_5_OFFSET 0x10
65+
6866
/* PMU registers occupy the 3rd 4KB page of each node's region */
6967
#define CMN_PMU_OFFSET 0x2000
7068

@@ -396,6 +394,25 @@ static struct arm_cmn_node *arm_cmn_node(const struct arm_cmn *cmn,
396394
return NULL;
397395
}
398396

397+
static u32 arm_cmn_device_connect_info(const struct arm_cmn *cmn,
398+
const struct arm_cmn_node *xp, int port)
399+
{
400+
int offset = CMN_MXP__CONNECT_INFO(port);
401+
402+
if (port >= 2) {
403+
if (cmn->model & (CMN600 | CMN650))
404+
return 0;
405+
/*
406+
* CI-700 may have extra ports, but still has the
407+
* mesh_port_connect_info registers in the way.
408+
*/
409+
if (cmn->model == CI700)
410+
offset += CI700_CONNECT_INFO_P2_5_OFFSET;
411+
}
412+
413+
return readl_relaxed(xp->pmu_base - CMN_PMU_OFFSET + offset);
414+
}
415+
399416
static struct dentry *arm_cmn_debugfs;
400417

401418
#ifdef CONFIG_DEBUG_FS
@@ -469,22 +486,17 @@ static int arm_cmn_map_show(struct seq_file *s, void *data)
469486
y = cmn->mesh_y;
470487
while (y--) {
471488
int xp_base = cmn->mesh_x * y;
472-
u8 port[6][CMN_MAX_DIMENSION];
489+
u8 port[CMN_MAX_PORTS][CMN_MAX_DIMENSION];
473490

474491
for (x = 0; x < cmn->mesh_x; x++)
475492
seq_puts(s, "--------+");
476493

477494
seq_printf(s, "\n%d |", y);
478495
for (x = 0; x < cmn->mesh_x; x++) {
479496
struct arm_cmn_node *xp = cmn->xps + xp_base + x;
480-
void __iomem *base = xp->pmu_base - CMN_PMU_OFFSET;
481-
482-
port[0][x] = readl_relaxed(base + CMN_MXP__CONNECT_INFO_P0);
483-
port[1][x] = readl_relaxed(base + CMN_MXP__CONNECT_INFO_P1);
484-
port[2][x] = readl_relaxed(base + CMN_MXP__CONNECT_INFO_P2);
485-
port[3][x] = readl_relaxed(base + CMN_MXP__CONNECT_INFO_P3);
486-
port[4][x] = readl_relaxed(base + CMN_MXP__CONNECT_INFO_P4);
487-
port[5][x] = readl_relaxed(base + CMN_MXP__CONNECT_INFO_P5);
497+
498+
for (p = 0; p < CMN_MAX_PORTS; p++)
499+
port[p][x] = arm_cmn_device_connect_info(cmn, xp, p);
488500
seq_printf(s, " XP #%-2d |", xp_base + x);
489501
}
490502

@@ -2083,18 +2095,9 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
20832095
* from this, since in that case we will see at least one XP
20842096
* with port 2 connected, for the HN-D.
20852097
*/
2086-
if (readq_relaxed(xp_region + CMN_MXP__CONNECT_INFO_P0))
2087-
xp_ports |= BIT(0);
2088-
if (readq_relaxed(xp_region + CMN_MXP__CONNECT_INFO_P1))
2089-
xp_ports |= BIT(1);
2090-
if (readq_relaxed(xp_region + CMN_MXP__CONNECT_INFO_P2))
2091-
xp_ports |= BIT(2);
2092-
if (readq_relaxed(xp_region + CMN_MXP__CONNECT_INFO_P3))
2093-
xp_ports |= BIT(3);
2094-
if (readq_relaxed(xp_region + CMN_MXP__CONNECT_INFO_P4))
2095-
xp_ports |= BIT(4);
2096-
if (readq_relaxed(xp_region + CMN_MXP__CONNECT_INFO_P5))
2097-
xp_ports |= BIT(5);
2098+
for (int p = 0; p < CMN_MAX_PORTS; p++)
2099+
if (arm_cmn_device_connect_info(cmn, xp, p))
2100+
xp_ports |= BIT(p);
20982101

20992102
if (cmn->multi_dtm && (xp_ports & 0xc))
21002103
arm_cmn_init_dtm(dtm++, xp, 1);

0 commit comments

Comments
 (0)