16 Jul, 2016

1 commit

  • The Kconfig for this file is:

    drivers/acpi/Kconfig:config ACPI_DOCK
    drivers/acpi/Kconfig: bool "Dock"

    ...and so it is not built as a module. Hence including module.h
    and everything that comes with it just for the no-op MODULE_LICENSE
    and friends is rather heavy handed.

    The license/author info is found at the top of the file, so we
    just remove the MODULE_LICENSE etc and the include of module.h

    The file does still have some module_param() so we add the right
    include for that infrastructure.

    Signed-off-by: Paul Gortmaker
    Signed-off-by: Rafael J. Wysocki

    Paul Gortmaker
     

08 Jul, 2015

1 commit


17 Mar, 2015

1 commit

  • Now that we have struct fwnode_handle, we can use that to point to
    ACPI companions from struct device objects instead of pointing to
    struct acpi_device directly.

    There are two benefits from that. First, the somewhat ugly and
    hackish struct acpi_dev_node can be dropped and, second, the same
    struct fwnode_handle pointer can be used in the future to point
    to other (non-ACPI) firmware device node types.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Acked-by: Grant Likely

    Rafael J. Wysocki
     

07 Apr, 2014

1 commit


20 Mar, 2014

1 commit


19 Mar, 2014

1 commit


22 Feb, 2014

3 commits


21 Feb, 2014

3 commits

  • In order to avoid the need to register special ACPI dock
    operations for SATA devices add a .uevent() callback pointer to
    struct acpi_hotplug_context and make dock_hotplug_event() use that
    callback if available. Also rename the existing .event() callback
    in struct acpi_hotplug_context to .notify() to avoid possible
    confusion in the future.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Instead of requiring a set of special dock operations to be registered
    via register_hotplug_dock_device() for each ACPI dock device, it is
    much more straightforward to use callback pointers from the devices'
    hotplug contexts if available.

    For this reason, modify dock_hotplug_event() to use callback pointers
    from the hotplug contexts of ACPI devices and fall back to using the
    special dock operarions only if those callbacks are missing. Also
    make the ACPI-based PCI hotplug (ACPIPHP) subsystem set the .fixup
    callback pointer in the hotplug contexts of devices handled by it to
    a new function, acpiphp_post_dock_fixup(), so that the dock station
    driver can use the callbacks from those contexts instead of special
    dock operations registered via register_hotplug_dock_device().

    Along with the above changes drop the ACPIPHP's dock operations that
    are not necessary any more.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Rework the ACPI dock station driver to store ACPI device object
    pointers instead of ACPI handles in its internal data structures.

    The purpose is moslty to make subsequent simplifications possible,
    but also this allows the overall code size to be reduced slightly.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

16 Feb, 2014

3 commits

  • To allow user space to check which ACPI device object the dock
    station is represented by, make acpi_dock_add() indicate to
    platform_device_register_full() which ACPI device object should
    be the companion of the new platform device.

    This also ensures that the ACPI device object in question will
    not go away while the dock platform device is present (which is
    always).

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Since we already know what the device's PNP IDs are when
    acpi_device_is_battery() is called, it is not necessary to run
    acpi_get_object_info() for the device in that function. Instead, if
    acpi_device_is_battery() is passed a pointer to a struct acpi_device
    object, it can use the list of PNP IDs from that object, so make that
    happen and modify the function's header accordingly

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • The ACPI dock station code carries out an extra namespace scan
    before the main one in order to find and register all of the dock
    device objects. Then, it registers a notify handler for each of
    them for handling dock events.

    However, dock device objects need not be scanned for upfront. They
    very well can be enumerated and registered during the first phase
    of the main namespace scan, before attaching scan handlers and ACPI
    drivers to ACPI device objects. Then, the dependent devices can be
    added to the in the second phase. That makes it possible to drop
    the extra namespace scan, so do it.

    Moreover, it is not necessary to register notify handlers for all
    of the dock stations' namespace nodes, becuase notifications may
    be dispatched from the global notify handler for them. Do that and
    drop two functions used for dock notify handling, acpi_dock_deferred_cb()
    and dock_notify_handler(), that aren't necessary any more.

    Finally, some dock station objects have _HID objects matching the
    ACPI container scan handler which causes it to claim those objects
    and try to handle their hotplug, but that is not a good idea,
    because those objects have their own special hotplug handling anyway.
    For this reason, the hotplug_notify flag should not be set for ACPI
    device objects representing dock stations and the container scan
    handler should be made ignore those objects, so make that happen.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

15 Feb, 2014

1 commit

  • After recent ACPI core changes acpi_bus_get_device() will always
    succeed for dock station ACPI device objects, so show_docked()
    should not use that function's return value as an indicator of
    whether or not the dock device is present.

    Make it use acpi_device_enumerated() for this purpose.

    Fixes: 202317a573b2 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace)
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

10 Feb, 2014

1 commit

  • After commit 202317a573b2 (ACPI / scan: Add acpi_device objects for
    all device nodes in the namespace) acpi_bus_get_device() will always
    return 0 for dock devices in dock_notify(), so the dock station
    docking code under ACPI_NOTIFY_DEVICE_CHECK will never be executed
    and docking will not work as a result of that.

    Fix the problem by making dock_notify() use acpi_device_enumerated()
    to check the presence of the device instead of checking the return
    value of acpi_bus_get_device().

    Fixes: 202317a573b2 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace)
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

13 Jan, 2014

1 commit

  • * 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
     

06 Jan, 2014

1 commit

  • Includes appropriate header file internal.h in dock.c because
    function acpi_dock_init() has its prototype declaration in
    internal.h.

    This eliminates the following warning in dock.c:
    drivers/acpi/dock.c:899:13: warning: no previous prototype for ‘acpi_dock_init’ [-Wmissing-prototypes]

    Signed-off-by: Rashika Kheria
    Reviewed-by: Josh Triplett
    Signed-off-by: Rafael J. Wysocki

    Rashika
     

07 Dec, 2013

3 commits

  • acpi_dock_init() is only called from acpi_scan_init() and the
    code logic shows that it doesn't need to check acpi_disabled:

    acpi_init();
    if (acpi_disabled) return;
    acpi_scan_init();
    acpi_dock_init();
    if (acpi_disabled) /* redundant */
    return;

    Signed-off-by: Hanjun Guo
    [rjw: Subject and changelog]
    Signed-off-by: Rafael J. Wysocki

    Hanjun Guo
     
  • 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
     

23 Nov, 2013

1 commit

  • 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
     

08 Nov, 2013

2 commits

  • * acpi-hotplug:
    ACPI / hotplug: Consolidate deferred execution of ACPI hotplug routines
    ACPI / hotplug: Do not execute "insert in progress" _OST
    ACPI / hotplug: Carry out PCI root eject directly
    ACPI / hotplug: Merge device hot-removal routines
    ACPI / hotplug: Make acpi_bus_hot_remove_device() internal
    ACPI / hotplug: Simplify device ejection routines
    ACPI / hotplug: Fix handle_root_bridge_removal()
    ACPI / hotplug: Refuse to hot-remove all objects with disabled hotplug
    ACPI / scan: Start matching drivers after trying scan handlers
    ACPI: Remove acpi_pci_slot_init() headers from internal.h

    Conflicts:
    include/acpi/acpiosxf.h (with the 'acpica' branch)

    Rafael J. Wysocki
     
  • There are two different interfaces for queuing up work items on the
    ACPI hotplug workqueue, alloc_acpi_hp_work() used by PCI and PCI host
    bridge hotplug code and acpi_os_hotplug_execute() used by the common
    ACPI hotplug code and docking stations. They both are somewhat
    cumbersome to use and work slightly differently.

    The users of alloc_acpi_hp_work() have to submit a work function that
    will extract the necessary data items from a struct acpi_hp_work
    object allocated by alloc_acpi_hp_work() and then will free that
    object, while it would be more straightforward to simply use a work
    function with one more argument and let the interface take care of
    the execution details.

    The users of acpi_os_hotplug_execute() also have to deal with the
    fact that it takes only one argument in addition to the work function
    pointer, although acpi_os_execute_deferred() actually takes care of
    the allocation and freeing of memory, so it would have been able to
    pass more arguments to the work function if it hadn't been
    constrained by the connection with acpi_os_execute().

    Moreover, while alloc_acpi_hp_work() makes GFP_KERNEL memory
    allocations, which is correct, because hotplug work items are
    always queued up from process context, acpi_os_hotplug_execute()
    uses GFP_ATOMIC, as that is needed by acpi_os_execute(). Also,
    acpi_os_execute_deferred() queued up by it waits for the ACPI event
    workqueues to flush before executing the work function, whereas
    alloc_acpi_hp_work() can't do anything similar. That leads to
    somewhat arbitrary differences in behavior between various ACPI
    hotplug code paths and has to be straightened up.

    For this reason, replace both alloc_acpi_hp_work() and
    acpi_os_hotplug_execute() with a single interface,
    acpi_hotplug_execute(), combining their behavior and being more
    friendly to its users than any of the two.

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

    Rafael J. Wysocki
     

24 Sep, 2013

1 commit

  • acpi_evaluate_integer() is an ACPI API introduced to evaluate an
    ACPI control method that is known to have an integer return value.
    This API can simplify the code because the calling function does not need to
    use the specified acpi_buffer structure required by acpi_evaluate_object();

    Convert acpi_evaluate_object() to acpi_evaluate_integer()
    in drivers/acpi/dock.c in this patch.

    Signed-off-by: Zhang Rui
    Signed-off-by: Rafael J. Wysocki

    Zhang Rui
     

27 Aug, 2013

1 commit

  • * acpi-assorted:
    ACPI / osl: Kill macro INVALID_TABLE().
    earlycpio.c: Fix the confusing comment of find_cpio_data().
    ACPI / x86: Print Hot-Pluggable Field in SRAT.
    ACPI / thermal: Use THERMAL_TRIPS_NONE macro to replace number
    ACPI / thermal: Remove unused macros in the driver/acpi/thermal.c
    ACPI / thermal: Remove the unused lock of struct acpi_thermal
    ACPI / osl: Fix osi_setup_entries[] __initdata attribute location
    ACPI / numa: Fix __init attribute location in slit_valid()
    ACPI / dock: Fix __init attribute location in find_dock_and_bay()
    ACPI / Sleep: Fix incorrect placement of __initdata
    ACPI / processor: Fix incorrect placement of __initdata
    ACPI / EC: Fix incorrect placement of __initdata
    ACPI / scan: Drop unnecessary label from acpi_create_platform_device()
    ACPI: Move acpi_bus_get_device() from bus.c to scan.c
    ACPI / scan: Allow platform device creation without any IO resources
    ACPI: Cleanup sparse warning on acpi_os_initialize1()
    platform / thinkpad: Remove deprecated hotkey_report_mode parameter
    ACPI: Remove the old /proc/acpi/event interface

    Rafael J. Wysocki
     

13 Aug, 2013

1 commit


26 Jul, 2013

1 commit


15 Jul, 2013

11 commits

  • The local variable id in dock_add() is not necessary, so drop it.

    While we're at it, use an initializer to clear the local variable ds
    and drop the memset() used for this purpose.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • The only user of the ACPI dock notifier chain is the ACPI-based PCI
    hotplug (acpiphp) driver that uses it to carry out post-dock fixups
    needed by some systems with broken _DCK. However, it is not
    necessary to use a separate notifier chain for that, as it can be
    simply replaced with a new callback in struct acpi_dock_ops.

    For this reason, add a new .fixup() callback to struct acpi_dock_ops
    and make hotplug_dock_devices() execute it for all dock devices with
    hotplug operations registered. Accordingly, make acpiphp point that
    callback to the function carrying out the post-dock fixups and
    do not register a separate dock notifier for each device
    registering dock operations. Finally, drop the ACPI dock notifier
    chain that has no more users.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • The function creating and registering dock station objects,
    dock_add(), leaks memory if there's an error after it's walked
    the ACPI namespace calling find_dock_devices(), because it doesn't
    free the list of dependent devices it's just created in those cases.

    Fix that issue by adding the missing code to free the list of
    dependent devices on errors.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • The ACPI dock driver uses register_acpi_bus_notifier() which
    installs a notifier triggered globally for all system notifications.
    That first of all is inefficient, because the dock driver is only
    interested in notifications associated with the devices it handles,
    but it has to handle all system notifies for all devices. Moreover,
    it does that even if no docking stations are present in the system
    (CONFIG_ACPI_DOCK set is sufficient for that to happen). Besides,
    that is inconvenient, because it requires the driver to do extra work
    for each notification to find the target dock station object.

    For these reasons, rework the dock driver to install a notify
    handler individually for each dock station in the system using
    acpi_install_notify_handler(). This allows the dock station
    object to be passed directly to the notify handler and makes it
    possible to simplify the dock driver quite a bit. It also
    reduces the overhead related to the handling of all system
    notifies when CONFIG_ACPI_DOCK is set.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu

    Rafael J. Wysocki
     
  • Make dock_init_hotplug() and dock_release_hotplug() slightly simpler
    and move some checks in those functions to the code paths where they
    are needed.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu

    Rafael J. Wysocki
     
  • If there are indirect dependencies between devices in a dock
    station's dependent devices list, they may be broken if the devices
    are removed in the same order in which they have been added.

    For this reason, make the code in handle_eject_request() walk the
    list of dependent devices in reverse order.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu

    Rafael J. Wysocki
     
  • Since acpi_walk_namespace() calls find_dock_devices() during tree
    pre-order visit, the latter doesn't need to add devices whose
    parents have _EJD pointing to the docking station to the list of
    that station's dependent devices, because those parents are going to
    be added to that list anyway and the removal of a parent will take
    care of the removal of its children in those cases.

    For this reason, rework find_dock_devices() to only call
    add_dock_dependent_device() for devices whose _EJD point directy to
    the docking station represented by its context argument and simplify
    it slightly.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu

    Rafael J. Wysocki
     
  • The only existing user of the hp_lock mutex in struct dock_station,
    hotplug_dock_devices(), is always called under acpi_scan_lock and
    cannot race with another instance of itself, so drop the mutex
    which is not necessary.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Use helper functions introduced previously to simplify the ACPI dock
    driver.

    [rjw: Changelog]
    Signed-off-by: Jiang Liu
    Signed-off-by: Rafael J. Wysocki

    Jiang Liu
     
  • The return value of dock_create_acpi_device() is not used at all,
    so change its signature to return void and simplify the
    implementation of it.

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

    Jiang Liu
     
  • Mark all initialization functions with __init to reduce runtime
    memory consumption.

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

    Jiang Liu