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

Commit 67838f80 authored by Santosh Mardi's avatar Santosh Mardi
Browse files

drivers: soc: qcom: allow setup of pmu events during hotplug



Setup pmu counter functions of rimps memlat driver check cpu_is_hp
flag before creating counters, and the setup of pmu counters will
be called in two places one in probe and other when cpu is coming
up from hotplug path.

The hotplug path will clear cpu_is_hp after the pmu setup calls are
issued, but pmu setup function will not create pmu events as the
cpu_is_hp flag not cleared at this point, this results in pmu
counters not getting setup even cpu is up from the hotplug path.

Add a parameter to these functions indicating from which path these
are called and update the logic accordingly to allow creation of
pmu events when core is coming up.

Change-Id: I8bf8d52d91d14ab3f4d837271055f03e704e98a0
Signed-off-by: default avatarSantosh Mardi <gsantosh@codeaurora.org>
parent cbcfe29a
Loading
Loading
Loading
Loading
+9 −8
Original line number Original line Diff line number Diff line
@@ -479,7 +479,7 @@ static struct perf_event *set_event(int event_id, unsigned int cpu,
}
}


static int setup_common_pmu_events(struct memlat_cpu_grp *cpu_grp,
static int setup_common_pmu_events(struct memlat_cpu_grp *cpu_grp,
				cpumask_t *mask)
				cpumask_t *mask, bool cpu_online)
{
{
	struct perf_event_attr *attr = alloc_attr();
	struct perf_event_attr *attr = alloc_attr();
	struct perf_event *pevent;
	struct perf_event *pevent;
@@ -489,7 +489,7 @@ static int setup_common_pmu_events(struct memlat_cpu_grp *cpu_grp,
		struct pmu_map *pmu = to_common_pmu_map(cpu_grp, cpu);
		struct pmu_map *pmu = to_common_pmu_map(cpu_grp, cpu);
		struct cpu_data *cpus_data = to_cpu_data(cpu_grp, cpu);
		struct cpu_data *cpus_data = to_cpu_data(cpu_grp, cpu);


		if (per_cpu(cpu_is_hp, cpu))
		if (!cpu_online && per_cpu(cpu_is_hp, cpu))
			continue;
			continue;


		pevent = set_event(cpu_grp->common_ev_ids[INST_IDX],
		pevent = set_event(cpu_grp->common_ev_ids[INST_IDX],
@@ -533,7 +533,8 @@ static int setup_common_pmu_events(struct memlat_cpu_grp *cpu_grp,
	return 0;
	return 0;
}
}


static int setup_mon_pmu_events(struct memlat_mon *mon, cpumask_t *mask)
static int setup_mon_pmu_events(struct memlat_mon *mon,
					cpumask_t *mask, bool cpu_online)
{
{
	struct perf_event_attr *attr = alloc_attr();
	struct perf_event_attr *attr = alloc_attr();
	struct perf_event *pevent;
	struct perf_event *pevent;
@@ -543,7 +544,7 @@ static int setup_mon_pmu_events(struct memlat_mon *mon, cpumask_t *mask)
		struct pmu_map *pmu = to_mon_pmu_map(mon, cpu);
		struct pmu_map *pmu = to_mon_pmu_map(mon, cpu);
		struct mon_data *ev_data = to_mon_ev_data(mon, cpu);
		struct mon_data *ev_data = to_mon_ev_data(mon, cpu);


		if (per_cpu(cpu_is_hp, cpu))
		if (!cpu_online && per_cpu(cpu_is_hp, cpu))
			continue;
			continue;


		pevent = set_event(mon->mon_ev_ids[MISS_IDX], cpu, attr);
		pevent = set_event(mon->mon_ev_ids[MISS_IDX], cpu, attr);
@@ -708,7 +709,7 @@ static int memlat_hp_restart_events(unsigned int cpu, bool cpu_up)
		set_pmu_cache_flag(PMU_MAP_INVALID, cpu);
		set_pmu_cache_flag(PMU_MAP_INVALID, cpu);


	if (cpu_up) {
	if (cpu_up) {
		ret = setup_common_pmu_events(cpu_grp, &mask);
		ret = setup_common_pmu_events(cpu_grp, &mask, true);
		if (ret < 0) {
		if (ret < 0) {
			pr_err("failed to setup common PMU cpu = %d ret %d\n",
			pr_err("failed to setup common PMU cpu = %d ret %d\n",
					cpu, ret);
					cpu, ret);
@@ -735,7 +736,7 @@ static int memlat_hp_restart_events(unsigned int cpu, bool cpu_up)
		if (!cpumask_test_cpu(cpu, &mon->cpus))
		if (!cpumask_test_cpu(cpu, &mon->cpus))
			continue;
			continue;
		if (cpu_up) {
		if (cpu_up) {
			ret = setup_mon_pmu_events(mon, &mask);
			ret = setup_mon_pmu_events(mon, &mask, true);
			if (ret < 0) {
			if (ret < 0) {
				pr_err("mon events failed on cpu %d ret %d\n",
				pr_err("mon events failed on cpu %d ret %d\n",
						cpu, ret);
						cpu, ret);
@@ -1261,7 +1262,7 @@ static int memlat_cpu_grp_probe(struct platform_device *pdev)
		put_online_cpus();
		put_online_cpus();
	}
	}


	ret = setup_common_pmu_events(cpu_grp, &cpu_grp->cpus);
	ret = setup_common_pmu_events(cpu_grp, &cpu_grp->cpus, false);
	if (ret < 0) {
	if (ret < 0) {
		dev_err(dev, "failed to setup common evs = %d\n", ret);
		dev_err(dev, "failed to setup common evs = %d\n", ret);
		return ret;
		return ret;
@@ -1377,7 +1378,7 @@ static int memlat_mon_probe(struct platform_device *pdev, u32 mon_type)
	} else {
	} else {
		mon->mon_ev_ids[L3_ACCESS_IDX] = event_id;
		mon->mon_ev_ids[L3_ACCESS_IDX] = event_id;
	}
	}
	setup_mon_pmu_events(mon, &mon->cpus);
	setup_mon_pmu_events(mon, &mon->cpus, false);
	if (mon->mon_type == L3_MEMLAT) {
	if (mon->mon_type == L3_MEMLAT) {
		if (!use_cached_l3_freqs) {
		if (!use_cached_l3_freqs) {
			ret = populate_opp_table(dev);
			ret = populate_opp_table(dev);