From: Jeremy Linton <jeremy.linton@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, will.deacon@arm.com, mark.rutland@arm.com, punit.agrawal@arm.com, steve.capper@arm.com, msalter@redhat.com, mlangsdorf@redhat.com, linux@armlinux.org.uk, lorenzo.pieralisi@arm.com, bamvor.zhangjian@linaro.org Subject: [PATCH v14 3/6] arm: arm64: pmu: Assign platform PMU CPU affinity Date: Mon, 23 Jan 2017 16:32:42 -0600 [thread overview] Message-ID: <1485210765-9422-4-git-send-email-jeremy.linton@arm.com> (raw) In-Reply-To: <1485210765-9422-1-git-send-email-jeremy.linton@arm.com> On systems with multiple PMU types the PMU to CPU affinity needs to be detected and set. The CPU to interrupt affinity should also be set. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> --- drivers/perf/arm_pmu.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 6d93358..37e241f 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -11,6 +11,7 @@ */ #define pr_fmt(fmt) "hw perfevents: " fmt +#include <linux/acpi.h> #include <linux/bitmap.h> #include <linux/cpumask.h> #include <linux/cpu_pm.h> @@ -24,6 +25,7 @@ #include <linux/irq.h> #include <linux/irqdesc.h> +#include <asm/cpu.h> #include <asm/cputype.h> #include <asm/irq_regs.h> @@ -889,25 +891,47 @@ static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu) } /* - * CPU PMU identification and probing. + * CPU PMU identification and probing. Its possible to have + * multiple CPU types in an ARM machine. Assure that we are + * picking the right PMU types based on the CPU in question */ -static int probe_current_pmu(struct arm_pmu *pmu, - const struct pmu_probe_info *info) +static int probe_plat_pmu(struct arm_pmu *pmu, + const struct pmu_probe_info *info, + unsigned int pmuid) { - int cpu = get_cpu(); - unsigned int cpuid = read_cpuid_id(); int ret = -ENODEV; + int cpu; + int aff_ctr = 0; + struct platform_device *pdev = pmu->plat_device; + int irq = platform_get_irq(pdev, 0); - pr_info("probing PMU on CPU %d\n", cpu); + if (irq >= 0 && !irq_is_percpu(irq)) { + pmu->irq_affinity = kcalloc(pdev->num_resources, sizeof(int), + GFP_KERNEL); + if (!pmu->irq_affinity) + return -ENOMEM; + } + + for_each_possible_cpu(cpu) { + unsigned int cpuid = read_specific_cpuid(cpu); + + if (cpuid == pmuid) { + cpumask_set_cpu(cpu, &pmu->supported_cpus); + if (pmu->irq_affinity) { + pmu->irq_affinity[aff_ctr] = cpu; + aff_ctr++; + } + } + } + /* find the type of PMU given the CPU */ for (; info->init != NULL; info++) { - if ((cpuid & info->mask) != info->cpuid) + if ((pmuid & info->mask) != info->cpuid) continue; ret = info->init(pmu); break; } - put_cpu(); return ret; } @@ -1043,8 +1067,7 @@ int arm_pmu_device_probe(struct platform_device *pdev, if (!ret) ret = init_fn(pmu); } else if (probe_table) { - cpumask_setall(&pmu->supported_cpus); - ret = probe_current_pmu(pmu, probe_table); + ret = probe_plat_pmu(pmu, probe_table, read_cpuid_id()); } if (ret) { -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: jeremy.linton@arm.com (Jeremy Linton) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v14 3/6] arm: arm64: pmu: Assign platform PMU CPU affinity Date: Mon, 23 Jan 2017 16:32:42 -0600 [thread overview] Message-ID: <1485210765-9422-4-git-send-email-jeremy.linton@arm.com> (raw) In-Reply-To: <1485210765-9422-1-git-send-email-jeremy.linton@arm.com> On systems with multiple PMU types the PMU to CPU affinity needs to be detected and set. The CPU to interrupt affinity should also be set. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> --- drivers/perf/arm_pmu.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 6d93358..37e241f 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -11,6 +11,7 @@ */ #define pr_fmt(fmt) "hw perfevents: " fmt +#include <linux/acpi.h> #include <linux/bitmap.h> #include <linux/cpumask.h> #include <linux/cpu_pm.h> @@ -24,6 +25,7 @@ #include <linux/irq.h> #include <linux/irqdesc.h> +#include <asm/cpu.h> #include <asm/cputype.h> #include <asm/irq_regs.h> @@ -889,25 +891,47 @@ static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu) } /* - * CPU PMU identification and probing. + * CPU PMU identification and probing. Its possible to have + * multiple CPU types in an ARM machine. Assure that we are + * picking the right PMU types based on the CPU in question */ -static int probe_current_pmu(struct arm_pmu *pmu, - const struct pmu_probe_info *info) +static int probe_plat_pmu(struct arm_pmu *pmu, + const struct pmu_probe_info *info, + unsigned int pmuid) { - int cpu = get_cpu(); - unsigned int cpuid = read_cpuid_id(); int ret = -ENODEV; + int cpu; + int aff_ctr = 0; + struct platform_device *pdev = pmu->plat_device; + int irq = platform_get_irq(pdev, 0); - pr_info("probing PMU on CPU %d\n", cpu); + if (irq >= 0 && !irq_is_percpu(irq)) { + pmu->irq_affinity = kcalloc(pdev->num_resources, sizeof(int), + GFP_KERNEL); + if (!pmu->irq_affinity) + return -ENOMEM; + } + + for_each_possible_cpu(cpu) { + unsigned int cpuid = read_specific_cpuid(cpu); + + if (cpuid == pmuid) { + cpumask_set_cpu(cpu, &pmu->supported_cpus); + if (pmu->irq_affinity) { + pmu->irq_affinity[aff_ctr] = cpu; + aff_ctr++; + } + } + } + /* find the type of PMU given the CPU */ for (; info->init != NULL; info++) { - if ((cpuid & info->mask) != info->cpuid) + if ((pmuid & info->mask) != info->cpuid) continue; ret = info->init(pmu); break; } - put_cpu(); return ret; } @@ -1043,8 +1067,7 @@ int arm_pmu_device_probe(struct platform_device *pdev, if (!ret) ret = init_fn(pmu); } else if (probe_table) { - cpumask_setall(&pmu->supported_cpus); - ret = probe_current_pmu(pmu, probe_table); + ret = probe_plat_pmu(pmu, probe_table, read_cpuid_id()); } if (ret) { -- 2.7.4
next prev parent reply other threads:[~2017-01-23 22:33 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-01-23 22:32 [PATCH v14 0/6] Enable PMUs in ACPI systems Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton 2017-01-23 22:32 ` [PATCH v14 1/6] arm: arm64: Add routine to determine cpuid of other cpus Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton 2017-01-23 22:32 ` [PATCH v14 2/6] arm64: pmu: Cache PMU interrupt numbers from MADT parse Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton [this message] 2017-01-23 22:32 ` [PATCH v14 3/6] arm: arm64: pmu: Assign platform PMU CPU affinity Jeremy Linton 2017-01-23 22:32 ` [PATCH v14 4/6] arm64: pmu: Detect multiple generic PMUs and append counter Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton 2017-01-23 22:32 ` [PATCH v14 5/6] arm64: pmu: Detect and enable multiple PMUs in an ACPI system Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton 2017-01-23 22:32 ` [PATCH v14 6/6] arm: pmu: Add PMU definitions for cores not initially online Jeremy Linton 2017-01-23 22:32 ` Jeremy Linton 2017-01-24 6:46 ` [PATCH v14 0/6] Enable PMUs in ACPI systems Ganapatrao Kulkarni 2017-01-24 6:46 ` Ganapatrao Kulkarni 2017-01-24 19:56 ` Jeremy Linton 2017-01-24 19:56 ` Jeremy Linton 2017-01-24 7:49 ` Hanjun Guo 2017-01-24 7:49 ` Hanjun Guo 2017-02-10 6:06 ` Ganapatrao Kulkarni 2017-02-10 6:06 ` Ganapatrao Kulkarni
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1485210765-9422-4-git-send-email-jeremy.linton@arm.com \ --to=jeremy.linton@arm.com \ --cc=bamvor.zhangjian@linaro.org \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux@armlinux.org.uk \ --cc=lorenzo.pieralisi@arm.com \ --cc=mark.rutland@arm.com \ --cc=mlangsdorf@redhat.com \ --cc=msalter@redhat.com \ --cc=punit.agrawal@arm.com \ --cc=steve.capper@arm.com \ --cc=will.deacon@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.