06 Oct, 2014

1 commit

  • commit 8ab17fc92e49bc2b8fff9d220c19bf50ec9c1158 upstream.

    Commit 46394fd01 (ACPI / hotplug: Move container-specific code out of
    the core) removed the generation of "online" uevents for containers,
    because "add" uevents are now generated for them automatically when
    container system devices are registered. However, there are user
    space tools that need to be notified when the container and all of
    its children have been enumerated, which doesn't happen any more.

    For this reason, add a mechanism allowing "online" uevents to be
    generated for ACPI containers after enumerating the container along
    with all of its children.

    Fixes: 46394fd01 (ACPI / hotplug: Move container-specific code out of the core)
    Reported-and-tested-by: Yasuaki Ishimatsu
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

18 Sep, 2014

1 commit

  • commit a383b68d9fe9864c4d3b86f67ad6488f58136435 upstream.

    The _SUN device indentification object is not guaranteed to return
    the same value every time it is executed, so we should not cache its
    return value, but rather execute it every time as needed. If it is
    cached, an incorrect stale value may be used in some situations.

    This issue was exposed by commit 202317a573b2 (ACPI / scan: Add
    acpi_device objects for all device nodes in the namespace). Fix it
    by avoiding to cache the return value of _SUN.

    Fixes: 202317a573b2 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace)
    Signed-off-by: Yasuaki Ishimatsu
    [ rjw: Changelog ]
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Yasuaki Ishimatsu
     

29 Jan, 2014

1 commit

  • * acpi-processor:
    ACPI / scan: reduce log level of "ACPI: \_PR_.CPU4: failed to get CPU APIC ID"
    ACPI / processor: Return specific error value when mapping lapic id

    * acpi-hotplug:
    ACPI / scan: Clear match_driver flag in acpi_bus_trim()

    * acpi-init:
    ACPI / init: Flag use of ACPI and ACPI idioms for power supplies to regulator API

    * acpi-pm:
    ACPI / PM: Use ACPI_COMPANION() to get ACPI companions of devices

    * acpica:
    ACPICA: Remove bool usage from ACPICA.

    Rafael J. Wysocki
     

28 Jan, 2014

1 commit

  • The use of "bool" is not safe for ACPICA code where it is originally using
    a "BOOLEAN" defined as "unsigned char".

    This patch removes the only "bool" usage from kernel source tree to reduce
    the source code differences between Linux and ACPICA upstream.

    This patch is required by future acpidump release automation.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

13 Jan, 2014

4 commits

  • * acpi-dsm:
    ACPI / extlog: replace open-coded _DSM code with helper functions
    ACPI / nouveau: replace open-coded _DSM code with helper functions
    nouveau / ACPI: fix memory leak in ACPI _DSM related code
    ACPI / i915: replace open-coded _DSM code with helper functions
    ACPI / i2c-hid: replace open-coded _DSM code with helper functions
    ACPI / TPM: detect PPI features by checking availability of _DSM functions
    ACPI / TPM: replace open-coded _DSM code with helper functions
    ACPI / TPM: match node name instead of full path when searching for TPM device
    PCI / pci-label: treat PCI label with index 0 as valid label
    ACPI / PCI: replace open-coded _DSM code with helper functions
    PCI / pci-label: release allocated ACPI object on error recovery path
    ACPI: introduce helper interfaces for _DSM method

    Rafael J. Wysocki
     
  • * acpica: (21 commits)
    ACPICA: Update version to 20131218.
    ACPICA: Utilities: Cleanup declarations of the acpi_gbl_debug_file global.
    ACPICA: Linuxize: Cleanup spaces after special macro invocations.
    ACPICA: Interpreter: Add additional debug info for an error case.
    ACPICA: Update ACPI example code to make it an actual working program.
    ACPICA: Add an error message if the Debugger fails initialization.
    ACPICA: Conditionally define a local variable that is used for debug only.
    ACPICA: Parser: Updates/fixes for debug output.
    ACPICA: Enhance ACPI warning for memory/IO address conflicts.
    ACPICA: Update several debug statements - no functional change.
    ACPICA: Improve exception handling for GPE block installation.
    ACPICA: Add helper macros to extract bus/segment numbers from HEST table.
    ACPICA: Tables: Add full support for the PCCT table, update table definition.
    ACPICA: Tables: Add full support for the DBG2 table.
    ACPICA: Add option to favor 32-bit FADT addresses.
    ACPICA: Cleanup the option of forcing the use of the RSDT.
    ACPICA: Back port and refine validation of the XSDT root table.
    ACPICA: Linux Header: Remove unused OSL prototypes.
    ACPICA: Remove unused ACPI_FREE_BUFFER macro. No functional change.
    ACPICA: Disassembler: Improve pathname support for emitted External() statements.
    ...

    Rafael J. Wysocki
     
  • * acpi-hotplug:
    ACPI / scan: ACPI device object sysfs attribute for _STA evaluation
    ACPI / hotplug / driver core: Handle containers in a special way
    ACPI / hotplug: Add demand_offline hotplug profile flag
    ACPI / bind: Move acpi_get_child() to drivers/ide/ide-acpi.c
    ACPI / bind: Pass struct acpi_device pointer to acpi_bind_one()
    ACPI / bind: Rework struct acpi_bus_type
    ACPI / bind: Redefine acpi_preset_companion()
    ACPI / bind: Redefine acpi_get_child()
    PCI / ACPI: Use acpi_find_child_device() for child devices lookup
    ACPI / bind: Simplify child device lookups
    ACPI / scan: Use direct recurrence for device hierarchy walks
    ACPI: Introduce acpi_set_device_status()
    ACPI / hotplug: Drop unfinished global notification handling routines
    ACPI / hotplug: Rework generic code to handle suprise removals
    ACPI / hotplug: Move container-specific code out of the core
    ACPI / hotplug: Make ACPI PCI root hotplug use common hotplug code
    ACPI / hotplug: Introduce common hotplug function acpi_device_hotplug()
    ACPI / hotplug: Do not fail bus and device checks for disabled hotplug
    ACPI / scan: Add acpi_device objects for all device nodes in the namespace
    ACPI / scan: Define non-empty device removal handler

    Rafael J. Wysocki
     
  • * acpi-cleanup: (22 commits)
    ACPI / tables: Return proper error codes from acpi_table_parse() and fix comment.
    ACPI / tables: Check if id is NULL in acpi_table_parse()
    ACPI / proc: Include appropriate header file in proc.c
    ACPI / EC: Remove unused functions and add prototype declaration in internal.h
    ACPI / dock: Include appropriate header file in dock.c
    ACPI / PCI: Include appropriate header file in pci_link.c
    ACPI / PCI: Include appropriate header file in pci_slot.c
    ACPI / EC: Mark the function acpi_ec_add_debugfs() as static in ec_sys.c
    ACPI / NVS: Include appropriate header file in nvs.c
    ACPI / OSL: Mark the function acpi_table_checksum() as static
    ACPI / processor: initialize a variable to silence compiler warning
    ACPI / processor: use ACPI_COMPANION() to get ACPI device
    ACPI: correct minor typos
    ACPI / sleep: Drop redundant acpi_disabled check
    ACPI / dock: Drop redundant acpi_disabled check
    ACPI / table: Replace '1' with specific error return values
    ACPI: remove trailing whitespace
    ACPI / IBFT: Fix incorrect inclusion in iSCSI boot firmware module
    ACPI / i915: Fix incorrect inclusions via
    SFI / ACPI: Fix warnings reported during builds with W=1
    ...

    Conflicts:
    drivers/acpi/nvs.c
    drivers/hwmon/asus_atk0110.c

    Rafael J. Wysocki
     

08 Jan, 2014

12 commits

  • Version 20131218.

    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Bob Moore
     
  • This global is acting as an OSL global variable, implemented in the
    oswinxf.c and osunixxf.c.

    This patch cleans up the definition of this variable so that new utilities
    do not need to define it in order to link.

    Linux kernel behaviour is not affected as the changes only applies to the
    ACPICA userspace utilities which are not shipped in the kernel currently.

    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This patch reflects the improvment of a cleanup step which is performed in
    the release process.

    There are still spaces in the "linuxized" ACPICA files after special macro
    invocations. This is because indent treats comments and pre-processor
    directives as spaces, thus we need to skip them.

    Before applying this patch, cleanup code will search from keyword back to
    end of line and wipe spaces between them.

    After applying this patch, cleanup code will search to the end of the macro
    invocations, skip "empty lines", "comments" and "pre-processor directives",
    then wipe the spaces between the new line and the first non-spaces
    characters.

    Following improvements are thus achieved in the release automation by this
    commit which are originally maintained manually:
    - acpi_status acpi_ev_remove_global_lock_handler(void);
    +acpi_status acpi_ev_remove_global_lock_handler(void);
    - acpi_status
    +acpi_status
    acpi_ev_match_gpe_method(acpi_handle obj_handle,
    - acpi_status acpi_subsystem_status(void);
    +acpi_status acpi_subsystem_status(void);
    - acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type,
    +acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type,
    - acpi_status
    +acpi_status
    acpi_acquire_mutex(acpi_handle handle, acpi_string pathname, u16 timeout);
    - acpi_status
    +acpi_status
    acpi_get_sleep_type_data(u8 sleep_state, u8 *slp_typ_a, u8 *slp_typ_b);
    - acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
    +acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
    Some empty lines are restored by this commit due to the change of the
    removal implementation.

    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • Previously, the example code (tools/examples) showed the ACPICA
    init code, but was not an actual working program. Added ACPI tables
    to make it actually function.

    Linux kernel behaviour is not affected as the change only applies
    to the ACPICA userspace utilities which are not shipped in the
    kernel currently.

    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Bob Moore
     
  • This change adds two macros to extract the encoded bus and segment
    numbers from the HEST Bus field.

    Signed-off-by: Betty Dall
    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Betty Dall
     
  • Updates the PCCT table definition in the actbl3.h header.

    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Bob Moore
     
  • Updates the DBG2 (Debug Port 2) table definition in the actbl2.h header.

    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Bob Moore
     
  • This change adds an option to favor 32-bit FADT addresses when there
    is a conflict between the 32-bit and 64-bit versions of the same
    address. The default behavior is to use the 64-bit version in accordance
    with the ACPI specification. This can now be overridden via the
    AcpiGbl_Use32BitFadtAddresses flag. Lv Zheng.

    Also, the "Convert FADT" and "Verify FADT" functions have been merged to
    simplify the code, make it easier to understand, and make it easier to
    maintain. Bob Moore.

    References: https://bugs.acpica.org/show_bug.cgi?id=885
    References: https://bugs.acpica.org/show_bug.cgi?id=993
    Original-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Bob Moore
     
  • This change adds a runtime option that will force ACPICA to use the
    RSDT instead of the XSDT. Although the ACPI spec requires that an XSDT
    be used instead of the RSDT, the XSDT has been found to be corrupt or
    ill-formed on some machines.

    This option is already in the Linux kernel. When it is back ported to
    ACPICA, code is re-written to follow ACPICA coding style. This patch
    is the generation of the integration.

    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • Some platforms contain an XSDT that is ill-formed or otherwise invalid
    (such as containing some or all entries that are NULL pointers).
    This change adds a new function to validate the XSDT before actually
    using it. If the XSDT is found to be invalid, ACPICA will now fall
    back to using the RSDT instead.

    This feature is already in the Linux kernel. When it is back ported to
    ACPICA, code is refined to follow ACPICA coding style and this patch
    is the generation of the integration.

    Original-by: Zhao Yakui
    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This patch removes 2 useless OSL prototypes as they are not used by Linux now.

    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This macro is no longer used by ACPICA and it is not public.
    Also update comments related to the use of ACPI_ALLOCATE_BUFFER and
    the use of acpi_os_free (kfree is equivalent and prefered in the
    kernel) to free the buffer.

    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

05 Jan, 2014

1 commit

  • There are several drivers making use of ACPI _DSM method to detect
    and invoke device specific methods. Currently every driver has
    implemented its private version to support ACPI _DSM method.
    So this patch introduces three helper functions to support ACPI _DSM
    method, which will be used to replace open-coded versions.

    It helps to simplify code and improve code readability.

    Signed-off-by: Jiang Liu
    Signed-off-by: Rafael J. Wysocki

    Jiang Liu
     

01 Jan, 2014

1 commit


31 Dec, 2013

2 commits

  • Conflicts:
    include/acpi/acpi_bus.h

    Rafael J. Wysocki
     
  • The changes in the ACPI-based PCI hotplug (ACPIPHP) subsystem made
    during the 3.12 development cycle uncovered a problem with VGA
    switcheroo that on some systems, when the device-specific method
    (ATPX in the radeon case, _DSM in the nouveau case) is used to turn
    off the discrete graphics, the BIOS generates ACPI hotplug events for
    that device and those events cause ACPIPHP to attempt to remove the
    device from the system (they are events for a device that was present
    previously and is not present any more, so that's what should be done
    according to the spec). Then, the system stops functioning correctly.

    Since the hotplug events in question were simply silently ignored
    previously, the least intrusive way to address that problem is to
    make ACPIPHP ignore them again. For this purpose, introduce a new
    ACPI device flag, no_hotplug, and modify ACPIPHP to ignore hotplug
    events for PCI devices whose ACPI companions have that flag set.
    Next, make the radeon and nouveau switcheroo detection code set the
    no_hotplug flag for the discrete graphics' ACPI companion.

    Fixes: bbd34fcdd1b2 (ACPI / hotplug / PCI: Register all devices under the given bridge)
    References: https://bugzilla.kernel.org/show_bug.cgi?id=61891
    References: https://bugzilla.kernel.org/show_bug.cgi?id=64891
    Reported-and-tested-by: Mike Lothian
    Reported-and-tested-by:
    Reported-and-tested-by: Joaquín Aramendía
    Cc: Alex Deucher
    Cc: Dave Airlie
    Cc: Takashi Iwai
    Signed-off-by: Rafael J. Wysocki
    Cc: 3.12+ # 3.12+

    Rafael J. Wysocki
     

29 Dec, 2013

1 commit

  • Add a new ACPI hotplug profile flag, demand_offline, such that if
    set for the given ACPI device object's scan handler, it will cause
    acpi_scan_hot_remove() to check if that device object's physical
    companions are offline upfront and fail the hot removal if that
    is not the case.

    That flag will be useful to overcome a problem with containers on
    some system where they can only be hot-removed after some cleanup
    operations carried out by user space, which needs to be notified
    of the container hot-removal before the kernel attempts to offline
    devices in the container. In those cases the current implementation
    of acpi_scan_hot_remove() is not sufficient, because it first tries
    to offline the devices in the container and only if that is
    suffcessful it tries to offline the container itself. As a result,
    the container hot-removal notification is not delivered to user space
    at the right time.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

07 Dec, 2013

8 commits

  • To avoid build problems and breaking dependencies between ACPI header
    files, should not be included directly by code outside
    of the ACPI core subsystem. However, that is possible if
    is included, because that file contains
    a direct inclusion of .

    For this reason, remove the direct inclusion from
    , move that file from include/linux/ to include/acpi/
    and make include it for CONFIG_ACPI set along with the
    other ACPI header files. Accordingly, Remove the inclusions of
    from everywhere.

    Of course, that causes the contents of the new file
    to be available for CONFIG_ACPI set only, so intel_opregion.o that
    depends on it should also depend on CONFIG_ACPI (and it really should
    not be compiled for CONFIG_ACPI unset anyway).

    References: https://01.org/linuxgraphics/sites/default/files/documentation/acpi_igd_opregion_spec.pdf
    Cc: Matthew Garrett
    Signed-off-by: Lv Zheng
    Acked-by: Daniel Vetter
    [rjw: Subject and changelog]
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • Since drivers/ide/ide-acpi.c is the only remaining user of
    acpi_get_child(), move that function into that file as a static
    routine.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Replace the .find_device function pointer in struct acpi_bus_type
    with a new one, .find_companion, that is supposed to point to a
    function returning struct acpi_device pointer (instead of an int)
    and takes one argument (instead of two). This way the role of
    this callback is more clear and the implementation of it can
    be more straightforward.

    Update all of the users of struct acpi_bus_type (PCI, PNP/ACPI and
    USB) to reflect the structure change.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Lan Tianyu # for USB/ACPI

    Rafael J. Wysocki
     
  • Modify acpi_preset_companion() to take a struct acpi_device pointer
    instead of an ACPI handle as its second argument and redefine it as
    a static inline wrapper around ACPI_COMPANION_SET() passing the
    return value of acpi_find_child_device() directly as the second
    argument to it. Update its users to pass struct acpi_device
    pointers instead of ACPI handles to it.

    This allows some unnecessary acpi_bus_get_device() calls to be
    avoided.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu
    Tested-by: Aaron Lu # for ATA binding

    Rafael J. Wysocki
     
  • Since acpi_get_child() is the only user of acpi_find_child() now,
    drop the static inline definition of the former and redefine the
    latter as new acpi_get_child().

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu
    Tested-by: Aaron Lu # for ATA binding

    Rafael J. Wysocki
     
  • Now that we create a struct acpi_device object for every ACPI
    namespace node representing a device, it is not necessary to
    use acpi_walk_namespace() for child device lookup in
    acpi_find_child() any more. Instead, we can simply walk the
    list of children of the given struct acpi_device object and
    return the matching one (or the one which is the best match if
    there are more of them). The checks done during the matching
    loop can be simplified too so that the secondary namespace walks
    in find_child_checks() are not necessary any more.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu

    Rafael J. Wysocki
     
  • Conflicts:
    drivers/acpi/scan.c

    Rafael J. Wysocki
     
  • Replace direct inclusions of , and
    , which are incorrect, with
    inclusions and remove some inclusions of those files that aren't
    necessary.

    First of all, , and
    should not be included directly from any files that are built for
    CONFIG_ACPI unset, because that generally leads to build warnings about
    undefined symbols in !CONFIG_ACPI builds. For CONFIG_ACPI set,
    includes those files and for CONFIG_ACPI unset it
    provides stub ACPI symbols to be used in that case.

    Second, there are ordering dependencies between those files that always
    have to be met. Namely, it is required that be included
    prior to so that the acpi_pci_root declarations the
    latter depends on are always there. And which provides
    basic ACPICA type declarations should always be included prior to any other
    ACPI headers in CONFIG_ACPI builds. That also is taken care of including
    as appropriate.

    Signed-off-by: Lv Zheng
    Cc: Greg Kroah-Hartman
    Cc: Matthew Garrett
    Cc: Tony Luck
    Cc: "H. Peter Anvin"
    Acked-by: Bjorn Helgaas (drivers/pci stuff)
    Acked-by: Konrad Rzeszutek Wilk (Xen stuff)
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

27 Nov, 2013

1 commit

  • * acpica:
    ACPI: Clean up incorrect inclusions of ACPICA headers
    ACPICA: Update version to 20131115.
    ACPICA: Add support to delete all objects attached to the root namespace node.
    ACPICA: Delete all attached data objects during namespace node deletion.
    ACPICA: Resources: Fix loop termination for the get AML length function.
    ACPICA: Tests: Add CHECKSUM_ABORT protection for test utilities.
    ACPICA: Debug output: Do not emit function nesting level for kernel build.

    Rafael J. Wysocki
     

26 Nov, 2013

1 commit


23 Nov, 2013

5 commits

  • Introduce a static inline function for setting the status field
    of struct acpi_device on the basis of a supplied u32 number,
    acpi_set_device_status(), and use it instead of the horrible
    horrible STRUCT_TO_INT() macro wherever applicable. Having done
    that, drop STRUCT_TO_INT() (and pretend that it has never existed).

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Mika Westerberg

    Rafael J. Wysocki
     
  • Move container-specific uevents from the core hotplug code to the
    container scan handler's .attach() and .detach() callbacks.

    This way the core will not have to special-case containers and
    the uevents will be guaranteed to happen every time a container
    is either scanned or trimmed as appropriate.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Mika Westerberg

    Rafael J. Wysocki
     
  • Rework the common ACPI device hotplug code so that it is suitable
    for PCI host bridge hotplug and switch the PCI host bridge scan
    handler to using the common hotplug code.

    This allows quite a few lines of code that are not necessary any more
    to be dropped from the PCI host bridge scan handler and removes
    arbitrary differences in behavior between PCI host bridge hotplug
    and ACPI-based hotplug of other components, like CPUs and memory.

    Also acpi_device_hotplug() can be static now.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Mika Westerberg

    Rafael J. Wysocki
     
  • Modify the ACPI namespace scanning code to register a struct
    acpi_device object for every namespace node representing a device,
    processor and so on, even if the device represented by that namespace
    node is reported to be not present and not functional by _STA.

    There are multiple reasons to do that. First of all, it avoids
    quite a lot of overhead when struct acpi_device objects are
    deleted every time acpi_bus_trim() is run and then added again
    by a subsequent acpi_bus_scan() for the same scope, although the
    namespace objects they correspond to stay in memory all the time
    (which always is the case on a vast majority of systems).

    Second, it will allow user space to see that there are namespace
    nodes representing devices that are not present at the moment and may
    be added to the system. It will also allow user space to evaluate
    _SUN for those nodes to check what physical slots the "missing"
    devices may be put into and it will make sense to add a sysfs
    attribute for _STA evaluation after this change (that will be
    useful for thermal management on some systems).

    Next, it will help to consolidate the ACPI hotplug handling among
    subsystems by making it possible to store hotplug-related information
    in struct acpi_device objects in a standard common way.

    Finally, it will help to avoid a race condition related to the
    deletion of ACPI namespace nodes. Namely, namespace nodes may be
    deleted as a result of a table unload triggered by _EJ0 or _DCK.
    If a hotplug notification for one of those nodes is triggered
    right before the deletion and it executes a hotplug callback
    via acpi_hotplug_execute(), the ACPI handle passed to that
    callback may be stale when the callback actually runs. One way
    to work around that is to always pass struct acpi_device pointers
    to hotplug callbacks after doing a get_device() on the objects in
    question which eliminates the use-after-free possibility (the ACPI
    handles in those objects are invalidated by acpi_scan_drop_device(),
    so they will trigger ACPICA errors on attempts to use them).

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Mika Westerberg

    Rafael J. Wysocki
     
  • If an ACPI namespace node is removed (usually, as a result of a
    table unload), and there is a data object attached to that node,
    acpi_ns_delete_node() executes the removal handler submitted to
    acpi_attach_data() for that object. That handler is currently empty
    for struct acpi_device objects, so it is necessary to detach those
    objects from the corresponding ACPI namespace nodes in advance every
    time a table unload may happen. That is cumbersome and inefficient
    and leads to some design constraints that turn out to be quite
    inconvenient (in particular, struct acpi_device objects cannot be
    registered for namespace nodes representing devices that are not
    reported as present or functional by _STA).

    For this reason, introduce a non-empty removal handler for ACPI
    device objects that will unregister them when their ACPI namespace
    nodes go away.

    This code modification alone should not change functionality except
    for the ordering of the ACPI hotplug workqueue which should not
    matter (without subsequent code changes).

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Mika Westerberg

    Rafael J. Wysocki