From: mark gross <markgross@thegnar.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
ACPI Devel Mailing List <linux-acpi@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Huang Ying <ying.huang@intel.com>,
Sarah Sharp <sarah.a.sharp@linux.intel.com>,
Lan Tianyu <tianyu.lan@intel.com>, Aaron Lu <aaron.lu@intel.com>,
Jean Pihet <j-pihet@ti.com>,
linux-pci@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
mark gross <markgross@thegnar.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/7] PM / QoS: Introduce request and constraint data types for PM QoS flags
Date: Tue, 9 Oct 2012 20:21:20 -0700 [thread overview]
Message-ID: <20121010032120.GB21067@MGROSS-X220VM> (raw)
In-Reply-To: <5257738.DZvocH2moA@vostro.rjw.lan>
On Mon, Oct 08, 2012 at 10:05:07AM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Introduce struct pm_qos_flags_request and struct pm_qos_flags
> representing PM QoS flags request type and PM QoS flags constraint
> type, respectively. With these definitions the data structures
> will be arranged so that the list member of a struct pm_qos_flags
> object will contain the head of a list of struct pm_qos_flags_request
> objects representing all of the "flags" requests present for the
> given device. Then, the effective_flags member of a struct
> pm_qos_flags object will contain the bitwise OR of the flags members
> of all the struct pm_qos_flags_request objects in the list.
>
> Additionally, introduce helper function pm_qos_update_flags()
> allowing the caller to manage the list of struct pm_qos_flags_request
> pointed to by the list member of struct pm_qos_flags.
>
> The flags are of type s32 so that the request's "value" field
> is always of the same type regardless of what kind of request it
> is (latency requests already have value fields of type s32).
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Jean Pihet <j-pihet@ti.com>
> ---
> include/linux/pm_qos.h | 17 +++++++++++--
> kernel/power/qos.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 78 insertions(+), 2 deletions(-)
>
> Index: linux/include/linux/pm_qos.h
> ===================================================================
> --- linux.orig/include/linux/pm_qos.h
> +++ linux/include/linux/pm_qos.h
> @@ -33,6 +33,11 @@ struct pm_qos_request {
> struct delayed_work work; /* for pm_qos_update_request_timeout */
> };
>
> +struct pm_qos_flags_request {
> + struct list_head node;
> + s32 flags; /* Do not change to 64 bit */
> +};
> +
> struct dev_pm_qos_request {
> struct plist_node node;
> struct device *dev;
> @@ -45,8 +50,8 @@ enum pm_qos_type {
> };
>
> /*
> - * Note: The lockless read path depends on the CPU accessing
> - * target_value atomically. Atomic access is only guaranteed on all CPU
> + * Note: The lockless read path depends on the CPU accessing target_value
> + * or effective_flags atomically. Atomic access is only guaranteed on all CPU
> * types linux supports for 32 bit quantites
> */
> struct pm_qos_constraints {
> @@ -57,6 +62,11 @@ struct pm_qos_constraints {
> struct blocking_notifier_head *notifiers;
> };
>
> +struct pm_qos_flags {
> + struct list_head list;
> + s32 effective_flags; /* Do not change to 64 bit */
> +};
> +
> struct dev_pm_qos {
> struct pm_qos_constraints latency;
> };
> @@ -75,6 +85,9 @@ static inline int dev_pm_qos_request_act
>
> int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
> enum pm_qos_req_action action, int value);
> +bool pm_qos_update_flags(struct pm_qos_flags *pqf,
> + struct pm_qos_flags_request *req,
> + enum pm_qos_req_action action, s32 val);
> void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
> s32 value);
> void pm_qos_update_request(struct pm_qos_request *req,
> Index: linux/kernel/power/qos.c
> ===================================================================
> --- linux.orig/kernel/power/qos.c
> +++ linux/kernel/power/qos.c
> @@ -213,6 +213,69 @@ int pm_qos_update_target(struct pm_qos_c
> }
>
> /**
> + * pm_qos_flags_remove_req - Remove device PM QoS flags request.
> + * @pqf: Device PM QoS flags set to remove the request from.
> + * @req: Request to remove from the set.
> + */
> +static void pm_qos_flags_remove_req(struct pm_qos_flags *pqf,
> + struct pm_qos_flags_request *req)
> +{
> + s32 val = 0;
> +
> + list_del(&req->node);
> + list_for_each_entry(req, &pqf->list, node)
> + val |= req->flags;
> +
> + pqf->effective_flags = val;
> +}
> +
> +/**
> + * pm_qos_update_flags - Update a set of PM QoS flags.
> + * @pqf: Set of flags to update.
> + * @req: Request to add to the set, to modify, or to remove from the set.
> + * @action: Action to take on the set.
> + * @val: Value of the request to add or modify.
> + *
> + * Update the given set of PM QoS flags and call notifiers if the aggregate
> + * value has changed. Returns 1 if the aggregate constraint value has changed,
> + * 0 otherwise.
> + */
> +bool pm_qos_update_flags(struct pm_qos_flags *pqf,
> + struct pm_qos_flags_request *req,
> + enum pm_qos_req_action action, s32 val)
> +{
> + unsigned long irqflags;
> + s32 prev_value, curr_value;
> +
> + spin_lock_irqsave(&pm_qos_lock, irqflags);
> +
> + prev_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags;
> +
> + switch (action) {
> + case PM_QOS_REMOVE_REQ:
> + pm_qos_flags_remove_req(pqf, req);
> + break;
> + case PM_QOS_UPDATE_REQ:
> + pm_qos_flags_remove_req(pqf, req);
> + case PM_QOS_ADD_REQ:
> + req->flags = val;
> + INIT_LIST_HEAD(&req->node);
> + list_add_tail(&req->node, &pqf->list);
> + pqf->effective_flags |= val;
> + break;
> + default:
> + /* no action */
> + ;
> + }
> +
> + curr_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags;
> +
> + spin_unlock_irqrestore(&pm_qos_lock, irqflags);
> +
> + return prev_value != curr_value;
> +}
> +
> +/**
> * pm_qos_request - returns current system wide qos expectation
> * @pm_qos_class: identification of which qos value is requested
> *
>
acked-by: mark gross <markgross@thegnar.org>
--mark
next prev parent reply other threads:[~2012-10-10 3:21 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-28 21:51 [RFD][PATCH 0/7] PM / QoS: Support for PM QoS device flags Rafael J. Wysocki
2012-09-28 21:52 ` [RFD][PATCH 1/7] PM / QoS: Prepare device structure for adding more constraint types Rafael J. Wysocki
2012-09-28 21:52 ` [RFD][PATCH 2/7] PM / QoS: Introduce request and constraint data types for PM QoS flags Rafael J. Wysocki
2012-09-29 6:02 ` Lan Tianyu
2012-09-29 21:36 ` Rafael J. Wysocki
2012-09-28 21:53 ` [RFD][PATCH 3/7] PM / QoS: Prepare struct dev_pm_qos_request for more request types Rafael J. Wysocki
2012-09-28 21:54 ` [RFD][PATCH 4/7] PM / QoS: Introduce device PM QoS flags support Rafael J. Wysocki
2012-09-28 21:55 ` [RFD][PATCH 5/7] PM / QoS: Make it possible to expose PM QoS device flags to user space Rafael J. Wysocki
2012-10-30 8:53 ` Aaron Lu
2012-10-30 15:29 ` Rafael J. Wysocki
2012-09-28 21:56 ` [RFD][PATCH 6/7] PM / Domains: Check device PM QoS flags in pm_genpd_poweroff() Rafael J. Wysocki
2012-09-28 21:56 ` [RFD][PATCH 7/7] PM / ACPI: Take device PM QoS flags into account Rafael J. Wysocki
2012-09-29 3:16 ` Huang Ying
2012-09-29 21:39 ` Rafael J. Wysocki
2012-11-12 21:07 ` Bjorn Helgaas
2012-11-12 23:42 ` Rafael J. Wysocki
2012-10-01 16:17 ` [RFD][PATCH 0/7] PM / QoS: Support for PM QoS device flags Pihet-XID, Jean
2012-10-02 2:17 ` Rafael J. Wysocki
2012-10-08 8:02 ` [PATCH " Rafael J. Wysocki
2012-10-08 8:04 ` [PATCH 1/7] PM / QoS: Prepare device structure for adding more constraint types Rafael J. Wysocki
2012-10-10 3:15 ` mark gross
2012-10-10 23:12 ` Rafael J. Wysocki
2012-10-08 8:05 ` [PATCH 2/7] PM / QoS: Introduce request and constraint data types for PM QoS flags Rafael J. Wysocki
2012-10-10 3:21 ` mark gross [this message]
2012-10-08 8:06 ` [PATCH 3/7] PM / QoS: Prepare struct dev_pm_qos_request for more request types Rafael J. Wysocki
2012-10-10 3:37 ` mark gross
2012-10-08 8:07 ` [PATCH 4/7] PM / QoS: Introduce PM QoS device flags support Rafael J. Wysocki
2012-10-10 3:37 ` mark gross
2012-10-08 8:07 ` [PATCH 5/7] PM / QoS: Make it possible to expose PM QoS device flags to user space Rafael J. Wysocki
2012-10-10 3:33 ` mark gross
2012-10-08 8:08 ` [PATCH 6/7] PM / Domains: Check device PM QoS flags in pm_genpd_poweroff() Rafael J. Wysocki
2012-10-10 3:35 ` mark gross
2012-10-08 8:09 ` [PATCH 7/7] PM / ACPI: Take device PM QoS flags into account Rafael J. Wysocki
2012-10-09 2:46 ` Huang Ying
2012-10-10 3:36 ` mark gross
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=20121010032120.GB21067@MGROSS-X220VM \
--to=markgross@thegnar.org \
--cc=aaron.lu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=j-pihet@ti.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=sarah.a.sharp@linux.intel.com \
--cc=stern@rowland.harvard.edu \
--cc=tianyu.lan@intel.com \
--cc=ying.huang@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).