11 Feb, 2020

3 commits

  • commit ff3154d1d89a2343fd5f82e65bc0cf1d4e6659b3 upstream.

    Commit b41901a2cf06 ("ACPI / battery: Do not export energy_full[_design] on
    devices without full_charge_capacity") added support for some (broken)
    devices which always report 0 for both design_capacity and
    full_charge_capacity.

    Since the device that commit was written as a fix for is not reporting any
    form of "full" capacity we cannot calculate the value for the
    POWER_SUPPLY_PROP_CAPACITY, this is worked around by using an alternative
    array of available properties which does not contain this property.

    This is necessary because userspace (upower) treats us returning -ENODEV
    as 0 and then typically will trigger an emergency shutdown because of that.
    Userspace does not do this if the capacity sysfs attribute is not present
    at all.

    There are two potential problems with that commit:
    1) It assumes that both full_charge- and design-capacity are broken at the
    same time and only checks if full_charge- is broken.
    2) It assumes that this only ever happens for devices which report energy
    units rather then charge units.

    This commit fixes both issues by only using the alternative
    array of available properties if both full_charge- and design-capacity are
    broken and by also adding an alternative array of available properties for
    devices using mA units.

    Fixes: b41901a2cf06 ("ACPI / battery: Do not export energy_full[_design] on devices without full_charge_capacity")
    Cc: 4.19+ # 4.19+
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     
  • commit 5b74d1d16e2f5753fcbdecd6771b2d8370dda414 upstream.

    The ThunderSoft TS178 tablet's _BIX implementation reports design_capacity
    but not full_charge_capacity.

    Before this commit this would cause us to return -ENODEV for the capacity
    attribute, which userspace does not like. Specifically upower does this:

    if (sysfs_file_exists (native_path, "capacity")) {
    percentage = sysfs_get_double (native_path, "capacity");

    Where the sysfs_get_double() helper returns 0 when we return -ENODEV,
    so the battery always reads 0% if we return -ENODEV.

    This commit fixes this by using the design-capacity instead of the
    full-charge-capacity when the full-charge-capacity is not available.

    Fixes: b41901a2cf06 ("ACPI / battery: Do not export energy_full[_design] on devices without full_charge_capacity")
    Cc: 4.19+ # 4.19+
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     
  • commit cc99f0ad52467028cb1251160f23ad4bb65baf20 upstream.

    Commit b41901a2cf06 ("ACPI / battery: Do not export energy_full[_design]
    on devices without full_charge_capacity") added support for some (broken)
    devices which always report 0 for both design- and full_charge-capacity.

    This assumes that if the capacity is not being reported it is 0. The
    ThunderSoft TS178 tablet's _BIX implementation falsifies this assumption.
    It reports ACPI_BATTERY_VALUE_UNKNOWN (-1) as full_charge_capacity, which
    we treat as a valid value which causes several problems.

    This commit fixes this by adding a new ACPI_BATTERY_CAPACITY_VALID() helper
    which checks that the value is not 0 and not -1; and using this whenever we
    need to test if either design_capacity or full_charge_capacity is valid.

    Fixes: b41901a2cf06 ("ACPI / battery: Do not export energy_full[_design] on devices without full_charge_capacity")
    Cc: 4.19+ # 4.19+
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     

31 May, 2019

1 commit

  • Based on 3 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version [author] [kishon] [vijay] [abraham]
    [i] [kishon]@[ti] [com] this program is distributed in the hope that
    it will be useful but without any warranty without even the implied
    warranty of merchantability or fitness for a particular purpose see
    the gnu general public license for more details

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version [author] [graeme] [gregory]
    [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
    [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
    [hk] [hemahk]@[ti] [com] this program is distributed in the hope
    that it will be useful but without any warranty without even the
    implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1105 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

09 Aug, 2018

1 commit

  • On some devices (with a buggy _BIX implementation) full_charge_capacity
    always reports as 0. This means that our energy_full sysfs attribute will
    also always be 0, which is not useful to export.

    Worse we calculate our reported capacity on full_charge_capacity and if it
    is 0 we always report 0. This causes userspace to immediately shutdown or
    hibernate the laptop since it assumes that the battery is critically low.

    This commit makes us not report energy_full[_design] or capacity on such
    broken devices, avoiding the immediate shutdown / hibernate from userspace.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=83941
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki

    Hans de Goede
     

25 Jul, 2018

4 commits

  • Simple conditions without negations inflict less cognitive load
    on readers.

    Rework conditional branches not to use negations. Also add braces
    around single statement branches where their counterpart else-branches
    consist of more than one statement as suggested in the paragraph 3 of
    the coding style.

    Suggested-by: Andy Shevchenko
    Signed-off-by: Dmitry Rozhkov
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Rafael J. Wysocki

    Dmitry Rozhkov
     
  • The kernel provides specialized macros for printing
    info and warning messages which make the code shorter.

    Use the specialized macros instead of bare printk()'s.

    Also format one user visible string literal into a searchable one
    line string.

    Suggested-by: Andy Shevchenko
    Signed-off-by: Dmitry Rozhkov
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Rafael J. Wysocki

    Dmitry Rozhkov
     
  • Headers ordered alphabetically as easier to maintain.

    Suggested-by: Andy Shevchenko
    Signed-off-by: Dmitry Rozhkov
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Rafael J. Wysocki

    Dmitry Rozhkov
     
  • The driver can be built as a module thus inclusion of init.h is
    redundant in battery.c since it's always included by module.h.

    Suggested-by: Andy Shevchenko
    Signed-off-by: Dmitry Rozhkov
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Rafael J. Wysocki

    Dmitry Rozhkov
     

24 Jul, 2018

1 commit

  • On removal battery_present changes from 1 to 0 after calling
    acpi_battery_get_status() and battery->update_time is set to 0
    before returning.

    On insertion battery_present changes from 0 to 1 after calling
    acpi_battery_get_status() and acpi_battery_get_info() is called
    because battery->update_time is 0.

    The old_present condition is therefore redundant.

    This was added in the commit below when there was a path without
    sysfs that would skip getting the newly inserted battery info.

    commit 50b178512b7d ("Newly inserted battery might differ from one
    just removed, so update of battery info fields is required.")

    Signed-off-by: Lucas Rangit Magasweran
    Signed-off-by: Rafael J. Wysocki

    Lucas Rangit Magasweran
     

04 Jul, 2018

1 commit

  • A hooking API was implemented for 4.17 in fa93854f7a7ed63d followed
    by hooks for Thinkpad laptops in 2801b9683f740012. The Thinkpad
    drivers did not support the Thinkpad 13 and the hooking API crashes
    on unsupported batteries by altering a list of hooks during unsafe
    iteration. Thus, Thinkpad 13 laptops could no longer boot.

    Additionally, a lock was kept in place and debugging information was
    printed out of order.

    Fixes: fa93854f7a7e (battery: Add the battery hooking API)
    Cc: 4.17+ # 4.17+
    Signed-off-by: Jouke Witteveen
    Signed-off-by: Rafael J. Wysocki

    Jouke Witteveen
     

06 Jun, 2018

1 commit

  • Pull ACPI updates from Rafael Wysocki:
    "These update the ACPICA code in the kernel to the 20180508 upstream
    revision and make it support the RT patch, add CPPC v3 support to the
    ACPI CPPC library, add a WDAT-based watchdog quirk to prevent clashes
    with the RTC, add quirks to the ACPI AC and battery drivers, and
    update the ACPI SoC drivers.

    Specifics:

    - Update the ACPICA code in the kernel to the 20180508 upstream
    revision including:
    * iASL -tc option enhancement (Bob Moore).
    * Debugger improvements (Bob Moore).
    * Support for tables larger than 1 MB in acpidump/acpixtract (Bob
    Moore).
    * Minor fixes and cleanups (Colin Ian King, Toomas Soome).

    - Make the ACPICA code in the kernel support the RT patch (Sebastian
    Andrzej Siewior, Steven Rostedt).

    - Add a kmemleak annotation to the ACPICA code (Larry Finger).

    - Add CPPC v3 support to the ACPI CPPC library and fix two issues
    related to CPPC (Prashanth Prakash, Al Stone).

    - Add an ACPI WDAT-based watchdog quirk to prefer iTCO_wdt on systems
    where WDAT clashes with the RTC SRAM (Mika Westerberg).

    - Add some quirks to the ACPI AC and battery drivers (Carlo Caione,
    Hans de Goede).

    - Update the ACPI SoC drivers for Intel (LPSS) and AMD (APD)
    platforms (Akshu Agrawal, Hans de Goede).

    - Fix up some assorted minor issues (Al Stone, Laszlo Toth, Mathieu
    Malaterre)"

    * tag 'acpi-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (32 commits)
    ACPICA: Mark acpi_ut_create_internal_object_dbg() memory allocations as non-leaks
    ACPI / watchdog: Prefer iTCO_wdt always when WDAT table uses RTC SRAM
    mailbox: PCC: erroneous error message when parsing ACPI PCCT
    ACPICA: Update version to 20180508
    ACPICA: acpidump/acpixtract: Support for tables larger than 1MB
    ACPI: APD: Add AMD misc clock handler support
    clk: x86: Add ST oscout platform clock
    ACPICA: Update version to 20180427
    ACPICA: Debugger: Removed direct support for EC address space in "Test Objects"
    ACPICA: Debugger: Add Package support for "test objects" command
    ACPICA: Improve error messages for the namespace root node
    ACPICA: Fix potential infinite loop in acpi_rs_dump_byte_list
    ACPICA: vsnprintf: this statement may fall through
    ACPICA: Tables: Fix spelling mistake in comment
    ACPICA: iASL: Enhance the -tc option (create AML hex file in C)
    ACPI: Add missing prototype_for arch_post_acpi_subsys_init()
    ACPI / tables: improve comments regarding acpi_parse_entries_array()
    ACPICA: Convert acpi_gbl_hardware lock back to an acpi_raw_spinlock
    ACPICA: provide abstraction for raw_spinlock_t
    ACPI / CPPC: Fix invalid PCC channel status errors
    ...

    Linus Torvalds
     

16 May, 2018

1 commit


10 May, 2018

1 commit

  • With commit dccfae6d4f4c (ACPI / battery: Add a blacklist with PMIC ACPI
    HIDs with a native battery driver) a blacklist was introduced to avoid
    using the ACPI drivers for the battery when a native PMIC driver was
    already present. While this is in general a good idea (because of broken
    DSDT or proprietary and undocumented ACPI opregions for the ACPI battery
    devices) there are some Cherry Trail devices which use a separate FG
    controller despite the AXP288 having a builtin FG.

    The net effect of blacklisting the ACPI drivers is that on these devices
    the battery reporting is broken since the AXP288 PMIC FG bits are not
    actually used on this hardware.

    This commit adds a battery_do_not_check_pmic quirk for this and sets
    this on the 2 devices currently known to use a separate FG controller,
    the ECS EF20EA and the Lenovo Ideapad Miix 320.

    [hdegoede@redhat.com: Merge the quirk handling and the adding of the DMI
    table entry into 1 commit, add a second DMI entry for the Miix 320.]

    Signed-off-by: Carlo Caione
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki

    Carlo Caione
     

02 May, 2018

3 commits

  • On some devices the "AC" interface ACPI AML code uses the exact same broken
    logic which is causing the battery code to wrongly report discharging to
    determine the "AC" state. Specifically the ACPI AML code is checking the
    charging status bits of the charger-IC rather then the vbus present or
    power-good status bits.

    This makes our workaround for devices which wrongly report discharging when
    plugged into AC while the charge is above the start charging threshold not
    work on these devices.

    This commit adds a battery_ac_is_broken flag and when that is set it skips
    the power_supply_is_system_supplied() check in the workaround fixing this.

    This flag gets set by a DMI quirk selected by systems where we know the AC
    AML code is broken in this way *and* the rate_now value can be trusted.

    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki

    Hans de Goede
     
  • On quite a few devices the battery code in the ACPI tables is buggy and
    first checks the charging status bits of the charger-IC, and if those
    report not charging it will report discharging, without looking at the
    presence of AC power or at the battery dis(charge) current from the
    fuel-gauge.

    This causes the wrong status to be reported for the battery in the
    following quite common scenario:

    1) Plug in charger while battery is say half full, battery starts
    charging, charging state bits indicate: pre-charge or fast-charge,
    ACPI reported battery status is ok

    2) When fully charged charging state bits indicate: end-of-charge,
    ACPI reported battery status is ok

    3) unplug the charger, wait 1 minute, replug. Now the battery voltage is
    still above the start-charging threshold, so the charger will not start
    charging to avoid wrecking the battery by repeatedly recharging the last 1%
    capacity. The charger IC charging state bits now are all 0 (not-charging)
    and the broken ACPI code wrongly translate this to "discharging" and ends
    up setting the ACPI_BATTERY_STATE_DISCHARGING bit in its state field.

    Reporting this "not charging" state as discharging is confusing for users,
    making the user think his adapter/power-brick is broken or not properly
    plugged in.

    This commit adds a helper for handling the ACPI_BATTERY_STATE_DISCHARGING
    state. This helper checks if we're an AC and the current going out of the
    battery is 0 and in that case reports a status of "not charging" to
    userspace rather then "discharging".

    This replaces commit c68f0676ef7d ("ACPI / battery: Add quirk for Asus
    GL502VSK and UX305LA"), a previous fix for this which was reverted.

    Signed-off-by: Hans de Goede
    Reviewed-by: Daniel Drake
    Reviewed-by: Sebastian Reichel
    Signed-off-by: Rafael J. Wysocki

    Hans de Goede
     
  • The battery code does not use the dmi_system_id ident member, so there is
    no need to initialize it. This saves us storing the unused strings as
    as const data.

    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki

    Hans de Goede
     

02 Apr, 2018

1 commit

  • * acpi-battery:
    Revert "ACPI: battery: Add the ThinkPad "Not Charging" quirk"
    ACPI: battery: do not export degraded capacity values over 100
    ACPI: battery: make function __battery_hook_unregister() static
    ACPI: battery: Add the ThinkPad "Not Charging" quirk
    thinkpad_acpi: Add support for battery thresholds
    power: add to_power_supply macro to the API
    battery: Add the battery hooking API

    * acpi-doc:
    ACPI: sysfs: Update device object sysfs documentation

    * acpi-pmic:
    ACPI / PMIC: Replace license boilerplate with SPDX license identifier

    Rafael J. Wysocki
     

19 Mar, 2018

1 commit

  • Revert commit c68f0676ef7d ("ACPI / battery: Add quirk for Asus
    GL502VSK and UX305LA") and commit 4446823e2573 ("ACPI / battery: Add
    quirk for Asus UX360UA and UX410UAK").

    On many many Asus products, the battery is sometimes reported as
    charging or discharging even when it is full and you are on AC power.
    This change quirked the kernel to avoid advertising the discharging
    state when this happens on 4 laptop models, under the belief that
    this was incorrect information. I presume it originates from user
    reports who are confused that their battery status icon says that it
    is discharging.

    However, the reported information is indeed correct, and the quirk
    approach taken is inadequate and more thought is needed first.
    Specifically:

    1. It only quirks discharging state, not charging

    2. There are so many different Asus products and DMI naming variants
    within those product families that behave this way; Linux could
    grow to quirk hundreds of products and still not even be close at
    "winning" this battle.

    3. Asus previously clarified that this behaviour is intentional. The
    platform will periodically do a partial discharge/charge cycle
    when the battery is full, because this is one way to extend the
    lifetime of the battery (leaving a battery at 100% charge and
    unused will decrease its usable capacity over time).

    My understanding is that any decent consumer product will have
    this behaviour, but it appears that Asus is different in that
    they expose this info through ACPI.

    However, the behaviour seems correct. The ACPI spec does not
    suggest in that the platform should hide the truth. It lets you
    report that the battery is full of charge, and discharging, and
    with external power connected; and Asus does this.

    4. In terms of not confusing the user, this seems like something that
    could/should be handled by userspace, which can also detect these
    same (accurate) conditions in the general case.

    Revert this quirk before it gets included in a release, while we look
    for better approaches.

    Signed-off-by: Daniel Drake
    Acked-by: Kai-Heng Feng
    Signed-off-by: Rafael J. Wysocki

    Daniel Drake
     

13 Mar, 2018

1 commit

  • Revert commit 91eea70e5e5c (ACPI: battery: Add the ThinkPad "Not
    Charging" quirk) as it is reported to cause user space to misbehave.

    That appears to be due to bugs in user space, so this commit will go
    in again after the bugs have been fixed and the fixes have been
    delivered to users.

    Link: https://marc.info/?l=linux-acpi&m=152089585129589&w=2
    Reported-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

28 Feb, 2018

2 commits

  • With a degraded battery, full_charge_capacity can be less
    than design_capacity, however it's not sure that capacity_now's
    max will follow.

    Example from an affected machine:
    /sys/class/power_supply/BAT0/charge_full -> 4290000
    /sys/class/power_supply/BAT0/charge_full_design -> 5900000
    /sys/class/power_supply/BAT0/charge_now -> 5900000
    /sys/class/power_supply/BAT0/capacity -> 137

    The battery is a degraded one with a full charge, and
    charge_now is the value of charge_full_design instead of
    charge_full.

    Added a new quirk to test and correct this, and
    a new function to check if the battery is a degraded one
    or not. This keeps the possibility to be over 100 if
    it's really the case.

    Signed-off-by: Laszlo Toth
    Signed-off-by: Rafael J. Wysocki

    Laszlo Toth
     
  • The function __battery_hook_unregister is local to the source and does
    not need to be in global scope, so make it static.

    Cleans up sparse warning:
    drivers/acpi/battery.c:654:6: warning: symbol '__battery_hook_unregister'
    was not declared. Should it be static?

    Signed-off-by: Colin Ian King
    Signed-off-by: Rafael J. Wysocki

    Colin Ian King
     

22 Feb, 2018

2 commits

  • The EC/ACPI firmware on Lenovo ThinkPads used to report a status
    of "Unknown" when the battery is between the charge start and
    charge stop thresholds. On Windows, it reports "Not Charging"
    so the quirk has been added to also report correctly.

    Now the "status" attribute returns "Not Charging" when the
    battery on ThinkPads is not physicaly charging.

    Reviewed-by: Andy Shevchenko
    Signed-off-by: Ognjen Galic
    Signed-off-by: Rafael J. Wysocki

    Ognjen Galic
     
  • This is a patch that implements a generic hooking API for the
    generic ACPI battery driver.

    With this new generic API, drivers can expose platform specific
    behaviour via sysfs attributes in /sys/class/power_supply/BATn/
    in a generic way.

    A perfect example of the need for this API are Lenovo ThinkPads.

    Lenovo ThinkPads have a ACPI extension that allows the setting of
    start and stop charge thresholds in the EC and battery firmware
    via ACPI. The thinkpad_acpi module can use this API to expose
    sysfs attributes that it controls inside the ACPI battery driver
    sysfs tree, under /sys/class/power_supply/BATN/.

    The file drivers/acpi/battery.h has been moved to
    include/acpi/battery.h and the includes inside ac.c, sbs.c, and
    battery.c have been adjusted to reflect that.

    When drivers hooks into the API, the API calls add_battery() for
    each battery in the system that passes it a acpi_battery
    struct. Then, the drivers can use device_create_file() to create
    new sysfs attributes with that struct and identify the batteries
    for per-battery attributes.

    Signed-off-by: Ognjen Galic
    Signed-off-by: Rafael J. Wysocki

    Ognjen Galic
     

04 Feb, 2018

1 commit

  • Same issue as other Asus laptops, ACPI incorrectly reports discharging
    when battery is full and AC is plugged.

    Use the same battery quirk can workaround the issue.

    Link: https://bugs.launchpad.net/bugs/1661876
    Link: https://bugs.launchpad.net/bugs/1745032
    Signed-off-by: Kai-Heng Feng
    Signed-off-by: Rafael J. Wysocki

    Kai Heng Feng
     

18 Dec, 2017

1 commit

  • On Asus GL502VSK and UX305LA, ACPI incorrectly reports discharging when
    battery is full and AC is plugged.

    However rate_now is correct under this circumstance, hence we can use
    "rate_now == 0" as a predicate to report battery full status correctly.

    Link: https://bugs.launchpad.net/bugs/1482390
    Signed-off-by: Kai-Heng Feng
    Signed-off-by: Rafael J. Wysocki

    Kai-Heng Feng
     

13 Dec, 2017

1 commit


24 Aug, 2017

1 commit

  • Make these const as they are only passed as an argument to the function
    device_create_file and device_remove_file and the corresponding
    arguments are of type const.
    Done using Coccinelle

    Signed-off-by: Bhumika Goyal
    Signed-off-by: Rafael J. Wysocki

    Bhumika Goyal
     

15 Jun, 2017

1 commit

  • The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
    during suspend-to-idle transitions and, consequently, any events
    signaled through it wake up the system from that state. However,
    on some systems some of the events signaled via the ACPI SCI while
    suspended to idle should not cause the system to wake up. In fact,
    quite often they should just be discarded.

    Arguably, systems should not resume entirely on such events, but in
    order to decide which events really should cause the system to resume
    and which are spurious, it is necessary to resume up to the point
    when ACPI SCIs are actually handled and processed, which is after
    executing dpm_resume_noirq() in the system resume path.

    For this reasons, add a loop around freeze_enter() in which the
    platforms can process events signaled via multiplexed IRQ lines
    like the ACPI SCI and add suspend-to-idle hooks that can be
    used for this purpose to struct platform_freeze_ops.

    In the ACPI case, the ->wake hook is used for checking if the SCI
    has triggered while suspended and deferring the interrupt-induced
    system wakeup until the events signaled through it are actually
    processed sufficiently to decide whether or not the system should
    resume. In turn, the ->sync hook allows all of the relevant event
    queues to be flushed so as to prevent events from being missed due
    to race conditions.

    In addition to that, some ACPI code processing wakeup events needs
    to be modified to use the "hard" version of wakeup triggers, so that
    it will cause a system resume to happen on device-induced wakeup
    events even if the "soft" mechanism to prevent the system from
    suspending is not enabled. However, to preserve the existing
    behavior with respect to suspend-to-RAM, this only is done in
    the suspend-to-idle case and only if an SCI has occurred while
    suspended.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

09 Jun, 2017

1 commit


07 Jun, 2017

1 commit

  • Revert commit eed4d47efe95 (ACPI / sleep: Ignore spurious SCI wakeups
    from suspend-to-idle) as it turned out to be premature and triggered
    a number of different issues on various systems.

    That includes, but is not limited to, premature suspend-to-RAM aborts
    on Dell XPS 13 (9343) reported by Dominik.

    The issue the commit in question attempted to address is real and
    will need to be taken care of going forward, but evidently more work
    is needed for this purpose.

    Reported-by: Dominik Brodowski
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

10 May, 2017

1 commit

  • * pm-domains:
    PM / Domains: Add DT file to MAINTAINERS
    PM / Domains: Fix DT example

    * pm-cpuidle:
    x86/intel_idle: add Gemini Lake support
    cpuidle: check dev before usage in cpuidle_use_deepest_state()

    * pm-sleep:
    ACPI / sleep: Ignore spurious SCI wakeups from suspend-to-idle
    PM / wakeup: Integrate mechanism to abort transitions in progress

    * powercap:
    powercap: intel_rapl: Add support for Gemini Lake

    Rafael J. Wysocki
     

06 May, 2017

1 commit

  • The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
    during suspend-to-idle transitions and, consequently, any events
    signaled through it wake up the system from that state. However,
    on some systems some of the events signaled via the ACPI SCI while
    suspended to idle should not cause the system to wake up. In fact,
    quite often they should just be discarded.

    Arguably, systems should not resume entirely on such events, but in
    order to decide which events really should cause the system to resume
    and which are spurious, it is necessary to resume up to the point
    when ACPI SCIs are actually handled and processed, which is after
    executing dpm_resume_noirq() in the system resume path.

    For this reasons, add a loop around freeze_enter() in which the
    platforms can process events signaled via multiplexed IRQ lines
    like the ACPI SCI and add suspend-to-idle hooks that can be
    used for this purpose to struct platform_freeze_ops.

    In the ACPI case, the ->wake hook is used for checking if the SCI
    has triggered while suspended and deferring the interrupt-induced
    system wakeup until the events signaled through it are actually
    processed sufficiently to decide whether or not the system should
    resume. In turn, the ->sync hook allows all of the relevant event
    queues to be flushed so as to prevent events from being missed due
    to race conditions.

    In addition to that, some ACPI code processing wakeup events needs
    to be modified to use the "hard" version of wakeup triggers, so that
    it will cause a system resume to happen on device-induced wakeup
    events even if the "soft" mechanism to prevent the system from
    suspending is not enabled (that also helps to catch device-induced
    wakeup events occurring during suspend transitions in progress).

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

20 Apr, 2017

2 commits

  • On some systems we have a native PMIC driver which provides battery
    monitoring, while the ACPI battery driver is broken on these systems
    due to bad DSDTs or because we do not support the proprietary and
    undocumented ACPI opregions these ACPI battery devices rely on
    (e.g. BMOP opregion).

    This leads to there being 2 battery power_supply-s registed like this:

    ~$ acpi
    Battery 0: Charging, 84%, 00:49:39 until charged
    Battery 1: Unknown, 0%, rate information unavailable

    Even if the ACPI battery where to function fine (which on systems
    where we have a native PMIC driver it often doesn't) we still do not
    want to export the same battery to userspace twice.

    This commit adds a blacklist with PMIC ACPI HIDs for which we've a
    native battery driver and makes the ACPI battery driver not register
    itself when a PMIC on this list is present.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=194811
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki

    Hans de Goede
     
  • The acpi_lock_battery_dir() / acpi_bus_register_driver() calls in
    acpi_battery_init_async() may fail.

    Check that they succeeded before undoing them.

    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki

    Hans de Goede
     

25 Dec, 2016

1 commit


17 Nov, 2016

1 commit

  • The Lenovo Yoga 300 laptop's firmware advertises that it provides the _BIX
    the method to retrieve battery information. Unfortunately (some versions
    of?) the implementation return with an error.

    [ 21.712228] ACPI Exception: AE_AML_PACKAGE_LIMIT, Index (0x000000010) is beyond end of object (length 0xD) (20160422/exoparg2-427)
    [ 21.712244] ACPI Error: Method parse/execution failed [\_SB.PCI0.LPCB.H_EC.BAT1._BIX] (Node ffff95f8ff0b20f0), AE_AML_PACKAGE_LIMIT (20160422/psparse-542)

    The _BIF method does succeed and returns convincing data. We detect _BIX
    failing and automatically retry with _BIF.

    Signed-off-by: Dave Lambley
    Signed-off-by: Rafael J. Wysocki

    Dave Lambley
     

31 Aug, 2016

1 commit

  • Thus move sysfs_add_battery() after acpi_battery_get_state(), which doesn't
    require the power_supply. Prevents possible hanged tasks if
    acpi_battery_get_state() fails consistently (and takes a long time in doing
    so) when called inside acpi_battery_add().

    In this situation the battery module first calls sysfs_add_battery(),
    which creates a power_supply, which spawns an async
    power_supply_deferred_register_work() task, which shall try to hold the
    parent battery device mutex (being already held) so this register work
    is set up after device initialization. If initialization takes long enough
    the thread will be eventually run and try to hold the mutex before
    acpi_battery_add() had the chance to finish.

    Eventually the 5 retries in acpi_battery_update_retry() fail, the error
    state is propagated, and results in sysfs_remove_battery() being called
    within the error handling paths of acpi_battery_add(), and the power_supply
    tear down too.

    This triggers a cancel_delayed_work_sync() of the deferred_register_work
    task, which ends up in schedule(). The end result is that the deferred
    task is blocked trying to acquire the parent device mutex, which is not
    released because the thread doing initialization (and failure handling)
    went to sleep awaiting for the deferred task to be cancelled.

    The hanged tasks look like this:

    INFO: task kworker/u8:0:6 blocked for more than 120 seconds.
    ...
    Call Trace:
    [] schedule+0x35/0x80
    [] schedule_timeout+0x1ec/0x250
    [] ? check_preempt_curr+0x52/0x90
    [] ? ttwu_do_wakeup+0x19/0xe0
    [] wait_for_common+0xc5/0x190
    [] ? wake_up_q+0x70/0x70
    [] wait_for_completion+0x1d/0x20
    [] flush_work+0x111/0x1c0
    [] ? flush_workqueue_prep_pwqs+0x1a0/0x1a0
    [] __cancel_work_timer+0x9f/0x1d0
    [] cancel_delayed_work_sync+0x13/0x20
    [] power_supply_unregister+0x37/0xc0
    [] sysfs_remove_battery+0x3d/0x52 [battery]
    [] acpi_battery_add+0x112/0x181 [battery]
    [] acpi_device_probe+0x54/0x19b
    [] driver_probe_device+0x22c/0x440
    [] __driver_attach+0xd1/0xf0
    [] ? driver_probe_device+0x440/0x440
    [] bus_for_each_dev+0x6c/0xc0
    [] driver_attach+0x1e/0x20
    [] bus_add_driver+0x1c3/0x280
    [] driver_register+0x60/0xe0
    [] acpi_bus_register_driver+0x3b/0x43
    [] acpi_battery_init_async+0x1c/0x1e [battery]
    [] async_run_entry_fn+0x48/0x150
    [] process_one_work+0x1e9/0x440
    [] worker_thread+0x4b/0x4f0
    [] ? process_one_work+0x440/0x440
    [] kthread+0xd8/0xf0
    [] ret_from_fork+0x1f/0x40
    [] ? kthread_worker_fn+0x180/0x180

    INFO: task kworker/u8:4:282 blocked for more than 120 seconds.
    ...
    Call Trace:
    [] ? put_prev_entity+0x35/0x8b0
    [] schedule+0x35/0x80
    [] schedule_preempt_disabled+0xe/0x10
    [] __mutex_lock_slowpath+0xb3/0x120
    [] mutex_lock+0x1f/0x30
    [] power_supply_deferred_register_work+0x2b/0x50
    [] process_one_work+0x1e9/0x440
    [] worker_thread+0x4b/0x4f0
    [] ? process_one_work+0x440/0x440
    [] ? process_one_work+0x440/0x440
    [] kthread+0xd8/0xf0
    [] ret_from_fork+0x1f/0x40
    [] ? kthread_worker_fn+0x180/0x180

    Making sysfs_add_battery() the last operation here means that the
    power_supply won't be created yet when the acpi_add_battery() failure
    handling happens, the deferred task won't even spawn, and
    sysfs_remove_battery will just skip over the NULL battery->bat.

    Signed-off-by: Carlos Garnacho
    Signed-off-by: Rafael J. Wysocki

    Carlos Garnacho
     

21 May, 2016

1 commit

  • async_synchronize_cookie() only serialises all tasks up to the specified
    cookie, and importantly does not wait for the task corresponding with
    the cookie. [This is so that it can be trivially used from inside the
    async_func_t in order to serialise with all preceding tasks.] In order
    to serialise with acpi_battery_init_async() we need to compensate and
    pass in the next cookie instead.

    The impact today is zero since performing an async_schedule() from inside
    a module init function will trigger an async_synchronize_full() prior to
    the module loader's completion. However, if the probe was moved to its
    own unregistered async_domain, then the async_synchronize_cookie would
    be replaced with an async_synchronize_full_domain.

    Signed-off-by: Chris Wilson
    Signed-off-by: Rafael J. Wysocki

    Chris Wilson
     

08 Jul, 2015

1 commit