1. 10 2月, 2014 1 次提交
    • R
      ACPI / dock: Use acpi_device_enumerated() to check if dock is present · 0a8e5c3d
      Rafael J. Wysocki 提交于
      After commit 202317a5 (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: 202317a5 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0a8e5c3d
  2. 06 1月, 2014 1 次提交
  3. 07 12月, 2013 2 次提交
    • H
      ACPI / dock: Drop redundant acpi_disabled check · 4ef54410
      Hanjun Guo 提交于
      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: NHanjun Guo <hanjun.guo@linaro.org>
      [rjw: Subject and changelog]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      4ef54410
    • L
      ACPI: Clean up inclusions of ACPI header files · 8b48463f
      Lv Zheng 提交于
      Replace direct inclusions of <acpi/acpi.h>, <acpi/acpi_bus.h> and
      <acpi/acpi_drivers.h>, which are incorrect, with <linux/acpi.h>
      inclusions and remove some inclusions of those files that aren't
      necessary.
      
      First of all, <acpi/acpi.h>, <acpi/acpi_bus.h> and <acpi/acpi_drivers.h>
      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,
      <linux/acpi.h> 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 <acpi/acpi_bus.h> be included
      prior to <acpi/acpi_drivers.h> so that the acpi_pci_root declarations the
      latter depends on are always there.  And <acpi/acpi.h> 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
      <linux/acpi.h> as appropriate.
      Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Matthew Garrett <mjg59@srcf.ucam.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Acked-by: Bjorn Helgaas <bhelgaas@google.com> (drivers/pci stuff)
      Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> (Xen stuff)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8b48463f
  4. 23 11月, 2013 1 次提交
    • R
      ACPI / scan: Add acpi_device objects for all device nodes in the namespace · 202317a5
      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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      202317a5
  5. 08 11月, 2013 1 次提交
    • R
      ACPI / hotplug: Consolidate deferred execution of ACPI hotplug routines · 7b98118a
      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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      7b98118a
  6. 24 9月, 2013 1 次提交
  7. 13 8月, 2013 1 次提交
  8. 26 7月, 2013 1 次提交
  9. 15 7月, 2013 13 次提交
  10. 04 7月, 2013 1 次提交
    • R
      ACPI / dock: Actually define acpi_dock_init() as void · 2ce65fe8
      Rafael J. Wysocki 提交于
      Commit 94add0f8 (ACPI / dock: Initialize ACPI dock subsystem upfront)
      changed the header of acpi_dock_init() in internal.h so that it is
      supposed to be a void function now, but it forgot to update its
      actual definition in dock.c according to which it still is supposed
      to return int.
      
      Although that didn't cause any visible breakage or even a compiler
      warning to be thrown, which is odd enough, fix it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: 3.10+ <stable@vger.kernel.org>
      2ce65fe8
  11. 24 6月, 2013 1 次提交
    • R
      ACPI / dock / PCI: Synchronous handling of dock events for PCI devices · 21a31013
      Rafael J. Wysocki 提交于
      The interactions between the ACPI dock driver and the ACPI-based PCI
      hotplug (acpiphp) are currently problematic because of ordering
      issues during hot-remove operations.
      
      First of all, the current ACPI glue code expects that physical
      devices will always be deleted before deleting the companion ACPI
      device objects.  Otherwise, acpi_unbind_one() will fail with a
      warning message printed to the kernel log, for example:
      
      [  185.026073] usb usb5: Oops, 'acpi_handle' corrupt
      [  185.035150] pci 0000:1b:00.0: Oops, 'acpi_handle' corrupt
      [  185.035515] pci 0000:18:02.0: Oops, 'acpi_handle' corrupt
      [  180.013656]  port1: Oops, 'acpi_handle' corrupt
      
      This means, in particular, that struct pci_dev objects have to
      be deleted before the struct acpi_device objects they are "glued"
      with.
      
      Now, the following happens the during the undocking of an ACPI-based
      dock station:
       1) hotplug_dock_devices() invokes registered hotplug callbacks to
          destroy physical devices associated with the ACPI device objects
          depending on the dock station.  It calls dd->ops->handler() for
          each of those device objects.
       2) For PCI devices dd->ops->handler() points to
          handle_hotplug_event_func() that queues up a separate work item
          to execute _handle_hotplug_event_func() for the given device and
          returns immediately.  That work item will be executed later.
       3) hotplug_dock_devices() calls dock_remove_acpi_device() for each
          device depending on the dock station.  This runs acpi_bus_trim()
          for each of them, which causes the underlying ACPI device object
          to be destroyed, but the work items queued up by
          handle_hotplug_event_func() haven't been started yet.
       4) _handle_hotplug_event_func() queued up in step 2) are executed
          and cause the above failure to happen, because the PCI devices
          they handle do not have the companion ACPI device objects any
          more (those objects have been deleted in step 3).
      
      The possible breakage doesn't end here, though, because
      hotplug_dock_devices() may return before at least some of the
      _handle_hotplug_event_func() work items spawned by it have a
      chance to complete and then undock() will cause _DCK to be
      evaluated and that will cause the devices handled by the
      _handle_hotplug_event_func() to go away possibly while they are
      being accessed.
      
      This means that dd->ops->handler() for PCI devices should not point
      to handle_hotplug_event_func().  Instead, it should point to a
      function that will do the work of _handle_hotplug_event_func()
      synchronously.  For this reason, introduce such a function,
      hotplug_event_func(), and modity acpiphp_dock_ops to point to
      it as the handler.
      
      Unfortunately, however, this is not sufficient, because if the dock
      code were not changed further, hotplug_event_func() would now
      deadlock with hotplug_dock_devices() that called it, since it would
      run unregister_hotplug_dock_device() which in turn would attempt to
      acquire the dock station's hp_lock mutex already acquired by
      hotplug_dock_devices().
      
      To resolve that deadlock use the observation that
      unregister_hotplug_dock_device() won't need to acquire hp_lock
      if PCI bridges the devices on the dock station depend on are
      prevented from being removed prematurely while the first loop in
      hotplug_dock_devices() is in progress.
      
      To make that possible, introduce a mechanism by which the callers of
      register_hotplug_dock_device() can provide "init" and "release"
      routines that will be executed, respectively, during the addition
      and removal of the physical device object associated with the
      given ACPI device handle.  Make acpiphp use two new functions,
      acpiphp_dock_init() and acpiphp_dock_release(), that call
      get_bridge() and put_bridge(), respectively, on the acpiphp bridge
      holding the given device, for this purpose.
      
      In addition to that, remove the dock station's list of
      "hotplug devices" and make the dock code always walk the whole list
      of "dependent devices" instead in such a way that the loops in
      hotplug_dock_devices() and dock_event() (replacing the loops over
      "hotplug devices") will take references to the list entries that
      register_hotplug_dock_device() has been called for.  That prevents
      the "release" routines associated with those entries from being
      called while the given entry is being processed and for PCI
      devices this means that their bridges won't be removed (by a
      concurrent thread) while hotplug_event_func() handling them is
      being executed.
      
      This change is based on two earlier patches from Jiang Liu.
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=59501Reported-and-tested-by: NAlexander E. Patrakov <patrakov@gmail.com>
      Tracked-down-by: NJiang Liu <jiang.liu@huawei.com>
      Tested-by: NIllya Klymov <xanf@xanf.me>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      Cc: 3.9+ <stable@vger.kernel.org>
      21a31013
  12. 23 6月, 2013 1 次提交
  13. 20 6月, 2013 1 次提交
    • R
      ACPI / dock: Take ACPI scan lock in write_undock() · 8112006f
      Rafael J. Wysocki 提交于
      Since commit 3757b948 (ACPI / hotplug: Fix concurrency issues and
      memory leaks) acpi_bus_scan() and acpi_bus_trim() must always be
      called under acpi_scan_lock, but currently the following scenario
      violating that requirement is possible:
      
       write_undock()
        handle_eject_request()
         hotplug_dock_devices()
          dock_remove_acpi_device()
           acpi_bus_trim()
      
      Fix that by making write_undock() acquire acpi_scan_lock before
      calling handle_eject_request() as appropriate (begin_undock() is
      under the lock too in analogy with acpi_dock_deferred_cb()).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: 3.9+ <stable@vger.kernel.org>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      8112006f
  14. 13 2月, 2013 1 次提交
    • R
      ACPI / hotplug: Fix concurrency issues and memory leaks · 3757b948
      Rafael J. Wysocki 提交于
      This changeset is aimed at fixing a few different but related
      problems in the ACPI hotplug infrastructure.
      
      First of all, since notify handlers may be run in parallel with
      acpi_bus_scan(), acpi_bus_trim() and acpi_bus_hot_remove_device()
      and some of them are installed for ACPI handles that have no struct
      acpi_device objects attached (i.e. before those objects are created),
      those notify handlers have to take acpi_scan_lock to prevent races
      from taking place (e.g. a struct acpi_device is found to be present
      for the given ACPI handle, but right after that it is removed by
      acpi_bus_trim() running in parallel to the given notify handler).
      Moreover, since some of them call acpi_bus_scan() and
      acpi_bus_trim(), this leads to the conclusion that acpi_scan_lock
      should be acquired by the callers of these two funtions rather by
      these functions themselves.
      
      For these reasons, make all notify handlers that can handle device
      addition and eject events take acpi_scan_lock and remove the
      acpi_scan_lock locking from acpi_bus_scan() and acpi_bus_trim().
      Accordingly, update all of their users to make sure that they
      are always called under acpi_scan_lock.
      
      Furthermore, since eject operations are carried out asynchronously
      with respect to the notify events that trigger them, with the help
      of acpi_bus_hot_remove_device(), even if notify handlers take the
      ACPI scan lock, it still is possible that, for example,
      acpi_bus_trim() will run between acpi_bus_hot_remove_device() and
      the notify handler that scheduled its execution and that
      acpi_bus_trim() will remove the device node passed to
      acpi_bus_hot_remove_device() for ejection.  In that case, the struct
      acpi_device object obtained by acpi_bus_hot_remove_device() will be
      invalid and not-so-funny things will ensue.  To protect agaist that,
      make the users of acpi_bus_hot_remove_device() run get_device() on
      ACPI device node objects that are about to be passed to it and make
      acpi_bus_hot_remove_device() run put_device() on them and check if
      their ACPI handles are not NULL (make acpi_device_unregister() clear
      the device nodes' ACPI handles for that check to work).
      
      Finally, observe that acpi_os_hotplug_execute() actually can fail,
      in which case its caller ought to free memory allocated for the
      context object to prevent leaks from happening.  It also needs to
      run put_device() on the device node that it ran get_device() on
      previously in that case.  Modify the code accordingly.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      3757b948
  15. 03 2月, 2013 1 次提交
  16. 26 1月, 2013 1 次提交
  17. 19 1月, 2013 1 次提交
    • R
      ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead · b8bd759a
      Rafael J. Wysocki 提交于
      The only difference between acpi_bus_scan() and acpi_bus_add() is the
      invocation of acpi_update_all_gpes() in the latter which in fact is
      unnecessary, because acpi_update_all_gpes() has already been called
      by acpi_scan_init() and the way it is implemented guarantees the next
      invocations of it to do nothing.
      
      For this reason, drop acpi_bus_add() and make all its callers use
      acpi_bus_scan() directly instead of it.  Additionally, rearrange the
      code in acpi_scan_init() slightly to improve the visibility of the
      acpi_update_all_gpes() call in there.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      b8bd759a
  18. 15 1月, 2013 1 次提交
  19. 03 1月, 2013 2 次提交
    • R
      ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument · 0cd6ac52
      Rafael J. Wysocki 提交于
      The callers of acpi_bus_add() usually assume that if it has
      succeeded, then a struct acpi_device object has been attached to
      the handle passed as the first argument.  Unfortunately, however,
      this assumption is wrong, because acpi_bus_scan(), and acpi_bus_add()
      too as a result, may return a pointer to a different struct
      acpi_device object on success (it may be an object corresponding to
      one of the descendant ACPI nodes in the namespace scope below that
      handle).
      
      For this reason, the callers of acpi_bus_add() who care about
      whether or not a struct acpi_device object has been created for
      its first argument need to check that using acpi_bus_get_device()
      anyway, so the second argument of acpi_bus_add() is not really
      useful for them.  The same observation applies to acpi_bus_scan()
      executed directly from acpi_scan_init().
      
      Therefore modify the relevant callers of acpi_bus_add() to check the
      existence of the struct acpi_device in question with the help of
      acpi_bus_get_device() and drop the no longer necessary second
      argument of acpi_bus_add().  Accordingly, modify acpi_scan_init() to
      use acpi_bus_get_device() to get acpi_root and drop the no longer
      needed second argument of acpi_bus_scan().
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      0cd6ac52
    • R
      ACPI: Remove the arguments of acpi_bus_add() that are not used · 636458de
      Rafael J. Wysocki 提交于
      Notice that acpi_bus_add() uses only 2 of its 4 arguments and
      redefine its header to match the body.  Update all of its callers as
      necessary and observe that this leads to quite a number of removed
      lines of code (Linus will like that).
      
      Add a kerneldoc comment documenting acpi_bus_add() and wonder how
      its callers make wrong assumptions about the second argument (make
      note to self to take care of that later).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      636458de
  20. 22 11月, 2012 1 次提交
  21. 15 11月, 2012 1 次提交
  22. 13 1月, 2012 1 次提交
  23. 17 7月, 2011 1 次提交
  24. 12 1月, 2011 1 次提交
    • L
      ACPICA: Rename some function and variable names · 3a37898d
      Lin Ming 提交于
      Some function and variable names are renamed to be consistent with
      ACPICA code base.
      
      acpi_raw_enable_gpe -> acpi_ev_add_gpe_reference
      acpi_raw_disable_gpe -> acpi_ev_remove_gpe_reference
      acpi_gpe_can_wake -> acpi_setup_gpe_for_wake
      acpi_gpe_wakeup -> acpi_set_gpe_wake_mask
      acpi_update_gpes -> acpi_update_all_gpes
      acpi_all_gpes_initialized -> acpi_gbl_all_gpes_initialized
      acpi_handler_info -> acpi_gpe_handler_info
      ...
      Signed-off-by: NLin Ming <ming.m.lin@intel.com>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      3a37898d
  25. 20 10月, 2010 1 次提交
    • U
      ACPI dock: move some functions to .init.text · d38a5edf
      Uwe Kleine-König 提交于
      find_dock and find_bay are only called by dock_init which lives in
      .init.text dock_add is only called by find_dock and find_bay.  So all
      three functions can be moved to .init.text, too.
      
      This fixes:
      
              WARNING: vmlinux.o(.text+0x2134b7): Section mismatch in reference from the function dock_add() to the function .init.text:platform_device_register_resndata()
              The function dock_add() references
              the function __init platform_device_register_resndata().
              This is often because dock_add lacks a __init
              annotation or the annotation of platform_device_register_resndata is wrong.
      
      for a build with unset CONFIG_MODULES.
      Signed-off-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      d38a5edf
  26. 25 9月, 2010 1 次提交
    • R
      ACPI / ACPICA: Defer enabling of runtime GPEs (v3) · a2100801
      Rafael J. Wysocki 提交于
      The current ACPI GPEs initialization code has a problem that it
      enables some GPEs pointed to by device _PRW methods, generally
      intended for signaling wakeup events (system or device wakeup).
      These GPEs are then almost immediately disabled by the ACPI namespace
      scanning code with the help of acpi_gpe_can_wake(), but it would be
      better not to enable them at all until really necessary.
      
      Modify the initialization of GPEs so that the ones that have
      associated _Lxx or _Exx methods and are not pointed to by any _PRW
      methods will be enabled after the namespace scan is complete.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      a2100801