From: Lee Jones <lee.jones@linaro.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Vinod Koul <vinod.koul@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
mturquette@baylibre.com, sboyd@codeaurora.org
Subject: Re: [PATCH v6 1/8] PM / QoS: Make it possible to expose device latency tolerance to userspace
Date: Tue, 28 Jul 2015 08:47:18 +0100 [thread overview]
Message-ID: <20150728074718.GO21114@x1> (raw)
In-Reply-To: <1438009443-55317-2-git-send-email-andriy.shevchenko@linux.intel.com>
On Mon, 27 Jul 2015, Andy Shevchenko wrote:
> From: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> Typically when a device is created the bus core it belongs to (for example
> PCI) does not know if the device supports things like latency tolerance.
> This is left to the driver that binds to the device in question. However,
> at that time the device has already been created and there is no way to set
> its dev->power.set_latency_tolerance anymore.
>
> So follow what has been done for other PM QoS attributes as well and allow
> drivers to expose and hide latency tolerance from userspace, if the device
> supports it.
>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/base/power/power.h | 2 ++
> drivers/base/power/qos.c | 37 +++++++++++++++++++++++++++++++++++++
> drivers/base/power/sysfs.c | 11 +++++++++++
> include/linux/pm_qos.h | 5 +++++
> 4 files changed, 55 insertions(+)
Applied, thanks. Pull request to follow.
> diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
> index f1a5d95..998fa6b 100644
> --- a/drivers/base/power/power.h
> +++ b/drivers/base/power/power.h
> @@ -73,6 +73,8 @@ extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
> extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
> extern int pm_qos_sysfs_add_flags(struct device *dev);
> extern void pm_qos_sysfs_remove_flags(struct device *dev);
> +extern int pm_qos_sysfs_add_latency_tolerance(struct device *dev);
> +extern void pm_qos_sysfs_remove_latency_tolerance(struct device *dev);
>
> #else /* CONFIG_PM */
>
> diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
> index e56d538..7f3646e 100644
> --- a/drivers/base/power/qos.c
> +++ b/drivers/base/power/qos.c
> @@ -883,3 +883,40 @@ int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
> mutex_unlock(&dev_pm_qos_mtx);
> return ret;
> }
> +
> +/**
> + * dev_pm_qos_expose_latency_tolerance - Expose latency tolerance to userspace
> + * @dev: Device whose latency tolerance to expose
> + */
> +int dev_pm_qos_expose_latency_tolerance(struct device *dev)
> +{
> + int ret;
> +
> + if (!dev->power.set_latency_tolerance)
> + return -EINVAL;
> +
> + mutex_lock(&dev_pm_qos_sysfs_mtx);
> + ret = pm_qos_sysfs_add_latency_tolerance(dev);
> + mutex_unlock(&dev_pm_qos_sysfs_mtx);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_qos_expose_latency_tolerance);
> +
> +/**
> + * dev_pm_qos_hide_latency_tolerance - Hide latency tolerance from userspace
> + * @dev: Device whose latency tolerance to hide
> + */
> +void dev_pm_qos_hide_latency_tolerance(struct device *dev)
> +{
> + mutex_lock(&dev_pm_qos_sysfs_mtx);
> + pm_qos_sysfs_remove_latency_tolerance(dev);
> + mutex_unlock(&dev_pm_qos_sysfs_mtx);
> +
> + /* Remove the request from user space now */
> + pm_runtime_get_sync(dev);
> + dev_pm_qos_update_user_latency_tolerance(dev,
> + PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT);
> + pm_runtime_put(dev);
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_qos_hide_latency_tolerance);
> diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
> index d2be3f9..a7b4679 100644
> --- a/drivers/base/power/sysfs.c
> +++ b/drivers/base/power/sysfs.c
> @@ -738,6 +738,17 @@ void pm_qos_sysfs_remove_flags(struct device *dev)
> sysfs_unmerge_group(&dev->kobj, &pm_qos_flags_attr_group);
> }
>
> +int pm_qos_sysfs_add_latency_tolerance(struct device *dev)
> +{
> + return sysfs_merge_group(&dev->kobj,
> + &pm_qos_latency_tolerance_attr_group);
> +}
> +
> +void pm_qos_sysfs_remove_latency_tolerance(struct device *dev)
> +{
> + sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group);
> +}
> +
> void rpm_sysfs_remove(struct device *dev)
> {
> sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
> diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
> index 7b3ae0c..0f65d36 100644
> --- a/include/linux/pm_qos.h
> +++ b/include/linux/pm_qos.h
> @@ -161,6 +161,8 @@ void dev_pm_qos_hide_flags(struct device *dev);
> int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set);
> s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev);
> int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val);
> +int dev_pm_qos_expose_latency_tolerance(struct device *dev);
> +void dev_pm_qos_hide_latency_tolerance(struct device *dev);
>
> static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev)
> {
> @@ -229,6 +231,9 @@ static inline s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev)
> { return PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; }
> static inline int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
> { return 0; }
> +static inline int dev_pm_qos_expose_latency_tolerance(struct device *dev)
> + { return 0; }
> +static inline void dev_pm_qos_hide_latency_tolerance(struct device *dev) {}
>
> static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev) { return 0; }
> static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; }
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2015-07-28 7:47 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 15:03 [PATCH v6 0/8] mfd: introduce a driver for LPSS devices on SPT Andy Shevchenko
2015-07-27 15:03 ` [PATCH v6 1/8] PM / QoS: Make it possible to expose device latency tolerance to userspace Andy Shevchenko
2015-07-28 7:47 ` Lee Jones [this message]
2015-07-27 15:03 ` [PATCH v6 2/8] ACPI / PM: Attach ACPI power domain only once Andy Shevchenko
2015-07-28 7:47 ` Lee Jones
2015-07-27 15:03 ` [PATCH v6 3/8] Driver core: wakeup the parent device before trying probe Andy Shevchenko
2015-07-28 7:47 ` Lee Jones
2015-07-27 15:03 ` [PATCH v6 4/8] klist: implement klist_prev() Andy Shevchenko
2015-07-28 7:47 ` Lee Jones
2015-07-27 15:04 ` [PATCH v6 5/8] driver core: implement device_for_each_child_reverse() Andy Shevchenko
2015-07-28 7:48 ` Lee Jones
2015-07-27 15:04 ` [PATCH v6 6/8] mfd: make mfd_remove_devices() iterate in reverse order Andy Shevchenko
2015-07-28 7:48 ` Lee Jones
2015-07-27 15:04 ` [PATCH v6 7/8] dmaengine: add a driver for Intel integrated DMA 64-bit Andy Shevchenko
2015-07-28 7:48 ` Lee Jones
2015-07-28 7:53 ` Lee Jones
2015-07-28 8:14 ` Andy Shevchenko
2015-07-28 8:43 ` Vinod Koul
2015-07-27 15:04 ` [PATCH v6 8/8] mfd: Add support for Intel Sunrisepoint LPSS devices Andy Shevchenko
2015-07-28 7:48 ` Lee Jones
2015-07-29 22:44 ` Michael Turquette
2015-07-29 23:30 ` Rafael J. Wysocki
2015-07-30 10:19 ` Andy Shevchenko
2015-07-27 15:27 ` [PATCH v6 0/8] mfd: introduce a driver for LPSS devices on SPT Lee Jones
2015-07-27 16:04 ` Mika Westerberg
2015-07-27 16:24 ` Lee Jones
2015-07-27 21:48 ` Rafael J. Wysocki
2015-07-27 21:27 ` Lee Jones
2015-07-27 21:29 ` Lee Jones
2015-07-27 22:03 ` Rafael J. Wysocki
2015-07-28 7:46 ` Lee Jones
2015-07-28 8:59 ` Lee Jones
2015-07-28 9:00 ` [GIT PULL] mfd: Immutable branch between MFD, Base, ACPI and DMA Lee Jones
2015-07-28 9:02 ` [PATCH v6 0/8] mfd: introduce a driver for LPSS devices on SPT Mika Westerberg
2015-07-29 0:30 ` Rafael J. Wysocki
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=20150728074718.GO21114@x1 \
--to=lee.jones@linaro.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=mturquette@baylibre.com \
--cc=rafael.j.wysocki@intel.com \
--cc=sboyd@codeaurora.org \
--cc=vinod.koul@intel.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 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).