From: Kevin Hilman <khilman@ti.com>
To: Jon Hunter <jon-hunter@ti.com>
Cc: Will Deacon <will.deacon@arm.com>,
linux-omap <linux-omap@vger.kernel.org>,
Ming Lei <ming.lei@canonical.com>,
Benoit Cousson <b-cousson@ti.com>, Paul Walmsley <paul@pwsan.com>
Subject: Re: [PATCH 4/6] ARM: OMAP4: PMU: Add runtime PM support
Date: Thu, 31 May 2012 13:42:58 -0700 [thread overview]
Message-ID: <87r4u0ytd9.fsf@ti.com> (raw)
In-Reply-To: <4FC7B465.60703@ti.com> (Jon Hunter's message of "Thu, 31 May 2012 13:11:49 -0500")
Jon Hunter <jon-hunter@ti.com> writes:
> Hi Kevin, Will,
>
> On 05/30/2012 08:29 PM, Will Deacon wrote:
>> Hi Kevin,
>>
>> On Wed, May 30, 2012 at 10:50:01PM +0100, Kevin Hilman wrote:
>>> Basically, I don't like the result when we have to hack around missing
>>> runtime PM support for a driver, so IMO, the driver should be updated.
>>>
>>> IOW, it looks to me like the armpmu driver should grow runtime PM
>>> support. The current armpmu_release|reserve should probably be replaced
>>> with runtime PM get/put, and the functionality in those functions would
>>> be the runtime PM callbacks instead.
>>>
>>> Will, any objections to armpmu growing runtime PM support?
>>
>> My plan for the armpmu reservation is to kill the global reservation scheme
>> that we currently have and push those function pointers into the arm_pmu,
>> so that fits with what you'd like.
>>
>> The only concern I have is that we need the mutual exclusion even when we
>> don't have support for runtime PM. If we can solve that then I'm fine with
>> the approach.
>
> To add a bit more food for thought, I had implemented a quick patch to
> add runtime PM support for PMU. You will notice that I have been
> conservative on where I have placed the pm_runtime_get/put calls,
> because I am not too familiar with the PMU driver to know exactly
> where we need to maintain the PMU context. So right now these are just
> around the reserve_hardware/release_hardware calls. This works on OMAP
> for some quick testing. However, I would need to make sure this does
> not break compilation without runtime PM enabled.
>
> Let me know your thoughts.
That looks good, but I'm curious what would be done in the new
plat->runtime_* hooks. Maybe the irq enable/disable stuff in the pmu
driver needs to be moved into the runtime PM hooks?
Kevin
> Cheers
> Jon
>
> From b111bcb24737e070ee1ce7ea3d1deb60a4d6f266 Mon Sep 17 00:00:00 2001
> From: Jon Hunter <jon-hunter@ti.com>
> Date: Thu, 31 May 2012 13:05:20 -0500
> Subject: [PATCH] ARM: PMU: Add runtime PM Support
>
> ---
> arch/arm/include/asm/pmu.h | 2 ++
> arch/arm/kernel/perf_event.c | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 32 insertions(+)
>
> diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h
> index 90114fa..db9f20c 100644
> --- a/arch/arm/include/asm/pmu.h
> +++ b/arch/arm/include/asm/pmu.h
> @@ -43,6 +43,8 @@ struct arm_pmu_platdata {
> irq_handler_t pmu_handler);
> void (*enable_irq)(int irq);
> void (*disable_irq)(int irq);
> + int (*runtime_resume)(struct device *dev);
> + int (*runtime_suspend)(struct device *dev);
> };
>
> #ifdef CONFIG_CPU_HAS_PMU
> diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
> index 186c8cb..3b2b016 100644
> --- a/arch/arm/kernel/perf_event.c
> +++ b/arch/arm/kernel/perf_event.c
> @@ -20,6 +20,7 @@
> #include <linux/platform_device.h>
> #include <linux/spinlock.h>
> #include <linux/uaccess.h>
> +#include <linux/pm_runtime.h>
>
> #include <asm/cputype.h>
> #include <asm/irq.h>
> @@ -460,6 +461,8 @@ hw_perf_event_destroy(struct perf_event *event)
> armpmu_release_hardware(armpmu);
> mutex_unlock(pmu_reserve_mutex);
> }
> +
> + pm_runtime_put_sync(&armpmu->plat_device->dev);
> }
>
> static int
> @@ -546,6 +549,8 @@ static int armpmu_event_init(struct perf_event *event)
> if (armpmu->map_event(event) == -ENOENT)
> return -ENOENT;
>
> + pm_runtime_get_sync(&armpmu->plat_device->dev);
> +
> event->destroy = hw_perf_event_destroy;
>
> if (!atomic_inc_not_zero(active_events)) {
> @@ -584,6 +589,26 @@ static void armpmu_disable(struct pmu *pmu)
> armpmu->stop();
> }
>
> +static int armpmu_runtime_resume(struct device *dev)
> +{
> + struct arm_pmu_platdata *plat = dev_get_platdata(dev);
> +
> + if (plat->runtime_resume)
> + return plat->runtime_resume(dev);
> +
> + return 0;
> +}
> +
> +static int armpmu_runtime_suspend(struct device *dev)
> +{
> + struct arm_pmu_platdata *plat = dev_get_platdata(dev);
> +
> + if (plat->runtime_suspend)
> + return plat->runtime_suspend(dev);
> +
> + return 0;
> +}
> +
> static void __init armpmu_init(struct arm_pmu *armpmu)
> {
> atomic_set(&armpmu->active_events, 0);
> @@ -650,9 +675,14 @@ static int __devinit armpmu_device_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static const struct dev_pm_ops armpmu_dev_pm_ops = {
> + SET_RUNTIME_PM_OPS(armpmu_runtime_suspend, armpmu_runtime_resume, NULL)
> +};
> +
> static struct platform_driver armpmu_driver = {
> .driver = {
> .name = "arm-pmu",
> + .pm = &armpmu_dev_pm_ops,
> .of_match_table = armpmu_of_device_ids,
> },
> .probe = armpmu_device_probe,
next prev parent reply other threads:[~2012-05-31 20:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-09 21:35 [PATCH 4/6] ARM: OMAP4: PMU: Add runtime PM support Jon Hunter
2012-05-10 6:21 ` Shilimkar, Santosh
2012-05-15 4:53 ` Ming Lei
2012-05-15 14:39 ` Jon Hunter
[not found] ` <CACVXFVNqWM7G8dK2AA90JPvE6e_L0_Zwk-BJTjThY+nZ6ONnQA@mail.gmail.com>
2012-05-16 8:17 ` Ming Lei
2012-05-17 5:28 ` Ming Lei
2012-05-29 21:17 ` Kevin Hilman
2012-05-29 22:07 ` Jon Hunter
2012-05-29 22:27 ` Jon Hunter
2012-05-30 21:50 ` Kevin Hilman
2012-05-31 1:29 ` Will Deacon
2012-05-31 15:05 ` Jon Hunter
2012-05-31 18:49 ` Jon Hunter
2012-05-31 18:11 ` Jon Hunter
2012-05-31 20:42 ` Kevin Hilman [this message]
2012-05-31 21:23 ` Jon Hunter
2012-05-31 22:36 ` Kevin Hilman
2012-05-31 23:02 ` Jon Hunter
2012-06-01 0:27 ` Kevin Hilman
2012-06-01 14:42 ` Jon Hunter
2012-06-02 16:42 ` Will Deacon
2012-06-04 21:44 ` Jon Hunter
2012-06-05 13:19 ` Jon Hunter
2012-06-06 17:33 ` Will Deacon
2012-06-07 1:24 ` Jon Hunter
2012-05-31 15:04 ` Jon Hunter
2012-05-31 16:22 ` Kevin Hilman
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=87r4u0ytd9.fsf@ti.com \
--to=khilman@ti.com \
--cc=b-cousson@ti.com \
--cc=jon-hunter@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=ming.lei@canonical.com \
--cc=paul@pwsan.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: 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.