public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Rhyland Klein <rklein@nvidia.com>,
	Thierry Reding <treding@nvidia.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Sebastian Reichel <sre@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH] arm64: defconfig: Enable cros-ec and battery driver
Date: Wed, 25 May 2016 18:26:09 +0100	[thread overview]
Message-ID: <5745E031.7010406@nvidia.com> (raw)
In-Reply-To: <1c6df907-ea1f-201b-a36e-8311c5b2b3b1@nvidia.com>


On 25/05/16 17:36, Rhyland Klein wrote:

...

> I can see that getting the temperature could work. I would point out
> that I don't see any recent changes to bq27xxx or the power_supply_core
> that would imply this is a regression. My guess is that up until now,
> for devices that support the TEMP property, CONFIG_THERMAL isn't been
> enabled.
> 
> So here are my thoughts.... we can do 2 things here:
> 
> 1) patch bq27xxx in some manner that will allow the bq27xxx driver to
> work report the temp during register (such as above patch).
> 2) Patch the core to avoid using get_property callback during registration.

I wonder if #2 will cause other problems for other devices as this
really changes the functionality.

> I think for our immediate concern and crash, #1 is fine. It will work
> and is fine. I however think this is just a symptom of the larger issue
> (#2). In this case, the problem we see is that di->bat is used before it
> is set, and we have a way around it. However, for EVERY device that
> registers and has TEMP prop (and CONFIG_THERMAL enabled) it is going to
> receive a call with its relative di->bat uninitialized too.

I don't think we are understanding each other and I still think that
this could be specific to the bq27xxx. And here is why ...

The power supply driver is going to receive a call to it's
->get_property() function with a *VALID* pointer to the power_supply
structure, *psy. When initialised, di->bat == psy (assuming bq27xxx
naming) and so in other words, they point to the same thing. Therefore,
in the normal case, you should not need to access di->bat from within
->get_property() because you already have a valid pointer to the
power_supply structure, *psy.

So the ONLY problem would be IF the ->get_property function calls
power_supply_get_drvdata() to get a pointer to the drvdata, *di, and
then dereferences and uses the pointer, di->bat, which may NOT be
initialised yet. I am wondering how likely this is as it seems a bit
daft to do this, unless you are doing something like the bq27xxx driver
is attempting to do.

Again IMO the problem is related to how the bq27xxx driver has
implemented the status update.

Cheers
Jon

-- 
nvpublic

  reply	other threads:[~2016-05-25 17:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 15:45 [PATCH] arm64: defconfig: Enable cros-ec and battery driver Rhyland Klein
2016-05-19 17:20 ` Rhyland Klein
     [not found] ` <1462290318-9074-1-git-send-email-rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-24 14:09   ` Jon Hunter
     [not found]     ` <5744609A.1000008-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-24 19:08       ` Rhyland Klein
     [not found]         ` <324dfe74-4fc0-d500-91ac-2a802562e92f-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 10:58           ` Jon Hunter
     [not found]             ` <5745853B.1040304-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 11:03               ` Jon Hunter
2016-05-25 15:46                 ` Thierry Reding
2016-05-25 15:55                   ` Rhyland Klein
     [not found]                     ` <9411ff33-e375-8286-8690-fe7fcac1c14b-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 16:10                       ` Jon Hunter
     [not found]                         ` <5745CE75.7010603-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 16:29                           ` Jon Hunter
2016-05-25 16:36                             ` Rhyland Klein
2016-05-25 17:26                               ` Jon Hunter [this message]
     [not found]                                 ` <5745E031.7010406-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 19:44                                   ` Rhyland Klein
     [not found]                                     ` <5c03a025-f31d-fa18-b973-0b026ede9c5c-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-26 10:35                                       ` Jon Hunter
2016-05-27  8:37                                     ` Krzysztof Kozlowski
     [not found]                                       ` <5748073F.1030704-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-05-27  9:19                                         ` Krzysztof Kozlowski
2016-05-27 10:28                                         ` Jon Hunter
     [not found]                                           ` <57482162.20306-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-27 11:46                                             ` Krzysztof Kozlowski
     [not found]                                               ` <5748339E.9080504-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-05-27 12:17                                                 ` Jon Hunter
2016-05-27 12:55                                                   ` Krzysztof Kozlowski
     [not found]                                                     ` <574843D4.4080303-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-05-31 17:24                                                       ` Jon Hunter
     [not found]                             ` <5745D2DD.6080300-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 16:36                               ` Jon Hunter
     [not found]                   ` <20160525154618.GD13765-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-05-25 15:57                     ` Jon Hunter
     [not found]                 ` <57458693.3050700-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-25 15:49                   ` Rhyland Klein

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=5745E031.7010406@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=gnurou@gmail.com \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=rklein@nvidia.com \
    --cc=sre@kernel.org \
    --cc=swarren@wwwdotorg.org \
    --cc=treding@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