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

Commit ad9b5da1 authored by Raghavendra Rao Ananta's avatar Raghavendra Rao Ananta Committed by Sundara Vinayagam
Browse files

perf: Reorder idle notifier registration in armv7 PMU



The registration of idle notifier in the armv7 PMU driver is
currently being done as a part of the probe. However, issues
might arise if the idle notifier is called during the probe
itself as the data used by the notifier callback would not
have been initialized yet. As a result, move the registration
of idle notifier after the probe completes successfully.

Change-Id: Ifb3e2bc9eed5a42fcf876274ea644c99ebef2a08
Signed-off-by: default avatarRaghavendra Rao Ananta <rananta@codeaurora.org>
Signed-off-by: default avatarSundara Vinayagam <sundvi@codeaurora.org>
parent e5929710
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -1225,25 +1225,9 @@ static int armv7_pmu_idle_notifier(struct notifier_block *nb,

static int armv7_probe_pmu(struct arm_pmu *arm_pmu)
{
	int ret;
	struct armv7_pmu_idle_nb *pmu_idle_nb;

	pmu_idle_nb = devm_kzalloc(&arm_pmu->plat_device->dev,
				sizeof(*pmu_idle_nb), GFP_KERNEL);
	if (!pmu_idle_nb)
		return -ENOMEM;

	ret = smp_call_function_any(&arm_pmu->supported_cpus,
	return smp_call_function_any(&arm_pmu->supported_cpus,
				     armv7_read_num_pmnc_events,
				     &arm_pmu->num_events, 1);
	if (ret)
		return ret;

	pmu_idle_nb->cpu_pmu = arm_pmu;
	pmu_idle_nb->perf_cpu_idle_nb.notifier_call = armv7_pmu_idle_notifier;
	idle_notifier_register(&pmu_idle_nb->perf_cpu_idle_nb);

	return 0;
}

static int armv7_a8_pmu_init(struct arm_pmu *cpu_pmu)
@@ -2077,8 +2061,24 @@ static const struct pmu_probe_info armv7_pmu_probe_table[] = {

static int armv7_pmu_device_probe(struct platform_device *pdev)
{
	return arm_pmu_device_probe(pdev, armv7_pmu_of_device_ids,
	int ret;
	struct armv7_pmu_idle_nb *pmu_idle_nb;

	pmu_idle_nb = devm_kzalloc(&pdev->dev, sizeof(*pmu_idle_nb),
				    GFP_KERNEL);
	if (!pmu_idle_nb)
		return -ENOMEM;

	ret = arm_pmu_device_probe(pdev, armv7_pmu_of_device_ids,
				    armv7_pmu_probe_table);
	if (ret)
		return ret;

	pmu_idle_nb->cpu_pmu = (struct arm_pmu *) platform_get_drvdata(pdev);
	pmu_idle_nb->perf_cpu_idle_nb.notifier_call = armv7_pmu_idle_notifier;
	idle_notifier_register(&pmu_idle_nb->perf_cpu_idle_nb);

	return 0;
}

static struct platform_driver armv7_pmu_driver = {
+1 −0
Original line number Diff line number Diff line
@@ -1128,6 +1128,7 @@ int arm_pmu_device_probe(struct platform_device *pdev,
	armpmu_init(pmu);

	pmu->plat_device = pdev;
	platform_set_drvdata(pdev, pmu);

	if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) {
		init_fn = of_id->data;