From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jon Hunter Subject: Re: [PATCH 4/6] ARM: OMAP4: PMU: Add runtime PM support Date: Thu, 31 May 2012 13:11:49 -0500 Message-ID: <4FC7B465.60703@ti.com> References: <1336599355-10983-1-git-send-email-jon-hunter@ti.com> <87wr3uelgp.fsf@ti.com> <4FC548A3.2040906@ti.com> <4FC54D3B.10301@ti.com> <87pq9l7306.fsf@ti.com> <20120531012923.GB8506@mudshark.cambridge.arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Return-path: Received: from arroyo.ext.ti.com ([192.94.94.40]:40490 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976Ab2EaSMI (ORCPT ); Thu, 31 May 2012 14:12:08 -0400 In-Reply-To: <20120531012923.GB8506@mudshark.cambridge.arm.com> Sender: linux-omap-owner@vger.kernel.org List-Id: linux-omap@vger.kernel.org To: Will Deacon Cc: Kevin Hilman , linux-omap , Ming Lei , Benoit Cousson , Paul Walmsley 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. Cheers Jon >>From b111bcb24737e070ee1ce7ea3d1deb60a4d6f266 Mon Sep 17 00:00:00 2001 From: Jon Hunter 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 #include #include +#include #include #include @@ -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, -- 1.7.9.5