All of lore.kernel.org
 help / color / mirror / Atom feed
From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/6] ARM: pmu: register IRQs at runtime
Date: Thu, 18 Mar 2010 12:20:10 +0000	[thread overview]
Message-ID: <20100318122010.GC4177@wear.picochip.com> (raw)
In-Reply-To: <1268842288-30960-1-git-send-email-will.deacon@arm.com>

On Wed, Mar 17, 2010 at 04:11:27PM +0000, Will Deacon wrote:
> The current PMU infrastructure for ARM requires that the IRQs for the PMU
> device are fixed at compile time and are selected based on the ARCH_ or MACH_
> flags. This has the disadvantage of tying the Kernel down to a particular board
> as far as profiling is concerned.
> 
> This patch replaces the compile-time IRQ registration with a runtime mechanism
> which allows the IRQs to be registered with the framework as a platform_device.
> 
> A further advantage of this change is that there is scope for registering
> different types of performance counters in the future by changing the id of
> the platform_device and attaching different resources to it.
Hi Will,

This seems like a nice approach to the problem. A couple of pedantic comments
inline!

Jamie
> Cc: Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/include/asm/pmu.h   |   30 +++++-----
>  arch/arm/kernel/perf_event.c |   36 +++++++------
>  arch/arm/kernel/pmu.c        |  121 ++++++++++++++++++++++++++----------------
>  3 files changed, 110 insertions(+), 77 deletions(-)
[snip]
> +static int __devinit pmu_device_probe(struct platform_device *pdev)
> +{
> +
> +	if (pdev->id >= ARM_NUM_PMU_DEVICES) {
> +		pr_warning("PMU: Received registration request for unknown "
> +				"device %d\n", pdev->id);
> +		return -EINVAL;
> +	}
> +
> +	if (pmu_devices[pdev->id])
> +		pr_warning("PMU: Registering new PMU device type %d overwrites "
> +				"previous registration!\n", pdev->id);
> +	else
> +		pr_info("PMU: Registered new PMU device of type %d\n",
> +				pdev->id);
> +
> +	pmu_devices[pdev->id] = pdev;
struct pdev->id is a signed integer so we should check that it's not less than
0 so we don't overrun pmu_devices..
> @@ -79,7 +91,7 @@ set_irq_affinity(int irq,
>  #ifdef CONFIG_SMP
>  	int err = irq_set_affinity(irq, cpumask_of(cpu));
>  	if (err)
> -		pr_warning("unable to set irq affinity (irq=%d, cpu=%u)\n",
> +		pr_warning("PMU: Unable to set irq affinity (irq=%d, cpu=%u)\n",
>  			   irq, cpu);
How about we stick a '#define pr_fmt(fmt) "PMU: " fmt' before the includes so
we get consistent naming if we add more pr_*() statements?
>  	return err;
>  #else
> @@ -87,17 +99,36 @@ set_irq_affinity(int irq,
>  #endif
>  }
>  
> -int
> -init_pmu(void)
> +static int
> +init_cpu_pmu(void)
>  {
>  	int i, err = 0;
> +	struct platform_device *pdev = pmu_devices[ARM_PMU_DEVICE_CPU];
Just to be safe:

if (!pdev)
	return -ENODEV;
> -	for (i = 0; i < pmu_irqs.num_irqs; ++i) {
> -		err = set_irq_affinity(pmu_irqs.irqs[i], i);
> +	for (i = 0; i < pdev->num_resources; ++i) {
> +		err = set_irq_affinity(platform_get_irq(pdev, i), i);
>  		if (err)
>  			break;
>  	}
>  
>  	return err;
>  }

  parent reply	other threads:[~2010-03-18 12:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12 17:29 [RFC PATCH 0/6] ARM: pmu: provide a registration mechanism for IRQs [v2] Will Deacon
2010-03-12 17:29 ` [RFC PATCH 1/6] ARM: pmu: register IRQs at runtime Will Deacon
2010-03-12 17:29   ` [RFC PATCH 2/6] ARM: Realview: register PMU IRQs during board initialisation Will Deacon
2010-03-12 17:29     ` [RFC PATCH 3/6] ARM: OMAP: " Will Deacon
2010-03-12 17:29       ` [RFC PATCH 4/6] ARM: BCMRING: register PMU IRQ " Will Deacon
2010-03-12 17:29         ` [RFC PATCH 5/6] ARM: iop3xx: register PMU IRQs " Will Deacon
2010-03-12 17:29           ` [RFC PATCH 6/6] ARM: pxa: " Will Deacon
2010-03-16 11:41   ` [RFC PATCH 1/6] ARM: pmu: register IRQs at runtime Jamie Iles
2010-03-17 16:06     ` Will Deacon
2010-03-17 16:11     ` Will Deacon
2010-03-17 16:11       ` [RFC PATCH 2/6] ARM: Realview: register PMU IRQs during board initialisation Will Deacon
2010-03-18 12:20       ` Jamie Iles [this message]
2010-03-24 15:50         ` [RFC PATCH 1/6] ARM: pmu: register IRQs at runtime Will Deacon

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=20100318122010.GC4177@wear.picochip.com \
    --to=jamie@jamieiles.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 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.