linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>, Sebastian Reichel <sre@kernel.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH 3/4] power: supply: axp288_fuel_gauge: Unregister duplicate ACPI battery supply
Date: Tue, 11 Apr 2017 11:18:33 +0200	[thread overview]
Message-ID: <2796ccd7-333c-848c-1409-2a76fb498d94@redhat.com> (raw)
In-Reply-To: <CAJZ5v0i0pZwBvd1WFYxGh9grbDyRkYWoLY7VSn3+mbLZdmQnxw@mail.gmail.com>

Hi,

On 10-04-17 22:01, Rafael J. Wysocki wrote:
> On Mon, Apr 10, 2017 at 8:13 PM, Hans de Goede <hdegoede@redhat.com> wrote:

<snip>

>>>>>> OK
>>>>>>
>>>>>> Anyway, I'd prefer blacklists in the battery and ac drivers to be
>>>>>> honest.
>>>>>
>>>>>
>>>>> As I explained in my reply to the discussion around the first patch that
>>>>> is somewhat hard to do and requires encoding knowledge in those drivers
>>>>> which really does not belong there:
>>>>>
>>>>> "The problem is that Intel re-uses HIDs between generations and
>>>>> for the Whiskey Cove PMIC we want to not use the ACPI battery
>>>>> and ac drivers on Cherry Trail (where they are known to be
>>>>> broken) but things are different on Apollo Lake. Yet both
>>>>> use the same HID for their companion Whiskey Cove PMIC even
>>>>> though they are 2 completely different revisions of the PMIC
>>>>> (e.g. one uses i2c the other does not).
>>>>>
>>>>> The 2 native drivers have code to detect which revision they
>>>>> are dealing with and exit with -ENODEV if it is not the
>>>>> revision they were written for, but this means that simple
>>>>> HID blacklisting will not work. So IMHO the decision to
>>>>> unregister the  ACPI battery / ac interface really belongs
>>>>> in the native driver as that has all the nitty gritty detail
>>>>> needed to make that decision."
>>>>
>>>>
>>>> So thinking more about this, esp. after receiving a bug report
>>>> from a user getting ACPI errors because of Linux not implementing
>>>> the proprietary undocumented BMOP opregion before the ACPI battery
>>>> driver gets unregistered by the native one, I thing we do indeed
>>>> need to go with a blacklist.
>>>>
>>>> This means also being able to match by _HRV, as Some HIDs are
>>>> re-used for different hardware between Bay Trail / Cherry Trail /
>>>> Broxton with just a bump of _HRV.
>>>>
>>>> I'm currently working on respinning my
>>>> "acpi: utils: Add new acpi_dev_present helper" to address the
>>>> review comments on it. I'm going to give it an optional hrv
>>>> function argument for this use, so as to not having to implement
>>>> hrv checking code in both ac.c and battery.c .
>>>
>>>
>>> So a quick copy paste from another thread, the black-list approach
>>> causes regressions even before hitting -next and seeing any
>>> substantial testing, so we're back to adding unregister functions
>>> and calling those from native PMIC power_supply drivers when the
>>> native power_supply has been successfully registered.
>>>
>>> Some Bay Trail / Cherry Trail users are running kernels build
>>> from my personal tree to get early access to various fixes
>>> in there and I got a regression report on the DELL 5855, where
>>> the blacklisting of the ACPI battery driver if INT33F4 is
>>> present caused the battery monitoring to stop working, that
>>> devices has an INT33F4 node with _STA returning 15 yet it
>>> is not using an axp288 PMIC at all, I'm still gathering more
>>> info, but I believe atm that Dell simply disabled the i2c
>>> controller to which the axp288 would be connected if present
>>> and left the other bits of the DTSD unmodified.
>>>
>>> One option which comes to mind would be to only count devices
>>> as present if all their deps are met, but that will only
>>> work if the blacklist check is done after all other drivers
>>> have loaded which is not how things work.
>>>
>>> So I believe that my earlier attempts at fixing the double
>>> power_supply registration by unregistering the ACPI one when
>>> the native one has successfully loaded is better. That guarantees
>>> regressions like this one will not happen, because the ACPI
>>> power_supply does not get unregistered until the native one
>>> has loaded.
>>
>>
>> Ok scrap that, I've some more info and the INT33F4 node on
>> the Dell 5855 is returning 0 from _STA and the blacklist is
>> causing problems on that machine for other reason, it could
>> be the user was using an older version with the uninitialized
>> .cls match info problem, I've asked the user to test the latest
>> version.
>>
>> So assuming that does work, we are good to go with the blacklist
>> approach (which seems to be the solution everyone prefers),
>> sorry about the noise.
>
> OK, but there's one more possibility to consider.
>
> Instead of unregistering the ACPI battery (or AC) driver from the
> platform device driver superseding it, you could clear the
> match_driver flag for the ACPI companion device and call
> device_release_driver() on it, like acpi_bus_trim().  Then (because
> the match_driver flag is unset) the driver core will not try to attach
> the driver to the thing again - until the next invocation of
> acpi_bus_attach() on it, which I think is a bug, because there seems
> to be a flags.visited check missing in there (I need to go back and
> recall why it is not there).
>
> Arguably, that would be a more lightweight way of getting what you
> want without using a blacklist.

The reason I changed my mind on the blacklist approach and went
from unregistering on native-power-supply register to the blacklist
is because some users where seeing a ton of ACPI errors from the
ACPI battery driver trying to use the broken ACPI battery dev in
the DTSD before the native PMIC driver loaded and unregistered
the battery dev. So I really believe the blacklist is the right
approach.

I just got confirmation from the user that the regression on the
Dell 5855 was indeed a false positive.

So from my pov we are good to go with v5 of patch 1 of this
set and v2 (also send as v3 and v4 but unchanged) of patches
2-4 of this set.

Regards,

Hans

  reply	other threads:[~2017-04-11  9:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 16:15 [PATCH 0/4] Avoid duplicate registering of ACPI and native power-supplies Hans de Goede
2017-03-16 16:15 ` [PATCH 1/4] acpi: battery: Add acpi_battery_unregister() function Hans de Goede
2017-03-16 16:29   ` Andy Shevchenko
2017-03-20 13:03     ` Hans de Goede
2017-03-20 13:10       ` Andy Shevchenko
2017-03-20 13:11         ` Hans de Goede
2017-03-27  1:16   ` Zheng, Lv
2017-03-31  8:53     ` Hans de Goede
2017-03-31  9:00       ` Hans de Goede
2017-03-16 16:15 ` [PATCH 2/4] acpi: ac: Add acpi_ac_unregister() function Hans de Goede
2017-03-16 16:31   ` Andy Shevchenko
2017-03-16 16:16 ` [PATCH 3/4] power: supply: axp288_fuel_gauge: Unregister duplicate ACPI battery supply Hans de Goede
2017-03-16 16:33   ` Andy Shevchenko
2017-03-20 13:07     ` Hans de Goede
2017-03-29 20:31   ` Rafael J. Wysocki
2017-03-31  9:01     ` Hans de Goede
2017-03-31  9:05       ` Rafael J. Wysocki
2017-03-31  9:08         ` Hans de Goede
2017-03-31  9:11           ` Rafael J. Wysocki
2017-03-31  9:57             ` Hans de Goede
2017-03-31 22:30               ` Rafael J. Wysocki
2017-04-01 13:22                 ` Hans de Goede
2017-04-07  7:18               ` Hans de Goede
2017-04-10  7:31                 ` Hans de Goede
2017-04-10 18:13                   ` Hans de Goede
2017-04-10 20:01                     ` Rafael J. Wysocki
2017-04-11  9:18                       ` Hans de Goede [this message]
2017-04-11 13:51                         ` Rafael J. Wysocki
2017-03-16 16:16 ` [PATCH 4/4] power: supply: axp288_charger: Unregister duplicate ACPI ac supply Hans de Goede
2017-03-16 16:34   ` Andy Shevchenko
2017-03-20  1:33 ` [PATCH 0/4] Avoid duplicate registering of ACPI and native power-supplies Sebastian Reichel
2017-03-20 13:11   ` Hans de Goede
2017-03-20 13:18     ` Andy Shevchenko
2017-03-20 13:19       ` Hans de Goede
2017-03-20 21:55   ` Rafael J. Wysocki

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=2796ccd7-333c-848c-1409-2a76fb498d94@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sre@kernel.org \
    --cc=wens@csie.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).