From: Stephen Warren <swarren@wwwdotorg.org>
To: Wei Ni <wni@nvidia.com>
Cc: durgadoss.r@intel.com, rui.zhang@intel.com,
MLongnecker@nvidia.com, khali@linux-fr.org,
devicetree-discuss@lists.ozlabs.org, linux-tegra@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.orgrs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC PATCH 7/9] thermal: tegra30: add tegra30 thermal driver
Date: Tue, 19 Feb 2013 16:48:42 -0700 [thread overview]
Message-ID: <51240F5A.1060309@wwwdotorg.org> (raw)
In-Reply-To: <1361187031-3679-8-git-send-email-wni@nvidia.com>
On 02/18/2013 04:30 AM, Wei Ni wrote:
> dd Tegra30 thermal driver support. It create thermal zone with thermal
> sensors and cooling device to participate in the linux thermal management.
> diff --git a/drivers/thermal/tegra3_thermal.c b/drivers/thermal/tegra3_thermal.c
> +struct tegra_thermal_data {
That's not really "thermal data", but that "thermal zone" or "thermal
device" itself.
> +static int
> +tegra_throttle_set_cur_state(struct thermal_cooling_device *cdev,
> + unsigned long cur_state)
> +{
> + struct balanced_throttle *bthrot = cdev->devdata;
> + int index;
> +
> + mutex_lock(&cpu_throttle_lock);
> +
> + /* TODO: we will handle the dvfs here */
That seems like rather a large TODO. We don't have any DVFS support for
Tegra yet. Is it even worth moving forward with this driver without that?
> +struct thermal_cooling_device *balanced_throttle_register(
> + struct balanced_throttle *bthrot, char *type)
What does "balanced" mean here; isn't balanced a governor, whereas this
driver is simply providing the implementation that an arbitrary governor
would use to do its will?
This function also appears to be rather generically named. A consistent
function/symbol-name prefix of e.g. "tegra30_thermal" would be useful
throughout the file.
> +static struct tegra_thermal_data * __devinit thermal_tegra_dt_parse_pdata(
> + struct platform_device *pdev)
I'd like some slight re-structing here.
Tegra only supports device tree now; no board files (upstream at least,
which is all that's relevant here). Hence, none of the Tegra drivers
support platform data at all after the last round of cleanup patches I
sent on Friday (most of which haven't been checked in yet). Hence, this
function is not parsing platform data out of DT, it's plain parsing
device tree.
So, can you move the devm_kzalloc of the tdata into probe() right at the
start, rename this function tegra30_thermal_parse_dt(), and call it
right after allocating "tdata" (which also is more like "tdev" or
"tzone" perhaps).
Downstream if you still need to support platform data, you can simply
copy the platform data into "tdev" rather than calling
tegra30_thermal_parse_dt(); a simple patch to carry.
> + tdata = devm_kzalloc(&pdev->dev, sizeof(*tdata), GFP_KERNEL);
> + if (!tdata) {
> + dev_err(&pdev->dev, "Can't allocate platform data\n");
> + return NULL;
> + }
> + memset(tdata, 0, sizeof(*tdata));
That last line is kinda the whole point of k*z*alloc...
> +
> + ret = of_parse_phandle_with_args(np, "sensors", "#sensor-cells", 0,
> + &args);
> + if (ret) {
> + dev_err(&pdev->dev, "Can't get sensor.\n");
> + return NULL;
> + }
> + tdata->np_args.np = args.np;
> + tdata->np_args.index = args.args[0];
That lookup should be implemented as part of the thermal core. It
shouldn't be duplicated in every single driver.
> + ret = of_property_read_u32(np, "passive-delay", &val);
> + if (!ret)
> + tdata->passive_delay = val;
The DT binding documentation doesn't say this property is optional. If
you intend it to be, the documentation should say so, and specify what
the default is if the property is missing.
> + ret = of_property_read_u32(np, "num-passive-trips", &val);
> + if (!ret)
> + tdata->trip_ext.num_passive_trips = val;
> +
> + if (tdata->trip_ext.num_passive_trips) {
> + tdata->trip_ext.passive_trips = devm_kzalloc(&pdev->dev,
> + sizeof(int) * val, GFP_KERNEL);
DT cells are specifically U32 not int. You probably want the driver to
use U32 instead of int to make 100% sure the range matches.
> +
> + of_property_read_u32_array(np, "passive-trips",
> + (u32 *)(tdata->trip_ext.passive_trips),
> + tdata->trip_ext.num_passive_trips);
... and then you wouldn't need this cast!
> + }
> + of_property_read_u32_array(np, "throt-tab",
> + (u32 *)(&tdata->tj_throttle.throt_tab),
> + tdata->tj_throttle.throt_tab_size * 2);
What about error-handling that API call, and all the others?
> +static int tegra30_thermal_probe(struct platform_device *pdev)
> +{
> + struct tegra_thermal_data *pdata = pdev->dev.platform_data;
Lets not support platform data at all upstream.
> + /* Register cooling device */
> + cdev = balanced_throttle_register(&pdata->tj_throttle, "cdev_throttle");
Is this picking specific policy ("balanced")? Should it be? What is
"cdev_throttle"?
next prev parent reply other threads:[~2013-02-19 23:48 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 11:30 [RFC PATCH 0/9] Support for tegra30 thermal Wei Ni
2013-02-18 11:30 ` [RFC PATCH 2/9] hwmon: (lm90) split set&show temp as common codes Wei Ni
2013-02-18 22:29 ` Matthew Longnecker
2013-02-19 9:48 ` Wei Ni
2013-02-19 3:31 ` [lm-sensors] " Guenter Roeck
[not found] ` <20130219033144.GA25610-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-19 10:00 ` Wei Ni
2013-02-19 22:56 ` Stephen Warren
[not found] ` <51240331.7080604-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20 12:31 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 4/9] hwmon: (lm90) use macros for the indexes of temp8 and temp11 Wei Ni
2013-02-19 5:39 ` Alex Courbot
[not found] ` <5123100A.9050604-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 9:58 ` Wei Ni
2013-02-19 23:02 ` Stephen Warren
[not found] ` <51240497.8010909-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20 10:29 ` Wei Ni
[not found] ` <1361187031-3679-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-18 11:30 ` [RFC PATCH 1/9] ARM: dt: t30 cardhu: add dt entry for lm90 Wei Ni
[not found] ` <1361187031-3679-2-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 3:28 ` Alex Courbot
2013-02-19 9:52 ` Wei Ni
[not found] ` <5122F162.9030103-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 22:48 ` Stephen Warren
2013-02-18 11:30 ` [RFC PATCH 3/9] hwmon: (lm90) add support to handle irq Wei Ni
[not found] ` <1361187031-3679-4-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 3:34 ` [lm-sensors] " Guenter Roeck
2013-02-19 10:43 ` Wei Ni
2013-02-19 23:00 ` Stephen Warren
2013-02-20 3:27 ` Alex Courbot
[not found] ` <5124429B.2000404-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-20 10:27 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 5/9] Thermal: Support using dt node to get sensor Wei Ni
[not found] ` <1361187031-3679-6-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 23:12 ` Stephen Warren
[not found] ` <512406F0.4080708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20 10:36 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 6/9] hwmon: (lm90) Register to the thermal framework Wei Ni
2013-02-19 3:42 ` [lm-sensors] " Guenter Roeck
[not found] ` <20130219034205.GC25610-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-19 10:47 ` Wei Ni
2013-02-19 5:22 ` Alex Courbot
2013-02-19 10:58 ` Wei Ni
[not found] ` <1361187031-3679-7-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 23:18 ` Stephen Warren
2013-02-20 10:40 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 8/9] ARM: dt: t30 cardhu: add dt entry for thermal driver Wei Ni
2013-02-19 3:42 ` Alex Courbot
2013-02-19 9:56 ` Wei Ni
[not found] ` <1361187031-3679-9-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 23:28 ` Stephen Warren
2013-02-20 11:53 ` Wei Ni
[not found] ` <5124B934.3020900-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-20 17:18 ` Stephen Warren
2013-02-18 11:30 ` [RFC PATCH 9/9] ARM: tegra: defconfig: enable thermal framework Wei Ni
2013-02-18 11:30 ` [RFC PATCH 7/9] thermal: tegra30: add tegra30 thermal driver Wei Ni
2013-02-19 23:48 ` Stephen Warren [this message]
2013-02-20 12:23 ` Wei Ni
2013-02-19 23:56 ` Russell King - ARM Linux
[not found] ` <20130219235629.GU17833-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-02-20 12:29 ` Wei Ni
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=51240F5A.1060309@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=MLongnecker@nvidia.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=durgadoss.r@intel.com \
--cc=khali@linux-fr.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.orgrs.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=rui.zhang@intel.com \
--cc=wni@nvidia.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).