From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 14/16] drivers/perf: arm_pmu: add ACPI framework
Date: Fri, 7 Apr 2017 15:27:06 +0100 [thread overview]
Message-ID: <20170407142706.GN19342@arm.com> (raw)
In-Reply-To: <1491503363-17731-15-git-send-email-mark.rutland@arm.com>
Hi Mark,
Just a couple of minor comments below.
On Thu, Apr 06, 2017 at 07:29:21PM +0100, Mark Rutland wrote:
> diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
> new file mode 100644
> index 0000000..5cacd7b
> --- /dev/null
> +++ b/drivers/perf/arm_pmu_acpi.c
> @@ -0,0 +1,240 @@
> +/*
> + * ACPI probing code for ARM performance counters.
> + *
> + * Copyright (C) 2017 ARM Ltd.
> + *
> + * 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/acpi.h>
> +#include <linux/cpumask.h>
> +#include <linux/init.h>
> +#include <linux/percpu.h>
> +#include <linux/perf/arm_pmu.h>
> +
> +#include <asm/cputype.h>
> +
> +static DEFINE_PER_CPU(struct arm_pmu *, probed_pmus);
> +static DEFINE_PER_CPU(int, pmu_irqs);
> +
> +static int arm_pmu_acpi_parse_irq(int cpu)
> +{
> + struct acpi_madt_generic_interrupt *gicc;
> + int gsi, trigger;
> +
> + gicc = acpi_cpu_get_madt_gicc(cpu);
> + if (WARN_ON(!gicc))
> + return -EINVAL;
> +
> + gsi = gicc->performance_interrupt;
> + if (gicc->flags & ACPI_MADT_PERFORMANCE_IRQ_MODE)
> + trigger = ACPI_EDGE_SENSITIVE;
> + else
> + trigger = ACPI_LEVEL_SENSITIVE;
> +
> + /*
> + * Helpfully, the MADT GICC doesn't have a polarity flag for the
> + * "performance interrupt". Luckily, on compliant GICs the polarity is
> + * fixed in HW (for both SPIs and PPIs), and thus we don't care. Other
> + * interrupt controllers are not supported with ACPI.
> + *
> + * Here we pass in ACPI_ACTIVE_HIGH to keep the core code happy.
> + */
> + return acpi_register_gsi(NULL, gsi, trigger, ACPI_ACTIVE_HIGH);
> +}
> +
> +static void arm_pmu_acpi_unparse_irq(int cpu)
> +{
"unparse" is a bit weird. Can you rename this register/unregister please?
> + struct acpi_madt_generic_interrupt *gicc;
> + int gsi;
> +
> + gicc = acpi_cpu_get_madt_gicc(cpu);
> + if (!gicc)
> + return;
> +
> + gsi = gicc->performance_interrupt;
> + acpi_unregister_gsi(gsi);
> +}
> +
> +static int arm_pmu_acpi_parse_irqs(void)
> +{
> + int cpu, irq;
> +
> + for_each_possible_cpu(cpu) {
> + int irq = arm_pmu_acpi_parse_irq(cpu);
> + if (irq < 0) {
> + pr_warn("Unable to parse ACPI PMU IRQ for CPU%d: %d\n",
> + cpu, irq);
> + goto out_err;
> + } else if (irq == 0) {
> + pr_warn("No ACPI PMU IRQ for CPU%d\n", cpu);
> + }
> +
> + per_cpu(pmu_irqs, cpu) = irq;
> + }
> +
> + return 0;
> +
> +out_err:
> + for_each_possible_cpu(cpu) {
> + arm_pmu_acpi_unparse_irq(cpu);
> + per_cpu(pmu_irqs, cpu) = 0;
> + }
It might work at the moment (I really can't tell), but I'd rather we didn't
unregister GSIs that we didn't register.
Will
next prev parent reply other threads:[~2017-04-07 14:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 18:29 [PATCHv2 00/16] arm_pmu: ACPI support Mark Rutland
2017-04-06 18:29 ` [PATCHv2 01/16] drivers/perf: arm_pmu: remove pointless PMU disabling Mark Rutland
2017-04-06 18:29 ` [PATCHv2 02/16] drivers/perf: arm_pmu: define armpmu_init_fn Mark Rutland
2017-04-06 18:29 ` [PATCHv2 03/16] drivers/perf: arm_pmu: fold init into alloc Mark Rutland
2017-04-06 18:29 ` [PATCHv2 04/16] drivers/perf: arm_pmu: factor out pmu registration Mark Rutland
2017-04-06 18:29 ` [PATCHv2 05/16] drivers/perf: arm_pmu: simplify cpu_pmu_request_irqs() Mark Rutland
2017-04-06 18:29 ` [PATCHv2 06/16] drivers/perf: arm_pmu: handle no platform_device Mark Rutland
2017-04-06 18:29 ` [PATCHv2 07/16] drivers/perf: arm_pmu: rename irq request/free functions Mark Rutland
2017-04-06 18:29 ` [PATCHv2 08/16] drivers/perf: arm_pmu: split cpu-local irq request/free Mark Rutland
2017-04-06 18:29 ` [PATCHv2 09/16] drivers/perf: arm_pmu: move irq request/free into probe Mark Rutland
2017-04-06 18:29 ` [PATCHv2 10/16] drivers/perf: arm_pmu: split out platform device probe logic Mark Rutland
2017-04-06 18:29 ` [PATCHv2 11/16] arm64: add function to get a cpu's MADT GICC table Mark Rutland
2017-04-06 18:29 ` [PATCHv2 12/16] arm64: parking: kill acpi_set_mailbox_entry() Mark Rutland
2017-04-06 18:29 ` [PATCHv2 13/16] arm64: parking: fix type endianness Mark Rutland
2017-04-06 18:29 ` [PATCHv2 14/16] drivers/perf: arm_pmu: add ACPI framework Mark Rutland
2017-04-07 14:27 ` Will Deacon [this message]
2017-04-07 14:49 ` Mark Rutland
2017-04-06 18:29 ` [PATCHv2 15/16] arm64: pmuv3: handle !PMUv3 when probing Mark Rutland
2017-04-07 14:29 ` Will Deacon
2017-04-07 16:30 ` Mark Rutland
2017-04-07 18:05 ` Mark Rutland
2017-04-07 19:09 ` Jeremy Linton
2017-04-06 18:29 ` [PATCHv2 16/16] arm64: pmuv3: use arm_pmu ACPI framework Mark Rutland
2017-04-07 14:30 ` [PATCHv2 00/16] arm_pmu: ACPI support Will Deacon
2017-04-07 16:13 ` Mark Rutland
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=20170407142706.GN19342@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).