All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Jeremy Linton <jeremy.linton@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org,
	mark.rutland@arm.com, lorenzo.pieralisi@arm.com,
	catalin.marinas@arm.com, peterz@infradead.org, mingo@redhat.com,
	acme@kernel.org, alexander.shishkin@linux.intel.com,
	mlangsdorf@redhat.com
Subject: Re: [PATCH 3/8] arm64: pmu: Add support for probing with ACPI
Date: Wed, 15 Jun 2016 12:33:33 +0100	[thread overview]
Message-ID: <20160615113333.GI24029@arm.com> (raw)
In-Reply-To: <1465511013-10742-4-git-send-email-jeremy.linton@arm.com>

On Thu, Jun 09, 2016 at 05:23:28PM -0500, Jeremy Linton wrote:
> From: Mark Salter <msalter@redhat.com>
> 
> In the case of ACPI, the PMU IRQ information is contained in the
> MADT table. Also, since the PMU does not exist as a device in the
> ACPI DSDT table, it is necessary to create a platform device so
> that the appropriate driver probing is triggered.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
> 
>  NOTE: Much of the code in pmu_acpi_init() is replaced in a later version
>        of this patch. The later version of the patch cleans up some of the
>        possible style/error handling issues that have been pointed out with
>        this version.
> 
>  arch/arm64/kernel/smp.c      |  5 +++
>  drivers/perf/Kconfig         |  4 ++
>  drivers/perf/Makefile        |  1 +
>  drivers/perf/arm_pmu_acpi.c  | 97 ++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/perf/arm_pmu.h |  7 ++++
>  5 files changed, 114 insertions(+)
>  create mode 100644 drivers/perf/arm_pmu_acpi.c
> 
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 678e084..5c96d23 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -37,6 +37,7 @@
>  #include <linux/completion.h>
>  #include <linux/of.h>
>  #include <linux/irq_work.h>
> +#include <linux/perf/arm_pmu.h>
>  
>  #include <asm/alternative.h>
>  #include <asm/atomic.h>
> @@ -540,6 +541,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
>  			return;
>  		}
>  		bootcpu_valid = true;
> +		arm_pmu_parse_acpi(0, processor);
>  		return;
>  	}
>  
> @@ -560,6 +562,9 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
>  	 */
>  	acpi_set_mailbox_entry(cpu_count, processor);
>  
> +	/* get PMU irq info */
> +	arm_pmu_parse_acpi(cpu_count, processor);
> +

Nit: the outer functions are now misnomers, since this has nothing to do
with the GIC. It feels like acpi_parse_gic_cpu_interface could use some
slight restructuring so that the MADT parsing looks less confused.

> diff --git a/drivers/perf/Makefile b/drivers/perf/Makefile
> index acd2397..fd8090d 100644
> --- a/drivers/perf/Makefile
> +++ b/drivers/perf/Makefile
> @@ -1 +1,2 @@
>  obj-$(CONFIG_ARM_PMU) += arm_pmu.o
> +obj-$(CONFIG_ARM_PMU_ACPI) += arm_pmu_acpi.o
> diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
> new file mode 100644
> index 0000000..98c452d
> --- /dev/null
> +++ b/drivers/perf/arm_pmu_acpi.c
> @@ -0,0 +1,97 @@
> +/*
> + * PMU support
> + *
> + * Copyright (C) 2015 Red Hat Inc.
> + * Author: Mark Salter <msalter@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include <linux/perf/arm_pmu.h>
> +#include <linux/platform_device.h>
> +#include <linux/acpi.h>
> +#include <linux/irq.h>
> +#include <linux/irqdesc.h>
> +
> +#define PMU_PDEV_NAME "armv8-pmu"

Stick this in include/linux/perf/arm_pmu.h where we can use it in the driver
code too?

> +
> +struct pmu_irq {
> +	int gsi;
> +	int trigger;
> +};
> +
> +static struct pmu_irq pmu_irqs[NR_CPUS] __initdata;
> +
> +void __init arm_pmu_parse_acpi(int cpu, struct acpi_madt_generic_interrupt *gic)
> +{
> +	pmu_irqs[cpu].gsi = gic->performance_interrupt;
> +	if (gic->flags & ACPI_MADT_PERFORMANCE_IRQ_MODE)
> +		pmu_irqs[cpu].trigger = ACPI_EDGE_SENSITIVE;
> +	else
> +		pmu_irqs[cpu].trigger = ACPI_LEVEL_SENSITIVE;
> +}
> +
> +static int __init pmu_acpi_init(void)
> +{
> +	struct platform_device *pdev;
> +	struct pmu_irq *pirq = pmu_irqs;
> +	struct resource	*res, *r;
> +	int err = -ENOMEM;
> +	int i, count, irq;
> +
> +	if (acpi_disabled)
> +		return 0;
> +
> +	/* Must have irq for boot boot cpu, at least */

boot boot

> +	if (pirq->gsi == 0)
> +		return -EINVAL;
> +
> +	irq = acpi_register_gsi(NULL, pirq->gsi, pirq->trigger,
> +				ACPI_ACTIVE_HIGH);

This is quite tricky to read, thanks to the aliasing of pirq and
pmu_irqs[0]. Why is it necessary to register the first gsi separately,
rather than just register it later in the loop with all the other
interrupts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] arm64: pmu: Add support for probing with ACPI
Date: Wed, 15 Jun 2016 12:33:33 +0100	[thread overview]
Message-ID: <20160615113333.GI24029@arm.com> (raw)
In-Reply-To: <1465511013-10742-4-git-send-email-jeremy.linton@arm.com>

On Thu, Jun 09, 2016 at 05:23:28PM -0500, Jeremy Linton wrote:
> From: Mark Salter <msalter@redhat.com>
> 
> In the case of ACPI, the PMU IRQ information is contained in the
> MADT table. Also, since the PMU does not exist as a device in the
> ACPI DSDT table, it is necessary to create a platform device so
> that the appropriate driver probing is triggered.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
> 
>  NOTE: Much of the code in pmu_acpi_init() is replaced in a later version
>        of this patch. The later version of the patch cleans up some of the
>        possible style/error handling issues that have been pointed out with
>        this version.
> 
>  arch/arm64/kernel/smp.c      |  5 +++
>  drivers/perf/Kconfig         |  4 ++
>  drivers/perf/Makefile        |  1 +
>  drivers/perf/arm_pmu_acpi.c  | 97 ++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/perf/arm_pmu.h |  7 ++++
>  5 files changed, 114 insertions(+)
>  create mode 100644 drivers/perf/arm_pmu_acpi.c
> 
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 678e084..5c96d23 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -37,6 +37,7 @@
>  #include <linux/completion.h>
>  #include <linux/of.h>
>  #include <linux/irq_work.h>
> +#include <linux/perf/arm_pmu.h>
>  
>  #include <asm/alternative.h>
>  #include <asm/atomic.h>
> @@ -540,6 +541,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
>  			return;
>  		}
>  		bootcpu_valid = true;
> +		arm_pmu_parse_acpi(0, processor);
>  		return;
>  	}
>  
> @@ -560,6 +562,9 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
>  	 */
>  	acpi_set_mailbox_entry(cpu_count, processor);
>  
> +	/* get PMU irq info */
> +	arm_pmu_parse_acpi(cpu_count, processor);
> +

Nit: the outer functions are now misnomers, since this has nothing to do
with the GIC. It feels like acpi_parse_gic_cpu_interface could use some
slight restructuring so that the MADT parsing looks less confused.

> diff --git a/drivers/perf/Makefile b/drivers/perf/Makefile
> index acd2397..fd8090d 100644
> --- a/drivers/perf/Makefile
> +++ b/drivers/perf/Makefile
> @@ -1 +1,2 @@
>  obj-$(CONFIG_ARM_PMU) += arm_pmu.o
> +obj-$(CONFIG_ARM_PMU_ACPI) += arm_pmu_acpi.o
> diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
> new file mode 100644
> index 0000000..98c452d
> --- /dev/null
> +++ b/drivers/perf/arm_pmu_acpi.c
> @@ -0,0 +1,97 @@
> +/*
> + * PMU support
> + *
> + * Copyright (C) 2015 Red Hat Inc.
> + * Author: Mark Salter <msalter@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include <linux/perf/arm_pmu.h>
> +#include <linux/platform_device.h>
> +#include <linux/acpi.h>
> +#include <linux/irq.h>
> +#include <linux/irqdesc.h>
> +
> +#define PMU_PDEV_NAME "armv8-pmu"

Stick this in include/linux/perf/arm_pmu.h where we can use it in the driver
code too?

> +
> +struct pmu_irq {
> +	int gsi;
> +	int trigger;
> +};
> +
> +static struct pmu_irq pmu_irqs[NR_CPUS] __initdata;
> +
> +void __init arm_pmu_parse_acpi(int cpu, struct acpi_madt_generic_interrupt *gic)
> +{
> +	pmu_irqs[cpu].gsi = gic->performance_interrupt;
> +	if (gic->flags & ACPI_MADT_PERFORMANCE_IRQ_MODE)
> +		pmu_irqs[cpu].trigger = ACPI_EDGE_SENSITIVE;
> +	else
> +		pmu_irqs[cpu].trigger = ACPI_LEVEL_SENSITIVE;
> +}
> +
> +static int __init pmu_acpi_init(void)
> +{
> +	struct platform_device *pdev;
> +	struct pmu_irq *pirq = pmu_irqs;
> +	struct resource	*res, *r;
> +	int err = -ENOMEM;
> +	int i, count, irq;
> +
> +	if (acpi_disabled)
> +		return 0;
> +
> +	/* Must have irq for boot boot cpu, at least */

boot boot

> +	if (pirq->gsi == 0)
> +		return -EINVAL;
> +
> +	irq = acpi_register_gsi(NULL, pirq->gsi, pirq->trigger,
> +				ACPI_ACTIVE_HIGH);

This is quite tricky to read, thanks to the aliasing of pirq and
pmu_irqs[0]. Why is it necessary to register the first gsi separately,
rather than just register it later in the loop with all the other
interrupts?

Will

  reply	other threads:[~2016-06-15 11:33 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 22:23 [PATCH 0/8] arm64: pmu: Detect multiple PMU types in an ACPI system Jeremy Linton
2016-06-09 22:23 ` Jeremy Linton
2016-06-09 22:23 ` [PATCH 1/8] arm64: pmu: add fallback probe table Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-15 10:59   ` Will Deacon
2016-06-15 10:59     ` Will Deacon
2016-06-09 22:23 ` [PATCH 2/8] arm64: pmu: Probe default hw/cache counters Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-15 11:14   ` Will Deacon
2016-06-15 11:14     ` Will Deacon
2016-06-09 22:23 ` [PATCH 3/8] arm64: pmu: Add support for probing with ACPI Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-15 11:33   ` Will Deacon [this message]
2016-06-15 11:33     ` Will Deacon
2016-06-15 15:07     ` Jeremy Linton
2016-06-15 15:07       ` Jeremy Linton
2016-06-09 22:23 ` [PATCH 4/8] arm: arm64: Add routine to determine cpuid of other cpus Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-20 16:49   ` Punit Agrawal
2016-06-20 16:49     ` Punit Agrawal
2016-06-09 22:23 ` [PATCH 5/8] arm: arm64: pmu: Assign platform PMU CPU affinity Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-15 13:09   ` Will Deacon
2016-06-15 13:09     ` Will Deacon
2016-06-20 16:40   ` Punit Agrawal
2016-06-20 16:40     ` Punit Agrawal
2016-06-20 16:49     ` Jeremy Linton
2016-06-20 16:49       ` Jeremy Linton
2016-06-20 17:01       ` Punit Agrawal
2016-06-20 17:01         ` Punit Agrawal
2016-06-09 22:23 ` [PATCH 6/8] arm64: pmu: Add routines for detecting differing PMU types in the system Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-09 22:23 ` [PATCH 7/8] arm64: pmu: Enable multiple PMUs in an ACPI system Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-15 13:22   ` Will Deacon
2016-06-15 13:22     ` Will Deacon
2016-06-15 15:21     ` Jeremy Linton
2016-06-15 15:21       ` Jeremy Linton
2016-06-15 15:30       ` Will Deacon
2016-06-15 15:30         ` Will Deacon
2016-06-20 16:37   ` Punit Agrawal
2016-06-20 16:37     ` Punit Agrawal
2016-06-20 21:44     ` Jeremy Linton
2016-06-20 21:44       ` Jeremy Linton
2016-06-21  8:34       ` Punit Agrawal
2016-06-21  8:34         ` Punit Agrawal
2016-06-09 22:23 ` [PATCH 8/8] MAINTAINERS: Tweak ARM PMU maintainers Jeremy Linton
2016-06-09 22:23   ` Jeremy Linton
2016-06-20 16:47 ` [PATCH 0/8] arm64: pmu: Detect multiple PMU types in an ACPI system Punit Agrawal
2016-06-20 16:47   ` Punit Agrawal

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=20160615113333.GI24029@arm.com \
    --to=will.deacon@arm.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=jeremy.linton@arm.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=mlangsdorf@redhat.com \
    --cc=peterz@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 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.