Skip to contentSkip to conversation

CCI PMU update

PATCH New Punit Agrawal 3 participants 6 messages Feb 19, 2014 – Feb 25, 2014

lore
Share & tools
lore
#0 lore raw

cover CCI PMU update

Hi,

Here are a short couple of patches to update the CCI PMU perf backend to better support IP updates.

The first patch simplifies version checking to assume that event numbering doesn't change for > r1p0 (it changed between r0 and r1). This change should help reduce code churn when IP version is bumped up without any changes to event numbering.

The second patch exports the PMU version to userspace (via the PMU name) to allow tooling to deal with event numbering differences.

I'd appreciate any feedback on the changes.

The patches are based on top of 3.14-rc3 and can hopefully make it for 3.15.

Thanks,
Punit

Punit Agrawal (2):
drivers: cci: Extend support to CCI revisions > r1p2
drivers: cci: Export CCI PMU revision

 drivers/bus/arm-cci.c |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/2 drivers: cci: Extend support to CCI revisions > r1p2

The driver queries the CCI IP revision to distinguish between r0 and r1 scheme for event numbers and currently supports upto version r1p2. To minimise code churn every time there's a new version of the IP, assume that event numbering doesn't change for revisions > r1p0 (which is the case).

The driver will still need an update for future revisions that change the event numbers.

---
 drivers/bus/arm-cci.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/bus/arm-cci.c +3 -9
index 962fd35..da485ae 100644
@@ -88,8 +88,7 @@ static unsigned long cci_ctrl_phys;
 
 #define CCI_REV_R0		0
 #define CCI_REV_R1		1
-#define CCI_REV_R0_P4		4
-#define CCI_REV_R1_P2		6
+#define CCI_REV_R1_PX		5
 
 #define CCI_PMU_EVT_SEL		0x000
 #define CCI_PMU_CNTR		0x004
@@ -193,21 +192,16 @@ static int probe_cci_revision(void)
 	rev = readl_relaxed(cci_ctrl_base + CCI_PID2) & CCI_PID2_REV_MASK;
 	rev >>= CCI_PID2_REV_SHIFT;
 
-	if (rev <= CCI_REV_R0_P4)
+	if (rev < CCI_REV_R1_PX)
 		return CCI_REV_R0;
-	else if (rev <= CCI_REV_R1_P2)
+	else
 		return CCI_REV_R1;
-
-	return -ENOENT;
 }
 
 static struct pmu_port_event_ranges *port_range_by_rev(void)
 {
 	int rev = probe_cci_revision();
 
-	if (rev < 0)
-		return NULL;
-
 	return &port_event_range[rev];
 }
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/2 drivers: cci: Export CCI PMU revision

In reply to Punit Agrawal

The event numbering changed between revision r0 and r1 of the CCI PMU. Expose this to userspace to allow tooling to handle the differences in event numbers.

---
 drivers/bus/arm-cci.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bus/arm-cci.c +10 -2
index da485ae..5a86da9 100644
@@ -31,7 +31,6 @@
 
 #define DRIVER_NAME		"CCI-400"
 #define DRIVER_NAME_PMU		DRIVER_NAME " PMU"
-#define PMU_NAME		"CCI_400"
 
 #define CCI_PORT_CTRL		0x0
 #define CCI_CTRL_STATUS		0xc
@@ -162,6 +161,15 @@ static struct pmu_port_event_ranges port_event_range[] = {
 	},
 };
 
+/*
+ * Export different PMU names for the different revisions so userspace knows
+ * because the event ids are different
+ */
+static char *const pmu_names[] = {
+	[CCI_REV_R0] = "CCI_400",
+	[CCI_REV_R1] = "CCI_400_r1",
+};
+
 struct cci_pmu_drv_data {
 	void __iomem *base;
 	struct arm_pmu *cci_pmu;
@@ -520,7 +528,7 @@ static void pmu_write_counter(struct perf_event *event, u32 value)
 static int cci_pmu_init(struct arm_pmu *cci_pmu, struct platform_device *pdev)
 {
 	*cci_pmu = (struct arm_pmu){
-		.name             = PMU_NAME,
+		.name		  = pmu_names[probe_cci_revision()],
 		.max_period       = (1LLU << 32) - 1,
 		.get_hw_events    = pmu_get_hw_events,
 		.get_event_idx    = pmu_get_event_idx,
Signature · 1 line
1.7.10.4
#3 lore raw

cover CCI PMU update

In reply to Punit Agrawal

[adding Olof and arm at kernel.org]

Quoted 8 lines · Punit Agrawal

Here are a short couple of patches to update the CCI PMU perf backend to better support IP updates.

The first patch simplifies version checking to assume that event numbering doesn't change for > r1p0 (it changed between r0 and r1). This change should help reduce code churn when IP version is bumped up without any changes to event numbering.

Quoted 7 lines

The second patch exports the PMU version to userspace (via the PMU name) to allow tooling to deal with event numbering differences.

I'd appreciate any feedback on the changes.

The patches are based on top of 3.14-rc3 and can hopefully make it for 3.15.

Since these patches [1] are small and trivial, would the arm-soc folk be happy picking them directly? I can put together a branch and pull request if necessary, but it seems a bit OTT for this.

Will

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-February/234041.html

#4 lore raw

cover CCI PMU update

Quoted 4 lines · Will Deacon

Since these patches [1] are small and trivial, would the arm-soc folk be happy picking them directly? I can put together a branch and pull request if necessary, but it seems a bit OTT for this.

Applied into next/drivers now

Arnd

#5 lore raw

cover CCI PMU update

Quoted 7 lines · Arnd Bergmann
Quoted 4 lines · Will Deacon

Since these patches [1] are small and trivial, would the arm-soc folk be happy picking them directly? I can put together a branch and pull request if necessary, but it seems a bit OTT for this.

Applied into next/drivers now

Thanks, Arnd.

Will