01 Oct, 2020

1 commit

  • [ Upstream commit 3df663a147fe077a6ee8444ec626738946e65547 ]

    There is a race condition in acpi_ec_get_query_handler()
    theoretically allowing query handlers to go away before refernce
    counting them.

    In order to avoid it, call kref_get() on query handlers under
    ec->mutex.

    Also simplify the code a bit while at it.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Rafael J. Wysocki
     

19 Aug, 2020

1 commit

  • [ Upstream commit 6a54ebae6d047c988a31f5ac5a64ab5cf83797a2 ]

    ACPICA commit e17b28cfcc31918d0db9547b6b274b09c413eb70

    Object reference counts are used as a part of ACPICA's garbage
    collection mechanism. This mechanism keeps track of references to
    heap-allocated structures such as the ACPI operand objects.

    Recent server firmware has revealed that this reference count can
    overflow on large servers that declare many field units under the
    same operation_region. This occurs because each field unit declaration
    will add a reference count to the source operation_region.

    This change solves the reference count overflow for operation_regions
    objects by preventing fieldunits from incrementing their
    operation_region's reference count. Each operation_region's reference
    count will not be changed by named objects declared under the Field
    operator. During namespace deletion, the operation_region namespace
    node will be deleted and each fieldunit will be deleted without
    touching the deleted operation_region object.

    Link: https://github.com/acpica/acpica/commit/e17b28cf
    Signed-off-by: Erik Kaneda
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Erik Kaneda
     

22 Jul, 2020

2 commits

  • [ Upstream commit c41c36e900a337b4132b12ccabc97f5578248b44 ]

    Currently, changing the brightness of the internal display of the Acer
    TravelMate 5735Z does not work. Pressing the function keys or changing the
    slider, GNOME Shell 3.36.2 displays the OSD (five steps), but the
    brightness does not change.

    The Acer TravelMate 5735Z shipped with Windows 7 and as such does not
    trigger our "win8 ready" heuristic for preferring the native backlight
    interface.

    Still ACPI backlight control doesn't work on this model, where as the
    native (intel_video) backlight interface does work by adding
    `acpi_backlight=native` or `acpi_backlight=none` to Linux’ command line.

    So, add a quirk to force using native backlight control on this model.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=207835
    Reviewed-by: Hans de Goede
    Signed-off-by: Paul Menzel
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Paul Menzel
     
  • [ Upstream commit 1c8fbc1f9bfb804ef2f0d4ee9397ab800e33f23a ]

    The Acer Aspire 5783z shipped with Windows 7 and as such does not trigger
    our "win8 ready" heuristic for prefering the native backlight interface.

    Still ACPI backlight control doesn't work on this model, where as the
    native (intel_video) backlight interface does work. Add a quirk to
    force using native backlight control on this model.

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

    Hans de Goede
     

01 Jul, 2020

2 commits

  • commit 75b0cea7bf307f362057cc778efe89af4c615354 upstream.

    Like other vectors already patched, this one here allows the root
    user to load ACPI tables, which enables arbitrary physical address
    writes, which in turn makes it possible to disable lockdown.

    Prevents this by checking the lockdown status before allowing a new
    ACPI table to be installed. The link in the trailer shows a PoC of
    how this might be used.

    Link: https://git.zx2c4.com/american-unsigned-language/tree/american-unsigned-language-2.sh
    Cc: 5.4+ # 5.4+
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Jason A. Donenfeld
     
  • commit e6d701dca9893990d999fd145e3e07223c002b06 upstream.

    When running a kernel with Clang's Control Flow Integrity implemented,
    there is a violation that happens when accessing
    /sys/firmware/acpi/pm_profile:

    $ cat /sys/firmware/acpi/pm_profile
    0

    $ dmesg
    ...
    [ 17.352564] ------------[ cut here ]------------
    [ 17.352568] CFI failure (target: acpi_show_profile+0x0/0x8):
    [ 17.352572] WARNING: CPU: 3 PID: 497 at kernel/cfi.c:29 __cfi_check_fail+0x33/0x40
    [ 17.352573] Modules linked in:
    [ 17.352575] CPU: 3 PID: 497 Comm: cat Tainted: G W 5.7.0-microsoft-standard+ #1
    [ 17.352576] RIP: 0010:__cfi_check_fail+0x33/0x40
    [ 17.352577] Code: 48 c7 c7 50 b3 85 84 48 c7 c6 50 0a 4e 84 e8 a4 d8 60 00 85 c0 75 02 5b c3 48 c7 c7 dc 5e 49 84 48 89 de 31 c0 e8 7d 06 eb ff 0b 5b c3 00 00 cc cc 00 00 cc cc 00 85 f6 74 25 41 b9 ea ff ff
    [ 17.352577] RSP: 0018:ffffaa6dc3c53d30 EFLAGS: 00010246
    [ 17.352578] RAX: 331267e0c06cee00 RBX: ffffffff83d85890 RCX: ffffffff8483a6f8
    [ 17.352579] RDX: ffff9cceabbb37c0 RSI: 0000000000000082 RDI: ffffffff84bb9e1c
    [ 17.352579] RBP: ffffffff845b2bc8 R08: 0000000000000001 R09: ffff9cceabbba200
    [ 17.352579] R10: 000000000000019d R11: 0000000000000000 R12: ffff9cc947766f00
    [ 17.352580] R13: ffffffff83d6bd50 R14: ffff9ccc6fa80000 R15: ffffffff845bd328
    [ 17.352582] FS: 00007fdbc8d13580(0000) GS:ffff9cce91ac0000(0000) knlGS:0000000000000000
    [ 17.352582] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 17.352583] CR2: 00007fdbc858e000 CR3: 00000005174d0000 CR4: 0000000000340ea0
    [ 17.352584] Call Trace:
    [ 17.352586] ? rev_id_show+0x8/0x8
    [ 17.352587] ? __cfi_check+0x45bac/0x4b640
    [ 17.352589] ? kobj_attr_show+0x73/0x80
    [ 17.352590] ? sysfs_kf_seq_show+0xc1/0x140
    [ 17.352592] ? ext4_seq_options_show.cfi_jt+0x8/0x8
    [ 17.352593] ? seq_read+0x180/0x600
    [ 17.352595] ? sysfs_create_file_ns.cfi_jt+0x10/0x10
    [ 17.352596] ? tlbflush_read_file+0x8/0x8
    [ 17.352597] ? __vfs_read+0x6b/0x220
    [ 17.352598] ? handle_mm_fault+0xa23/0x11b0
    [ 17.352599] ? vfs_read+0xa2/0x130
    [ 17.352599] ? ksys_read+0x6a/0xd0
    [ 17.352601] ? __do_sys_getpgrp+0x8/0x8
    [ 17.352602] ? do_syscall_64+0x72/0x120
    [ 17.352603] ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [ 17.352604] ---[ end trace 7b1fa81dc897e419 ]---

    When /sys/firmware/acpi/pm_profile is read, sysfs_kf_seq_show is called,
    which in turn calls kobj_attr_show, which gets the ->show callback
    member by calling container_of on attr (casting it to struct
    kobj_attribute) then calls it.

    There is a CFI violation because pm_profile_attr is of type
    struct device_attribute but kobj_attr_show calls ->show expecting it
    to be from struct kobj_attribute. CFI checking ensures that function
    pointer types match when doing indirect calls. Fix pm_profile_attr to
    be defined in terms of kobj_attribute so there is no violation or
    mismatch.

    Fixes: 362b646062b2 ("ACPI: Export FADT pm_profile integer value to userspace")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1051
    Reported-by: yuu ichii
    Signed-off-by: Nathan Chancellor
    Cc: 3.10+ # 3.10+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Nathan Chancellor
     

22 Jun, 2020

3 commits

  • [ Upstream commit 50c8ab8d9fbf5b18d5162a797ca26568afc0af1a ]

    An IORT PMCG node can have no ID mapping if its overflow interrupt is
    wire based therefore the code that parses the PMCG node can not assume
    the node will always have a single mapping present at index 0.

    Fix iort_get_id_mapping_index() by checking for an overflow interrupt
    and mapping count.

    Fixes: 24e516049360 ("ACPI/IORT: Add support for PMCG")

    Signed-off-by: Tuan Phan
    Reviewed-by: Hanjun Guo
    Acked-by: Lorenzo Pieralisi
    Link: https://lore.kernel.org/r/1589994787-28637-1-git-send-email-tuanphan@os.amperecomputing.com
    Signed-off-by: Will Deacon
    Signed-off-by: Sasha Levin

    Tuan Phan
     
  • [ Upstream commit 6bfe5344b2956d0bee116f1c640aef05e5cddd76 ]

    ACPICA commit 3244c1eeba9f9fb9ccedb875f7923a3d85e0c6aa

    The status chekcs are used to to avoid NULL pointer dereference on
    field objects

    Link: https://github.com/acpica/acpica/commit/3244c1ee
    Reported-by: Kurt Kennett
    Signed-off-by: Erik Kaneda
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Erik Kaneda
     
  • commit e5c399b0bd6490c12c0af2a9eaa9d7cd805d52c9 upstream.

    Commit ea6f3af4c5e63f69 ("ACPI: GED: add support for _Exx / _Lxx handler
    methods") added a reference to the 'triggering' field of either the
    normal or the extended ACPI IRQ resource struct, but inadvertently used
    the wrong pointer in the latter case. Note that both pointers refer to the
    same union, and the 'triggering' field appears at the same offset in both
    struct types, so it currently happens to work by accident. But let's fix
    it nonetheless

    Fixes: ea6f3af4c5e63f69 ("ACPI: GED: add support for _Exx / _Lxx handler methods")
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     

17 Jun, 2020

4 commits

  • commit 956ad9d98b73f59e442cc119c98ba1e04e94fe6d upstream.

    As recently reported, some platforms provide a list of power
    resources for device power state D3hot, through the _PR3 object,
    but they do not provide a list of power resources for device power
    state D0.

    Among other things, this causes acpi_device_get_power() to return
    D3hot as the current state of the device in question if all of the
    D3hot power resources are "on", because it sees the power_resources
    flag set and calls acpi_power_get_inferred_state() which finds that
    D3hot is the shallowest power state with all of the associated power
    resources turned "on", so that's what it returns. Moreover, that
    value takes precedence over the acpi_dev_pm_explicit_get() return
    value, because it means a deeper power state. The device may very
    well be in D0 physically at that point, however.

    Moreover, the presence of _PR3 without _PR0 for a given device
    means that only one D3-level power state can be supported by it.
    Namely, because there are no power resources to turn "off" when
    transitioning the device from D0 into D3cold (which should be
    supported since _PR3 is present), the evaluation of _PS3 should
    be sufficient to put it straight into D3cold, but this means that
    the effect of turning "on" the _PR3 power resources is unclear,
    so it is better to avoid doing that altogether. Consequently,
    there is no practical way do distinguish D3cold from D3hot for
    the device in question and the power states of it can be labeled
    so that D3hot is the deepest supported one (and Linux assumes
    that putting a device into D3hot via ACPI may cause power to be
    removed from it anyway, for legacy reasons).

    To work around the problem described above modify the ACPI
    enumeration of devices so that power resources are only used
    for device power management if the list of D0 power resources
    is not empty and make it mart D3cold as supported only if that
    is the case and the D3hot list of power resources is not empty
    too.

    Fixes: ef85bdbec444 ("ACPI / scan: Consolidate extraction of power resources lists")
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=205057
    Link: https://lore.kernel.org/linux-acpi/20200603194659.185757-1-hdegoede@redhat.com/
    Reported-by: Hans de Goede
    Tested-by: Hans de Goede
    Tested-by: youling257@gmail.com
    Cc: 3.10+ # 3.10+
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Hans de Goede
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • commit ea6f3af4c5e63f6981c0b0ab8ebec438e2d5ef40 upstream.

    Per the ACPI spec, interrupts in the range [0, 255] may be handled
    in AML using individual methods whose naming is based on the format
    _Exx or _Lxx, where xx is the hex representation of the interrupt
    index.

    Add support for this missing feature to our ACPI GED driver.

    Cc: v4.9+ # v4.9+
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit 4d8be4bc94f74bb7d096e1c2e44457b530d5a170 upstream.

    kobject_init_and_add() takes reference even when it fails.
    If this function returns an error, kobject_put() must be called to
    properly clean up the memory associated with the object. Previous
    commit "b8eb718348b8" fixed a similar problem.

    Fixes: 158c998ea44b ("ACPI / CPPC: add sysfs support to compute delivered performance")
    Signed-off-by: Qiushi Wu
    Cc: 4.10+ # 4.10+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Qiushi Wu
     
  • commit 6e6c25283dff866308c87b49434c7dbad4774cc0 upstream.

    kobject_init_and_add() takes reference even when it fails.
    Thus, when kobject_init_and_add() returns an error,
    kobject_put() must be called to properly clean up the kobject.

    Fixes: 3f8055c35836 ("ACPI / hotplug: Introduce user space interface for hotplug profiles")
    Signed-off-by: Qiushi Wu
    Cc: 3.10+ # 3.10+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Qiushi Wu
     

27 May, 2020

1 commit

  • [ Upstream commit 607b9df63057a56f6172d560d5366cca6a030c76 ]

    Flushing the EC work while suspended to idle when the EC GPE status
    is not set causes some EC wakeup events (notably power button and
    lid ones) to be missed after a series of spurious wakeups on the Dell
    XPS13 9360 in my office.

    If that happens, the machine cannot be woken up from suspend-to-idle
    by the power button or lid status change and it needs to be woken up
    in some other way (eg. by a key press).

    Flushing the EC work only after successful dispatching the EC GPE,
    which means that its status has been set, avoids the issue, so change
    the code in question accordingly.

    Fixes: 7b301750f7f8 ("ACPI: EC: PM: Avoid premature returns from acpi_s2idle_wake()")
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Tested-by: Chris Chiu
    Signed-off-by: Sasha Levin

    Rafael J. Wysocki
     

20 May, 2020

1 commit

  • [ Upstream commit 7b301750f7f8f6503e11f1af4a03832525f58c66 ]

    If the EC GPE status is not set after checking all of the other GPEs,
    acpi_s2idle_wake() returns 'false', to indicate that the SCI event
    that has just triggered is not a system wakeup one, but it does that
    without canceling the pending wakeup and re-arming the SCI for system
    wakeup which is a mistake, because it may cause s2idle_loop() to busy
    spin until the next valid wakeup event. [If that happens, the first
    spurious wakeup is still pending after acpi_s2idle_wake() has
    returned, so s2idle_enter() does nothing, acpi_s2idle_wake()
    is called again and it sees that the SCI has triggered, but no GPEs
    are active, so 'false' is returned again, and so on.]

    Fix that by moving all of the GPE checking logic from
    acpi_s2idle_wake() to acpi_ec_dispatch_gpe() and making the
    latter return 'true' only if a non-EC GPE has triggered and
    'false' otherwise, which will cause acpi_s2idle_wake() to
    cancel the pending SCI wakeup and re-arm the SCI for system
    wakeup regardless of the EC GPE status.

    This also addresses a lockup observed on an Elitegroup EF20EA laptop
    after attempting to wake it up from suspend-to-idle by a key press.

    Fixes: d5406284ff80 ("ACPI: PM: s2idle: Refine active GPEs check")
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=207603
    Reported-by: Todd Brandt
    Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system")
    Link: https://lore.kernel.org/linux-acpi/CAB4CAwdqo7=MvyG_PE+PGVfeA17AHF5i5JucgaKqqMX6mjArbQ@mail.gmail.com/
    Reported-by: Chris Chiu
    Tested-by: Chris Chiu
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Rafael J. Wysocki
     

10 May, 2020

1 commit


06 May, 2020

1 commit

  • commit a9b760b0266f563b4784f695bbd0e717610dc10a upstream.

    Transitioned power state logged at the end of setting ACPI power.

    However, D3cold won't be in the message because state can only be
    D3hot at most.

    Use target_state to corretly report when power state is D3cold.

    Cc: All applicable
    Signed-off-by: Kai-Heng Feng
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Kai-Heng Feng
     

23 Apr, 2020

2 commits

  • [ Upstream commit 9a1ae80412dcaa67a29eecf19de44f32b5f1c357 ]

    This is the result of squashing the following ACPICA commit ID's:
    6803997e5b4f3635cea6610b51ff69e29d251de3
    f31cdf8bfda22fe265c1a176d0e33d311c82a7f7

    This change fixes several problems with the support for the
    acpi_exec namespace init file (-fi option). Specifically, it
    fixes AE_ALREADY_EXISTS errors, as well as various seg faults.

    Link: https://github.com/acpica/acpica/commit/f31cdf8b
    Link: https://github.com/acpica/acpica/commit/6803997e
    Signed-off-by: Bob Moore
    Signed-off-by: Erik Kaneda
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Bob Moore
     
  • [ Upstream commit 696ac2e3bf267f5a2b2ed7d34e64131f2287d0ad ]

    Similar to commit 0266d81e9bf5 ("acpi/processor: Prevent cpu hotplug
    deadlock") except this is for acpi_processor_ffh_cstate_probe():

    "The problem is that the work is scheduled on the current CPU from the
    hotplug thread associated with that CPU.

    It's not required to invoke these functions via the workqueue because
    the hotplug thread runs on the target CPU already.

    Check whether current is a per cpu thread pinned on the target CPU and
    invoke the function directly to avoid the workqueue."

    WARNING: possible circular locking dependency detected
    ------------------------------------------------------
    cpuhp/1/15 is trying to acquire lock:
    ffffc90003447a28 ((work_completion)(&wfc.work)){+.+.}-{0:0}, at: __flush_work+0x4c6/0x630

    but task is already holding lock:
    ffffffffafa1c0e8 (cpuidle_lock){+.+.}-{3:3}, at: cpuidle_pause_and_lock+0x17/0x20

    which lock already depends on the new lock.

    the existing dependency chain (in reverse order) is:

    -> #1 (cpu_hotplug_lock){++++}-{0:0}:
    cpus_read_lock+0x3e/0xc0
    irq_calc_affinity_vectors+0x5f/0x91
    __pci_enable_msix_range+0x10f/0x9a0
    pci_alloc_irq_vectors_affinity+0x13e/0x1f0
    pci_alloc_irq_vectors_affinity at drivers/pci/msi.c:1208
    pqi_ctrl_init+0x72f/0x1618 [smartpqi]
    pqi_pci_probe.cold.63+0x882/0x892 [smartpqi]
    local_pci_probe+0x7a/0xc0
    work_for_cpu_fn+0x2e/0x50
    process_one_work+0x57e/0xb90
    worker_thread+0x363/0x5b0
    kthread+0x1f4/0x220
    ret_from_fork+0x27/0x50

    -> #0 ((work_completion)(&wfc.work)){+.+.}-{0:0}:
    __lock_acquire+0x2244/0x32a0
    lock_acquire+0x1a2/0x680
    __flush_work+0x4e6/0x630
    work_on_cpu+0x114/0x160
    acpi_processor_ffh_cstate_probe+0x129/0x250
    acpi_processor_evaluate_cst+0x4c8/0x580
    acpi_processor_get_power_info+0x86/0x740
    acpi_processor_hotplug+0xc3/0x140
    acpi_soft_cpu_online+0x102/0x1d0
    cpuhp_invoke_callback+0x197/0x1120
    cpuhp_thread_fun+0x252/0x2f0
    smpboot_thread_fn+0x255/0x440
    kthread+0x1f4/0x220
    ret_from_fork+0x27/0x50

    other info that might help us debug this:

    Chain exists of:
    (work_completion)(&wfc.work) --> cpuhp_state-up --> cpuidle_lock

    Possible unsafe locking scenario:

    CPU0 CPU1
    ---- ----
    lock(cpuidle_lock);
    lock(cpuhp_state-up);
    lock(cpuidle_lock);
    lock((work_completion)(&wfc.work));

    *** DEADLOCK ***

    3 locks held by cpuhp/1/15:
    #0: ffffffffaf51ab10 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x69/0x2f0
    #1: ffffffffaf51ad40 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x69/0x2f0
    #2: ffffffffafa1c0e8 (cpuidle_lock){+.+.}-{3:3}, at: cpuidle_pause_and_lock+0x17/0x20

    Call Trace:
    dump_stack+0xa0/0xea
    print_circular_bug.cold.52+0x147/0x14c
    check_noncircular+0x295/0x2d0
    __lock_acquire+0x2244/0x32a0
    lock_acquire+0x1a2/0x680
    __flush_work+0x4e6/0x630
    work_on_cpu+0x114/0x160
    acpi_processor_ffh_cstate_probe+0x129/0x250
    acpi_processor_evaluate_cst+0x4c8/0x580
    acpi_processor_get_power_info+0x86/0x740
    acpi_processor_hotplug+0xc3/0x140
    acpi_soft_cpu_online+0x102/0x1d0
    cpuhp_invoke_callback+0x197/0x1120
    cpuhp_thread_fun+0x252/0x2f0
    smpboot_thread_fn+0x255/0x440
    kthread+0x1f4/0x220
    ret_from_fork+0x27/0x50

    Signed-off-by: Qian Cai
    Tested-by: Borislav Petkov
    [ rjw: Subject ]
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Qian Cai
     

21 Apr, 2020

2 commits

  • commit 01091c496f920e634ea84b689f480c39016752a8 upstream.

    The 'func' variable can come from the user in the __nd_ioctl(). If it's
    too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
    undefined. In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
    which could result in an out of bounds access.

    To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
    updated nfit_dsm_revid() to use that define as well instead of magic
    numbers.

    Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Dan Williams
    Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
    Signed-off-by: Dan Williams
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • This reverts commit ce7a61a0d57d2dd613941d8aef82a5b54fb2e396 which is
    commit 65a691f5f8f0bb63d6a82eec7b0ffd193d8d8a5f upstream.

    Rafael writes:
    It has not been marked for -stable or otherwise requested to be
    included AFAICS. Also it depends on other mainline commits that
    have not been included into 5.6.5.

    Reported-by: Toralf Förster
    Reported-by: Rafael J. Wysocki
    Cc: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

17 Apr, 2020

3 commits

  • commit d5406284ff803a578ca503373624312770319054 upstream.

    The check for any active GPEs added by commit fdde0ff8590b ("ACPI:
    PM: s2idle: Prevent spurious SCIs from waking up the system") turns
    out to be insufficiently precise to prevent some systems from
    resuming prematurely due to a spurious EC wakeup, so refine it
    by first checking if any GPEs other than the EC GPE are active
    and skipping all of the SCIs coming from the EC that do not produce
    any genuine wakeup events after processing.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206629
    Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system")
    Reported-by: Ondřej Caletka
    Tested-by: Ondřej Caletka
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • commit 0ce792d660bda990c675eaf14ce09594a9b85cbf upstream.

    The check carried out by acpi_any_gpe_status_set() is not precise enough
    for the suspend-to-idle implementation in Linux and in some cases it is
    necessary make it skip one GPE (specifically, the EC GPE) from the check
    to prevent a race condition leading to a premature system resume from
    occurring.

    For this reason, redefine acpi_any_gpe_status_set() to take the number
    of a GPE to skip as an argument.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206629
    Tested-by: Ondřej Caletka
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • [ Upstream commit 65a691f5f8f0bb63d6a82eec7b0ffd193d8d8a5f ]

    The reason for clearing boot_ec_is_ecdt in acpi_ec_add() (if a
    PNP0C09 device object matching the ECDT boot EC had been found in
    the namespace) was to cause acpi_ec_ecdt_start() to return early,
    but since the latter does not look at boot_ec_is_ecdt any more,
    acpi_ec_add() need not clear it.

    Moreover, doing that may be confusing as it may cause "DSDT" to be
    printed instead of "ECDT" in the EC initialization completion
    message, so stop doing it.

    While at it, split the EC initialization completion message into
    two messages, one regarding the boot EC and another one printed
    regardless of whether or not the EC at hand is the boot one.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Rafael J. Wysocki
     

13 Apr, 2020

1 commit

  • commit ddfd9dcf270ce23ed1985b66fcfa163920e2e1b8 upstream.

    Since commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from
    waking up the system") the SCI triggering without there being a wakeup
    cause recognized by the ACPI sleep code will no longer wakeup the system.

    This works as intended, but this is a problem for devices where the SCI
    is shared with another device which is also a wakeup source.

    In the past these, from the pov of the ACPI sleep code, spurious SCIs
    would still cause a wakeup so the wakeup from the device sharing the
    interrupt would actually wakeup the system. This now no longer works.

    This is a problem on e.g. Bay Trail-T and Cherry Trail devices where
    some peripherals (typically the XHCI controller) can signal a
    Power Management Event (PME) to the Power Management Controller (PMC)
    to wakeup the system, this uses the same interrupt as the SCI.
    These wakeups are handled through a special INT0002 ACPI device which
    checks for events in the GPE0a_STS for this and takes care of acking
    the PME so that the shared interrupt stops triggering.

    The change to the ACPI sleep code to ignore the spurious SCI, causes
    the system to no longer wakeup on these PME events. To make things
    worse this means that the INT0002 device driver interrupt handler will
    no longer run, causing the PME to not get cleared and resulting in the
    system hanging. Trying to wakeup the system after such a PME through e.g.
    the power button no longer works.

    Add an acpi_register_wakeup_handler() function which registers
    a handler to be called from acpi_s2idle_wake() and when the handler
    returns true, return true from acpi_s2idle_wake().

    The INT0002 driver will use this mechanism to check the GPE0a_STS
    register from acpi_s2idle_wake() and to tell the system to wakeup
    if a PME is signaled in the register.

    Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system")
    Cc: 5.4+ # 5.4+
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     

01 Apr, 2020

1 commit

  • commit 024aa8732acb7d2503eae43c3fe3504d0a8646d0 upstream.

    Note that the EC GPE processing need not be synchronized in
    acpi_s2idle_wake() after invoking acpi_ec_dispatch_gpe(), because
    that function checks the GPE status and dispatches its handler if
    need be and the SCI action handler is not going to run anyway at
    that point.

    Moreover, it is better to drain all of the pending ACPI events
    before restoring the working-state configuration of GPEs in
    acpi_s2idle_restore(), because those events are likely to be related
    to system wakeup, in which case they will not be relevant going
    forward.

    Rework the code to take these observations into account.

    Tested-by: Kenneth R. Crudup
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

25 Mar, 2020

1 commit

  • commit 763802b53a427ed3cbd419dbba255c414fdd9e7c upstream.

    Commit 3f8fd02b1bf1 ("mm/vmalloc: Sync unmappings in
    __purge_vmap_area_lazy()") introduced a call to vmalloc_sync_all() in
    the vunmap() code-path. While this change was necessary to maintain
    correctness on x86-32-pae kernels, it also adds additional cycles for
    architectures that don't need it.

    Specifically on x86-64 with CONFIG_VMAP_STACK=y some people reported
    severe performance regressions in micro-benchmarks because it now also
    calls the x86-64 implementation of vmalloc_sync_all() on vunmap(). But
    the vmalloc_sync_all() implementation on x86-64 is only needed for newly
    created mappings.

    To avoid the unnecessary work on x86-64 and to gain the performance
    back, split up vmalloc_sync_all() into two functions:

    * vmalloc_sync_mappings(), and
    * vmalloc_sync_unmappings()

    Most call-sites to vmalloc_sync_all() only care about new mappings being
    synchronized. The only exception is the new call-site added in the
    above mentioned commit.

    Shile Zhang directed us to a report of an 80% regression in reaim
    throughput.

    Fixes: 3f8fd02b1bf1 ("mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy()")
    Reported-by: kernel test robot
    Reported-by: Shile Zhang
    Signed-off-by: Joerg Roedel
    Signed-off-by: Andrew Morton
    Tested-by: Borislav Petkov
    Acked-by: Rafael J. Wysocki [GHES]
    Cc: Dave Hansen
    Cc: Andy Lutomirski
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc:
    Link: http://lkml.kernel.org/r/20191009124418.8286-1-joro@8bytes.org
    Link: https://lists.01.org/hyperkitty/list/lkp@lists.01.org/thread/4D3JPPHBNOSPFK2KEPC6KGKS6J25AIDB/
    Link: http://lkml.kernel.org/r/20191113095530.228959-1-shile.zhang@linux.alibaba.com
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Joerg Roedel
     

21 Mar, 2020

1 commit

  • [ Upstream commit 3f9e12e0df012c4a9a7fd7eb0d3ae69b459d6b2c ]

    In case the WDAT interface is broken, give the user an option to
    ignore it to let a native driver bind to the watchdog device instead.

    Signed-off-by: Jean Delvare
    Acked-by: Mika Westerberg
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Jean Delvare
     

05 Mar, 2020

1 commit

  • commit 2ba33a4e9e22ac4dda928d3e9b5978a3a2ded4e0 upstream.

    ACPI Generic Address Structure (GAS) access_width field is not in bytes
    as the driver seems to expect in few places so fix this by using the
    newly introduced macro ACPI_ACCESS_BYTE_WIDTH().

    Fixes: b1abf6fc4982 ("ACPI / watchdog: Fix off-by-one error at resource assignment")
    Fixes: 058dfc767008 ("ACPI / watchdog: Add support for WDAT hardware watchdog")
    Reported-by: Jean Delvare
    Signed-off-by: Mika Westerberg
    Reviewed-by: Jean Delvare
    Cc: 4.16+ # 4.16+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Mika Westerberg
     

29 Feb, 2020

1 commit

  • commit 63fb9623427fbb44e3782233b6e4714057b76ff2 upstream.

    Commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from
    waking up the system") overlooked the fact that fixed events can wake
    up the system too and broke RTC wakeup from suspend-to-idle as a
    result.

    Fix this issue by checking the fixed events in acpi_s2idle_wake() in
    addition to checking wakeup GPEs and break out of the suspend-to-idle
    loop if the status bits of any enabled fixed events are set then.

    Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system")
    Reported-and-tested-by: Chris Wilson
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

24 Feb, 2020

2 commits

  • [ Upstream commit 0528904926aab19bffb2068879aa44db166c6d5f ]

    Running evemu-record on the lid switch event shows that the lid reports
    the first "close" but then never reports an "open". This causes systemd
    to continuously re-suspend the laptop every 30s. Resetting the _LID to
    "open" fixes the issue.

    Signed-off-by: Jason Ekstrand
    Reviewed-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Jason Ekstrand
     
  • [ Upstream commit 5ddbd77181dfca61b16d2e2222382ea65637f1b9 ]

    ACPICA commit 29cc8dbc5463a93625bed87d7550a8bed8913bf4

    create_buffer_field is a deferred op that is typically processed in
    load pass 2. However, disassembly of control method contents walk the
    parse tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are
    processed in a later walk. This is a problem when there is a control
    method that has the same name as the AML_CREATE object. In this case,
    any use of the name segment will be detected as a method call rather
    than a reference to a buffer field. If this is detected as a method
    call, it can result in a mal-formed parse tree if the control methods
    have parameters.

    This change in processing AML_CREATE ops earlier solves this issue by
    inserting the named object in the ACPI namespace so that references
    to this name would be detected as a name string rather than a method
    call.

    Link: https://github.com/acpica/acpica/commit/29cc8dbc
    Reported-by: Elia Geretto
    Tested-by: Elia Geretto
    Signed-off-by: Bob Moore
    Signed-off-by: Erik Kaneda
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Erik Kaneda
     

20 Feb, 2020

4 commits

  • commit fdde0ff8590b4c1c41b3227f5ac4265fccccb96b upstream.

    If the platform triggers a spurious SCI even though the status bit
    is not set for any GPE when the system is suspended to idle, it will
    be treated as a genuine wakeup, so avoid that by checking if any GPEs
    are active at all before returning 'true' from acpi_s2idle_wake().

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206413
    Fixes: 56b991849009 ("PM: sleep: Simplify suspend-to-idle control flow")
    Reported-by: Tsuchiya Yuto
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • commit ea128834dd76f9a72a35d011c651fa96658f06a7 upstream.

    Introduce a new helper function, acpi_any_gpe_status_set(), for
    checking the status bits of all enabled GPEs in one go.

    It is needed to distinguish spurious SCIs from genuine ones when
    deciding whether or not to wake up the system from suspend-to-idle.

    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • commit e3728b50cd9be7d4b1469447cdf1feb93e3b7adb upstream.

    It is theoretically possible for the ACPI EC GPE to be set after the
    s2idle_ops->wake() called from s2idle_loop() has returned and before
    the subsequent pm_wakeup_pending() check is carried out. If that
    happens, the resulting wakeup event will cause the system to resume
    even though it may be a spurious one.

    To avoid that race, first make the ->wake() callback in struct
    platform_s2idle_ops return a bool value indicating whether or not
    to let the system resume and rearrange s2idle_loop() to use that
    value instad of the direct pm_wakeup_pending() call if ->wake() is
    present.

    Next, rework acpi_s2idle_wake() to process EC events and check
    pm_wakeup_pending() before re-arming the SCI for system wakeup
    to prevent it from triggering prematurely and add comments to
    that function to explain the rationale for the new code flow.

    Fixes: 56b991849009 ("PM: sleep: Simplify suspend-to-idle control flow")
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • commit f0ac20c3f6137910c8a927953e8a92f5b3716166 upstream.

    Commit 016b87ca5c8c ("ACPI: EC: Rework flushing of pending work")
    introduced a subtle bug into the flushing of pending EC work while
    suspended to idle, which may cause the EC driver to fail to
    re-enable the EC GPE after handling a non-wakeup event (like a
    battery status change event, for example).

    The problem is that the work item flushed by flush_scheduled_work()
    in __acpi_ec_flush_work() may disable the EC GPE and schedule another
    work item expected to re-enable it, but that new work item is not
    flushed, so __acpi_ec_flush_work() returns with the EC GPE disabled
    and the CPU running it goes into an idle state subsequently. If all
    of the other CPUs are in idle states at that point, the EC GPE won't
    be re-enabled until at least one CPU is woken up by another interrupt
    source, so system wakeup events that would normally come from the EC
    then don't work.

    This is reproducible on a Dell XPS13 9360 in my office which
    sometimes stops reacting to power button and lid events (triggered
    by the EC on that machine) after switching from AC power to battery
    power or vice versa while suspended to idle (each of those switches
    causes the EC GPE to trigger for several times in a row, but they
    are not system wakeup events).

    To avoid this problem, it is necessary to drain the workqueue
    entirely in __acpi_ec_flush_work(), but that cannot be done with
    respect to system_wq, because work items may be added to it from
    other places while __acpi_ec_flush_work() is running. For this
    reason, make the EC driver use a dedicated workqueue for EC events
    processing (let that workqueue be ordered so that EC events are
    processed sequentially) and use drain_workqueue() on it in
    __acpi_ec_flush_work().

    Fixes: 016b87ca5c8c ("ACPI: EC: Rework flushing of pending work")
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

11 Feb, 2020

4 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
     
  • commit d21a91629f4b8e794fc4c0e0c17c85cedf1d806c upstream.

    Despite our heuristics to not wrongly export a non working ACPI backlight
    interface on desktop machines, we still end up exporting one on desktops
    using a motherboard from the MSI MS-7721 series.

    I've looked at improving the heuristics, but in this case a quirk seems
    to be the only way to solve this.

    While at it also add a comment to separate the video_detect_force_none
    entries in the video_detect_dmi_table from other type of entries, as we
    already do for the other entry types.

    Cc: All applicable
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1783786
    Signed-off-by: Hans de Goede
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede