From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: myungjoo.ham@samsung.com
Cc: "Sebastian Reichel" <sre@kernel.org>,
"Dmitry Eremin-Solenikov" <dbaryshkov@gmail.com>,
"David Woodhouse" <dwmw2@infradead.org>,
"Anton Vorontsov" <anton@enomsg.org>,
이종화 <jonghwa3.lee@samsung.com>, 최찬우 <cw00.choi@samsung.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
박경민 <kyungmin.park@samsung.com>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>
Subject: Re: [PATCH v2 2/2] power: charger-manager: Avoid recursive thermal get_temp call
Date: Mon, 13 Oct 2014 10:58:01 +0200 [thread overview]
Message-ID: <1413190681.3829.7.camel@AMDC1943> (raw)
In-Reply-To: <326901692.426181413180076268.JavaMail.weblogic@epmlwas05a>
On pon, 2014-10-13 at 06:01 +0000, MyungJoo Ham wrote:
> >
> > Add a 'no_thermal' property to the power supply class. If true then
> > thermal zone won't be created for this power supply in
> > power_supply_register().
> >
> > Power supply drivers may want to set it if they support
> > POWER_SUPPLY_PROP_TEMP and they are forwarding this get property call to
> > other thermal zone.
> >
> > If they won't set it lockdep may report false positive deadlock for
> > thermal zone's mutex because of nested calls to thermal_zone_get_temp().
> > First is the call to thermal_zone_get_temp() of the driver's thermal
> > zone. Thermal core gets POWER_SUPPLY_PROP_TEMP property from this
> > driver. The driver then calls other thermal zone thermal_zone_get_temp()
> > and returns result.
> >
> > Example of such driver is charger manager.
> >
> > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>
> Do we really need to add another variable in the psy struct?
> In the previous thread, I thought that wasn't needed, though.
I considered the idea mentioned by Jonghwa Lee:
static int psy_register_thermal(struct power_supply *psy)
{
...
+ if (psy->tzd)
+ return 0;
but there would be problem in determining the ownership of the thermal
zone - who should unregister that thermal zone? Charger manager's power
supply or fuel gauge's power supply?
We could NULL-ify it manually from charger's remove function before
calling power_supply_unregister... but it is really accessing a private
field of power_supply structure.
I think this should be done in API-level.
Best regards,
Krzysztof
>
>
> Cheers,
> MyungJoo
>
> >
> > ---
> >
> > Changes since v1:
> > 1. New patch (new idea).
> > ---
> > drivers/power/power_supply_core.c | 3 +++
> > include/linux/power_supply.h | 6 ++++++
> > 2 files changed, 9 insertions(+)
> >
> > diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
> > index 6cb7fe5c022d..694e8cddd5c1 100644
> > --- a/drivers/power/power_supply_core.c
> > +++ b/drivers/power/power_supply_core.c
> > @@ -417,6 +417,9 @@ static int psy_register_thermal(struct power_supply *psy)
> > {
> > int i;
> >
> > + if (psy->no_thermal)
> > + return 0;
> > +
> > /* Register battery zone device psy reports temperature */
> > for (i = 0; i < psy->num_properties; i++) {
> > if (psy->properties[i] == POWER_SUPPLY_PROP_TEMP) {
> > diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> > index 3ed049673022..096dbced02ac 100644
> > --- a/include/linux/power_supply.h
> > +++ b/include/linux/power_supply.h
> > @@ -200,6 +200,12 @@ struct power_supply {
> > void (*external_power_changed)(struct power_supply *psy);
> > void (*set_charged)(struct power_supply *psy);
> >
> > + /*
> > + * Set if thermal zone should not be created for this power supply.
> > + * For example for virtual supplies forwarding calls to actual
> > + * sensors or other supplies.
> > + */
> > + bool no_thermal;
> > /* For APM emulation, think legacy userspace. */
> > int use_for_apm;
> >
> > --
> > 1.9.1
> >
next prev parent reply other threads:[~2014-10-13 8:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-13 6:01 [PATCH v2 2/2] power: charger-manager: Avoid recursive thermal get_temp call MyungJoo Ham
2014-10-13 8:58 ` Krzysztof Kozlowski [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-10-07 15:47 [PATCH v2 1/2] power_supply: Add no_thermal property to prevent recursive get_temp calls Krzysztof Kozlowski
2014-10-07 15:47 ` [PATCH v2 2/2] power: charger-manager: Avoid recursive thermal get_temp call Krzysztof Kozlowski
2014-10-27 18:32 ` Sebastian Reichel
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=1413190681.3829.7.camel@AMDC1943 \
--to=k.kozlowski@samsung.com \
--cc=anton@enomsg.org \
--cc=b.zolnierkie@samsung.com \
--cc=cw00.choi@samsung.com \
--cc=dbaryshkov@gmail.com \
--cc=dwmw2@infradead.org \
--cc=jonghwa3.lee@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=myungjoo.ham@samsung.com \
--cc=sre@kernel.org \
/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).