From: Kevin Hilman <khilman@deeprootsystems.com>
To: Thara Gopinath <thara@ti.com>
Cc: linux-omap@vger.kernel.org, paul@pwsan.com, vishwanath.bs@ti.com,
sawant@ti.com, b-cousson@ti.com
Subject: Re: [PATCH 01/13] OMAP: Introduce a user list for each voltage domain instance in the voltage driver.
Date: Fri, 27 Aug 2010 16:53:20 -0700 [thread overview]
Message-ID: <87iq2vipe7.fsf@deeprootsystems.com> (raw)
In-Reply-To: <1282130412-12027-2-git-send-email-thara@ti.com> (Thara Gopinath's message of "Wed, 18 Aug 2010 16:50:00 +0530")
Thara Gopinath <thara@ti.com> writes:
> This patch introduces a user list of devices associated with each
> voltage domain instance. The user list is implemented using plist
> structure with priority node populated with the voltage values.
> This patch also adds an API which will take in a device and
> requested voltage as parameters, adds the info to the user list
> and returns back the maximum voltage requested by all the user
> devices. This can be used anytime to get the voltage that the
> voltage domain instance can be transitioned into.
>
> Signed-off-by: Thara Gopinath <thara@ti.com>
> ---
> arch/arm/mach-omap2/voltage.c | 94 +++++++++++++++++++++++++++++
> arch/arm/plat-omap/include/plat/voltage.h | 2 +
> 2 files changed, 96 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
> index 6a07fe9..4624250 100644
> --- a/arch/arm/mach-omap2/voltage.c
> +++ b/arch/arm/mach-omap2/voltage.c
> @@ -24,6 +24,9 @@
> #include <linux/clk.h>
> #include <linux/err.h>
> #include <linux/debugfs.h>
> +#include <linux/spinlock.h>
> +#include <linux/plist.h>
> +#include <linux/slab.h>
>
> #include <plat/omap-pm.h>
> #include <plat/omap34xx.h>
> @@ -95,6 +98,20 @@ struct vp_reg_val {
> };
>
> /**
> + * omap_vdd_user_list - The per vdd user list
> + *
> + * @dev : The device asking for the vdd to be set at a particular
> + * voltage
> + * @node : The list head entry
> + * @volt : The voltage requested by the device <dev>
> + */
> +struct omap_vdd_user_list {
> + struct device *dev;
> + struct plist_node node;
> + u32 volt;
> +};
> +
> +/**
> * omap_vdd_info - Per Voltage Domain info
> *
> * @volt_data : voltage table having the distinct voltages supported
> @@ -105,6 +122,9 @@ struct vp_reg_val {
> * vp registers
> * @volt_clk : the clock associated with the vdd.
> * @opp_dev : the 'struct device' associated with this vdd.
> + * @user_lock : the lock to be used by the plist user_list
> + * @user_list : the list head maintaining the various users
> + * of this vdd with the voltage requested by each user.
> * @volt_data_count : Number of distinct voltages supported by this vdd.
> * @nominal_volt : Nominal voltaged for this vdd.
> * cmdval_reg : Voltage controller cmdval register.
> @@ -117,6 +137,9 @@ struct omap_vdd_info{
> struct clk *volt_clk;
> struct device *opp_dev;
> struct voltagedomain voltdm;
> + spinlock_t user_lock;
> + struct plist_head user_list;
> + struct mutex scaling_mutex;
> int volt_data_count;
> unsigned long nominal_volt;
> u8 cmdval_reg;
> @@ -785,11 +808,18 @@ static void __init vdd_data_configure(struct omap_vdd_info *vdd)
> struct dentry *vdd_debug;
> char name[16];
> #endif
> +
> if (cpu_is_omap34xx())
> omap3_vdd_data_configure(vdd);
> else if (cpu_is_omap44xx())
> omap4_vdd_data_configure(vdd);
>
> + /* Init the plist */
> + spin_lock_init(&vdd->user_lock);
> + plist_head_init(&vdd->user_list, &vdd->user_lock);
> + /* Init the DVFS mutex */
> + mutex_init(&vdd->scaling_mutex);
> +
> #ifdef CONFIG_PM_DEBUG
> strcpy(name, "vdd_");
> strcat(name, vdd->voltdm.name);
> @@ -1142,6 +1172,70 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
> }
>
> /**
> + * omap_voltage_add_userreq : API to keep track of various requests to
> + * scale the VDD and returns the best possible
> + * voltage the VDD can be put to.
> + * @volt_domain: pointer to the voltage domain.
> + * @dev : the device pointer.
> + * @volt : the voltage which is requested by the device.
> + *
> + * This API is to be called before the actual voltage scaling is
> + * done to determine what is the best possible voltage the VDD can
> + * be put to. This API adds the device <dev> in the user list of the
> + * vdd <volt_domain> with <volt> as the requested voltage. The user list
> + * is a plist with the priority element absolute voltage values.
> + * The API then finds the maximum of all the requested voltages for
> + * the VDD and returns it back through <volt> pointer itself.
> + * Returns error value in case of any errors.
> + */
> +int omap_voltage_add_userreq(struct voltagedomain *voltdm, struct device *dev,
> + unsigned long *volt)
How about just omap_voltage_add_request()
Also, do we need both voltdm and dev? With your other patches, can't we
look up the voltm based on dev? Or, is there a need for a device to add
a request in a voltage domain other than the one to which it belongs?
Also, how does one remove a voltage request?
> +{
> + struct omap_vdd_info *vdd;
> + struct omap_vdd_user_list *user;
> + struct plist_node *node;
> + int found = 0;
> +
> + if (!voltdm || IS_ERR(voltdm)) {
> + pr_warning("%s: VDD specified does not exist!\n", __func__);
> + return -EINVAL;
> + }
> +
> + vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
> +
> + mutex_lock(&vdd->scaling_mutex);
> +
> + plist_for_each_entry(user, &vdd->user_list, node) {
> + if (user->dev == dev) {
> + found = 1;
> + break;
> + }
> + }
Minor: I'm not crazy about the 'found' flag. IMO, readability is
improved if you init 'user = NULL' above, use a tmp pointer to
walk the list, and rather than 'found = 1', do 'user = tmp_user'
when you find the match.
> +
> + if (!found) {
and here, do if (!user)
> + user = kzalloc(sizeof(struct omap_vdd_user_list), GFP_KERNEL);
> + if (!user) {
> + pr_err("%s: Unable to creat a new user for vdd_%s\n",
> + __func__, voltdm->name);
> + mutex_unlock(&vdd->scaling_mutex);
> + return -ENOMEM;
> + }
> + user->dev = dev;
> + } else {
> + plist_del(&user->node, &vdd->user_list);
hmm... if we get here, we didn't find a match, so 'user' points to the
last element in the list (which is the highest voltage request, I
guess), or even NULL if the list is empty. Then, this node is deleted.
-ECONFUSED
> + }
> +
> + plist_node_init(&user->node, *volt);
> + plist_add(&user->node, &vdd->user_list);
> + node = plist_first(&vdd->user_list);
> + *volt = node->prio;
> +
> + mutex_unlock(&vdd->scaling_mutex);
> +
> + return 0;
> +}
Can't think of a use-case now (cuz it's Friday), but would we ever want
to add multiple requests per device?
The current approch will only track one request per device.
Kevin
> +/**
> * omap_vp_enable : API to enable a particular VP
> * @voltdm: pointer to the VDD whose VP is to be enabled.
> *
> diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h
> index 3e8cf03..fffd086 100644
> --- a/arch/arm/plat-omap/include/plat/voltage.h
> +++ b/arch/arm/plat-omap/include/plat/voltage.h
> @@ -144,6 +144,8 @@ struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
> unsigned long volt);
> void omap_voltage_register_pmic(struct omap_volt_pmic_info *pmic_info);
> unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
> +int omap_voltage_add_userreq(struct voltagedomain *voltdm, struct device *dev,
> + unsigned long *volt);
> #ifdef CONFIG_PM
> void omap_voltage_init_vc(struct omap_volt_vc_data *setup_vc);
> void omap_change_voltscale_method(int voltscale_method);
next prev parent reply other threads:[~2010-08-27 23:53 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 11:19 [PATCH 00/13] OMAP: Basic DVFS framework Thara Gopinath
2010-08-18 11:20 ` [PATCH 01/13] OMAP: Introduce a user list for each voltage domain instance in the voltage driver Thara Gopinath
2010-08-27 23:53 ` Kevin Hilman [this message]
2010-08-30 22:56 ` Kevin Hilman
2010-09-16 9:59 ` Gopinath, Thara
2010-09-16 15:20 ` Kevin Hilman
2010-09-17 14:33 ` Gopinath, Thara
2010-09-01 22:51 ` Kevin Hilman
2010-09-02 7:43 ` Thomas Petazzoni
2010-09-02 8:17 ` Nishanth Menon
2010-09-02 10:00 ` Felipe Balbi
2010-09-02 10:17 ` Nishanth Menon
2010-09-02 10:28 ` Felipe Balbi
2010-09-02 10:40 ` Nishanth Menon
2010-09-02 11:16 ` Felipe Balbi
2010-09-02 17:47 ` Kevin Hilman
2010-09-02 18:46 ` Nishanth Menon
2010-09-02 18:56 ` Kevin Hilman
2010-09-03 7:09 ` Gopinath, Thara
2010-09-03 16:41 ` Kevin Hilman
2010-09-03 17:30 ` Mark Brown
2010-09-03 18:00 ` Kevin Hilman
2010-09-03 18:20 ` Mark Brown
2010-09-06 19:59 ` Eduardo Valentin
2010-09-06 20:21 ` Liam Girdwood
2010-09-06 21:21 ` Mark Brown
2010-11-23 9:26 ` Thomas Petazzoni
2010-11-24 9:45 ` Thomas Petazzoni
2010-11-24 9:51 ` Mark Brown
2010-09-03 18:27 ` Kevin Hilman
2010-09-06 11:01 ` Mark Brown
2010-08-18 11:20 ` [PATCH 02/13] OMAP: Introduce API in the OPP layer to find the opp entry corresponding to a voltage Thara Gopinath
2010-08-18 11:20 ` [PATCH 03/13] OMAP: Introduce voltage domain information in the hwmod structures Thara Gopinath
2010-08-18 11:20 ` [PATCH 04/13] OMAP: Introduce API to return a device list associated with a voltage domain Thara Gopinath
2010-08-28 0:52 ` Kevin Hilman
2010-08-28 0:54 ` Kevin Hilman
2010-09-16 10:04 ` Gopinath, Thara
2010-09-16 15:22 ` Kevin Hilman
2010-09-17 14:48 ` Gopinath, Thara
2010-09-20 18:00 ` Kevin Hilman
2010-09-02 0:33 ` Kevin Hilman
2010-09-16 10:10 ` Gopinath, Thara
2010-09-16 15:23 ` Kevin Hilman
2010-08-18 11:20 ` [PATCH 05/13] OMAP: Introduce device specific set rate and get rate in device opp structures Thara Gopinath
2010-09-02 23:41 ` Kevin Hilman
2010-09-16 10:21 ` Gopinath, Thara
2010-09-16 15:28 ` Kevin Hilman
2010-09-17 14:55 ` Gopinath, Thara
2010-09-18 10:13 ` Cousson, Benoit
2010-09-20 17:35 ` Kevin Hilman
2010-09-29 11:16 ` Gopinath, Thara
2010-09-29 20:25 ` Cousson, Benoit
2010-08-18 11:20 ` [PATCH 06/13] OMAP: Voltage layer changes to support DVFS Thara Gopinath
2010-08-18 11:20 ` [PATCH 07/13] OMAP: Introduce dependent voltage domain support Thara Gopinath
2010-08-18 11:20 ` [PATCH 08/13] OMAP: Introduce device set_rate and get_rate Thara Gopinath
2010-08-18 11:20 ` [PATCH 09/13] OMAP: Disable smartreflex across DVFS Thara Gopinath
2010-08-18 11:20 ` [PATCH 10/13] OMAP3: Introduce custom set rate and get rate APIs for scalable devices Thara Gopinath
2010-08-31 0:06 ` Kevin Hilman
2010-08-18 11:20 ` [PATCH 11/13] OMAP3: Update cpufreq driver to use the new set_rate API Thara Gopinath
2010-08-18 11:20 ` [PATCH 12/13] OMAP3: Introduce voltage domain info in the hwmod structures Thara Gopinath
2010-08-18 11:20 ` [PATCH 13/13] OMAP3: Add voltage dependency table for VDD1 Thara Gopinath
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=87iq2vipe7.fsf@deeprootsystems.com \
--to=khilman@deeprootsystems.com \
--cc=b-cousson@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=paul@pwsan.com \
--cc=sawant@ti.com \
--cc=thara@ti.com \
--cc=vishwanath.bs@ti.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.