Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93b0e1f1 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge changes I369be003,I8fde4384,Ia18788cc,Iec4e1d03,If540bdef into msm-4.14

* changes:
  perf: dsu: Use signed field for dsu_pmu->num_counters
  perf: ARM DynamIQ Shared Unit PMU support
  dt-bindings: Document devicetree binding for ARM DSU PMU
  arm_pmu: Use of_cpu_node_to_id helper
  arm64: Use of_cpu_node_to_id helper for CPU topology parsing
parents 411c04e5 3ed9e5db
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
* ARM DynamIQ Shared Unit (DSU) Performance Monitor Unit (PMU)

ARM DyanmIQ Shared Unit (DSU) integrates one or more CPU cores
with a shared L3 memory system, control logic and external interfaces to
form a multicore cluster. The PMU enables to gather various statistics on
the operations of the DSU. The PMU provides independent 32bit counters that
can count any of the supported events, along with a 64bit cycle counter.
The PMU is accessed via CPU system registers and has no MMIO component.

** DSU PMU required properties:

- compatible	: should be one of :

		"arm,dsu-pmu"

- interrupts	: Exactly 1 SPI must be listed.

- cpus		: List of phandles for the CPUs connected to this DSU instance.


** Example:

dsu-pmu-0 {
	compatible = "arm,dsu-pmu";
	interrupts = <GIC_SPI 02 IRQ_TYPE_LEVEL_HIGH>;
	cpus = <&cpu_0>, <&cpu_1>;
};
+28 −0
Original line number Diff line number Diff line
ARM DynamIQ Shared Unit (DSU) PMU
==================================

ARM DynamIQ Shared Unit integrates one or more cores with an L3 memory system,
control logic and external interfaces to form a multicore cluster. The PMU
allows counting the various events related to the L3 cache, Snoop Control Unit
etc, using 32bit independent counters. It also provides a 64bit cycle counter.

The PMU can only be accessed via CPU system registers and are common to the
cores connected to the same DSU. Like most of the other uncore PMUs, DSU
PMU doesn't support process specific events and cannot be used in sampling mode.

The DSU provides a bitmap for a subset of implemented events via hardware
registers. There is no way for the driver to determine if the other events
are available or not. Hence the driver exposes only those events advertised
by the DSU, in "events" directory under :

  /sys/bus/event_sources/devices/arm_dsu_<N>/

The user should refer to the TRM of the product to figure out the supported events
and use the raw event code for the unlisted events.

The driver also exposes the CPUs connected to the DSU instance in "associated_cpus".


e.g usage :

	perf stat -a -e arm_dsu_0/cycles/
+129 −0
Original line number Diff line number Diff line
/*
 * ARM DynamIQ Shared Unit (DSU) PMU Low level register access routines.
 *
 * Copyright (C) ARM Limited, 2017.
 *
 * Author: Suzuki K Poulose <suzuki.poulose@arm.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2, as published by the Free Software Foundation.
 */

#include <linux/bitops.h>
#include <linux/build_bug.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/barrier.h>
#include <asm/sysreg.h>


#define CLUSTERPMCR_EL1			sys_reg(3, 0, 15, 5, 0)
#define CLUSTERPMCNTENSET_EL1		sys_reg(3, 0, 15, 5, 1)
#define CLUSTERPMCNTENCLR_EL1		sys_reg(3, 0, 15, 5, 2)
#define CLUSTERPMOVSSET_EL1		sys_reg(3, 0, 15, 5, 3)
#define CLUSTERPMOVSCLR_EL1		sys_reg(3, 0, 15, 5, 4)
#define CLUSTERPMSELR_EL1		sys_reg(3, 0, 15, 5, 5)
#define CLUSTERPMINTENSET_EL1		sys_reg(3, 0, 15, 5, 6)
#define CLUSTERPMINTENCLR_EL1		sys_reg(3, 0, 15, 5, 7)
#define CLUSTERPMCCNTR_EL1		sys_reg(3, 0, 15, 6, 0)
#define CLUSTERPMXEVTYPER_EL1		sys_reg(3, 0, 15, 6, 1)
#define CLUSTERPMXEVCNTR_EL1		sys_reg(3, 0, 15, 6, 2)
#define CLUSTERPMMDCR_EL1		sys_reg(3, 0, 15, 6, 3)
#define CLUSTERPMCEID0_EL1		sys_reg(3, 0, 15, 6, 4)
#define CLUSTERPMCEID1_EL1		sys_reg(3, 0, 15, 6, 5)

static inline u32 __dsu_pmu_read_pmcr(void)
{
	return read_sysreg_s(CLUSTERPMCR_EL1);
}

static inline void __dsu_pmu_write_pmcr(u32 val)
{
	write_sysreg_s(val, CLUSTERPMCR_EL1);
	isb();
}

static inline u32 __dsu_pmu_get_reset_overflow(void)
{
	u32 val = read_sysreg_s(CLUSTERPMOVSCLR_EL1);
	/* Clear the bit */
	write_sysreg_s(val, CLUSTERPMOVSCLR_EL1);
	isb();
	return val;
}

static inline void __dsu_pmu_select_counter(int counter)
{
	write_sysreg_s(counter, CLUSTERPMSELR_EL1);
	isb();
}

static inline u64 __dsu_pmu_read_counter(int counter)
{
	__dsu_pmu_select_counter(counter);
	return read_sysreg_s(CLUSTERPMXEVCNTR_EL1);
}

static inline void __dsu_pmu_write_counter(int counter, u64 val)
{
	__dsu_pmu_select_counter(counter);
	write_sysreg_s(val, CLUSTERPMXEVCNTR_EL1);
	isb();
}

static inline void __dsu_pmu_set_event(int counter, u32 event)
{
	__dsu_pmu_select_counter(counter);
	write_sysreg_s(event, CLUSTERPMXEVTYPER_EL1);
	isb();
}

static inline u64 __dsu_pmu_read_pmccntr(void)
{
	return read_sysreg_s(CLUSTERPMCCNTR_EL1);
}

static inline void __dsu_pmu_write_pmccntr(u64 val)
{
	write_sysreg_s(val, CLUSTERPMCCNTR_EL1);
	isb();
}

static inline void __dsu_pmu_disable_counter(int counter)
{
	write_sysreg_s(BIT(counter), CLUSTERPMCNTENCLR_EL1);
	isb();
}

static inline void __dsu_pmu_enable_counter(int counter)
{
	write_sysreg_s(BIT(counter), CLUSTERPMCNTENSET_EL1);
	isb();
}

static inline void __dsu_pmu_counter_interrupt_enable(int counter)
{
	write_sysreg_s(BIT(counter), CLUSTERPMINTENSET_EL1);
	isb();
}

static inline void __dsu_pmu_counter_interrupt_disable(int counter)
{
	write_sysreg_s(BIT(counter), CLUSTERPMINTENCLR_EL1);
	isb();
}


static inline u32 __dsu_pmu_read_pmceid(int n)
{
	switch (n) {
	case 0:
		return read_sysreg_s(CLUSTERPMCEID0_EL1);
	case 1:
		return read_sysreg_s(CLUSTERPMCEID1_EL1);
	default:
		BUILD_BUG();
		return 0;
	}
}
+6 −10
Original line number Diff line number Diff line
@@ -38,18 +38,14 @@ static int __init get_cpu_for_node(struct device_node *node)
	if (!cpu_node)
		return -1;

	for_each_possible_cpu(cpu) {
		if (of_get_cpu_node(cpu, NULL) == cpu_node) {
	cpu = of_cpu_node_to_id(cpu_node);
	if (cpu >= 0)
		topology_parse_cpu_capacity(cpu_node, cpu);
			of_node_put(cpu_node);
			return cpu;
		}
	}

	pr_crit("Unable to find CPU node for %pOF\n", cpu_node);
	else
		pr_crit("Unable to find CPU node for %pKOF\n", cpu_node);

	of_node_put(cpu_node);
	return -1;
	return cpu;
}

static int __init parse_core(struct device_node *core, int cluster_id,
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,15 @@ config ARM_PMU_ACPI
	depends on ARM_PMU && ACPI
	def_bool y

config ARM_DSU_PMU
       tristate "ARM DynamIQ Shared Unit (DSU) PMU"
       depends on ARM64
         help
         Provides support for performance monitor unit in ARM DynamIQ Shared
         Unit (DSU). The DSU integrates one or more cores with an L3 memory
         system, control logic. The PMU allows counting various events related
         to DSU.

config QCOM_L2_PMU
	bool "Qualcomm Technologies L2-cache PMU"
	depends on ARCH_QCOM && ARM64 && ACPI
Loading