1. 29 12月, 2013 1 次提交
    • R
      ACPI / hotplug / driver core: Handle containers in a special way · caa73ea1
      Rafael J. Wysocki 提交于
      ACPI container devices require special hotplug handling, at least
      on some systems, since generally user space needs to carry out
      system-specific cleanup before it makes sense to offline devices in
      the container.  However, the current ACPI hotplug code for containers
      first attempts to offline devices in the container and only then it
      notifies user space of the container offline.
      
      Moreover, after commit 202317a5 (ACPI / scan: Add acpi_device
      objects for all device nodes in the namespace), ACPI device objects
      representing containers are present as long as the ACPI namespace
      nodes corresponding to them are present, which may be forever, even
      if the container devices are physically detached from the system (the
      return values of the corresponding _STA methods change in those
      cases, but generally the namespace nodes themselves are still there).
      Thus it is useful to introduce entities representing containers that
      will go away during container hot-unplug.
      
      The goal of this change is to address both the above issues.
      
      The idea is to create a "companion" container system device for each
      of the ACPI container device objects during the initial namespace
      scan or on a hotplug event making the container present.  That system
      device will be unregistered on container removal.  A new bus type
      for container devices is added for this purpose, because device
      offline and online operations need to be defined for them.  The
      online operation is a trivial function that is always successful
      and the offline uses a callback pointed to by the container device's
      offline member.
      
      For ACPI containers that callback simply walks the list of ACPI
      device objects right below the container object (its children) and
      checks if all of their physical companion devices are offline.  If
      that's not the case, it returns -EBUSY and the container system
      devivce cannot be put offline.  Consequently, to put the container
      system device offline, it is necessary to put all of the physical
      devices depending on its ACPI companion object offline beforehand.
      
      Container system devices created for ACPI container objects are
      initially online.  They are created by the container ACPI scan
      handler whose hotplug.demand_offline flag is set.  That causes
      acpi_scan_hot_remove() to check if the companion container system
      device is offline before attempting to remove an ACPI container or
      any devices below it.  If the check fails, a KOBJ_CHANGE uevent is
      emitted for the container system device in question and user space
      is expected to offline all devices below the container and the
      container itself in response to it.  Then, user space can finalize
      the removal of the container with the help of its ACPI device
      object's eject attribute in sysfs.
      Tested-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      caa73ea1
  2. 07 12月, 2013 1 次提交
  3. 23 11月, 2013 4 次提交
    • R
      ACPI / hotplug: Make ACPI PCI root hotplug use common hotplug code · 3338db00
      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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      3338db00
    • R
      ACPI / hotplug: Introduce common hotplug function acpi_device_hotplug() · c27b2c33
      Rafael J. Wysocki 提交于
      Modify the common ACPI device hotplug code to always queue up the
      same function, acpi_device_hotplug(), using acpi_hotplug_execute()
      and make the PCI host bridge hotplug code use that function too for
      device hot removal.
      
      This allows some code duplication to be reduced and a race condition
      where the relevant ACPI handle may become invalid between the
      notification handler and the function queued up by it via
      acpi_hotplug_execute() to be avoided.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      c27b2c33
    • 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
    • R
      ACPI / scan: Define non-empty device removal handler · d783156e
      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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      d783156e
  4. 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
  5. 07 11月, 2013 3 次提交
  6. 16 10月, 2013 1 次提交
    • A
      ACPI / video: Do not register backlight if win8 and native interface exists · fbc9fe1b
      Aaron Lu 提交于
      According to Matthew Garrett, "Windows 8 leaves backlight control up
      to individual graphics drivers rather than making ACPI calls itself.
      There's plenty of evidence to suggest that the Intel driver for
      Windows [8] doesn't use the ACPI interface, including the fact that
      it's broken on a bunch of machines when the OS claims to support
      Windows 8.  The simplest thing to do appears to be to disable the
      ACPI backlight interface on these systems".
      
      So for Win8 systems, if there is native backlight control interface
      registered by GPU driver, ACPI video does not need to register its own.
      Since there are systems that don't work well with this approach, a
      parameter for video module named use_native_backlight is introduced and
      has the value of false by default. For users who have a broken ACPI
      video backlight interface, video.use_native_backlight=1 is needed in
      kernel cmdline.
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      fbc9fe1b
  7. 26 7月, 2013 2 次提交
  8. 18 7月, 2013 1 次提交
    • R
      ACPI / video / i915: No ACPI backlight if firmware expects Windows 8 · 8c5bd7ad
      Rafael J. Wysocki 提交于
      According to Matthew Garrett, "Windows 8 leaves backlight control up
      to individual graphics drivers rather than making ACPI calls itself.
      There's plenty of evidence to suggest that the Intel driver for
      Windows [8] doesn't use the ACPI interface, including the fact that
      it's broken on a bunch of machines when the OS claims to support
      Windows 8.  The simplest thing to do appears to be to disable the
      ACPI backlight interface on these systems".
      
      There's a problem with that approach, however, because simply
      avoiding to register the ACPI backlight interface if the firmware
      calls _OSI for Windows 8 may not work in the following situations:
       (1) The ACPI backlight interface actually works on the given system
           and the i915 driver is not loaded (e.g. another graphics driver
           is used).
       (2) The ACPI backlight interface doesn't work on the given system,
           but there is a vendor platform driver that will register its
           own, equally broken, backlight interface if not prevented from
           doing so by the ACPI subsystem.
      Therefore we need to allow the ACPI backlight interface to be
      registered until the i915 driver is loaded which then will unregister
      it if the firmware has called _OSI for Windows 8 (or will register
      the ACPI video driver without backlight support if not already
      present).
      
      For this reason, introduce an alternative function for registering
      ACPI video, acpi_video_register_with_quirks(), that will check
      whether or not the ACPI video driver has already been registered
      and whether or not the backlight Windows 8 quirk has to be applied.
      If the quirk has to be applied, it will block the ACPI backlight
      support and either unregister the backlight interface if the ACPI
      video driver has already been registered, or register the ACPI
      video driver without the backlight interface otherwise.  Make
      the i915 driver use acpi_video_register_with_quirks() instead of
      acpi_video_register() in i915_driver_load().
      
      This change is based on earlier patches from Matthew Garrett,
      Chun-Yi Lee and Seth Forshee and includes a fix from Aaron Lu's.
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=51231Tested-by: NAaron Lu <aaron.lu@intel.com>
      Tested-by: NIgor Gnatenko <i.gnatenko.brain@gmail.com>
      Tested-by: NYves-Alexis Perez <corsac@debian.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NAaron Lu <aaron.lu@intel.com>
      Acked-by: NMatthew Garrett <matthew.garrett@nebula.com>
      8c5bd7ad
  9. 28 6月, 2013 1 次提交
  10. 23 6月, 2013 1 次提交
  11. 14 5月, 2013 1 次提交
  12. 12 5月, 2013 2 次提交
    • R
      ACPI / processor: Use common hotplug infrastructure · ac212b69
      Rafael J. Wysocki 提交于
      Split the ACPI processor driver into two parts, one that is
      non-modular, resides in the ACPI core and handles the enumeration
      and hotplug of processors and one that implements the rest of the
      existing processor driver functionality.
      
      The non-modular part uses an ACPI scan handler object to enumerate
      processors on the basis of information provided by the ACPI namespace
      and to hook up with the common ACPI hotplug infrastructure.  It also
      populates the ACPI handle of each processor device having a
      corresponding object in the ACPI namespace, which allows the driver
      proper to bind to those devices, and makes the driver bind to them
      if it is readily available (i.e. loaded) when the scan handler's
      .attach() routine is running.
      
      There are a few reasons to make this change.
      
      First, switching the ACPI processor driver to using the common ACPI
      hotplug infrastructure reduces code duplication and size considerably,
      even though a new file is created along with a header comment etc.
      
      Second, since the common hotplug code attempts to offline devices
      before starting the (non-reversible) removal procedure, it will abort
      (and possibly roll back) hot-remove operations involving processors
      if cpu_down() returns an error code for one of them instead of
      continuing them blindly (if /sys/firmware/acpi/hotplug/force_remove
      is unset).  That is a more desirable behavior than what the current
      code does.
      
      Finally, the separation of the scan/hotplug part from the driver
      proper makes it possible to simplify the driver's .remove() routine,
      because it doesn't need to worry about the possible cleanup related
      to processor removal any more (the scan/hotplug part is responsible
      for that now) and can handle device removal and driver removal
      symmetricaly (i.e. as appropriate).
      
      Some user-visible changes in sysfs are made (for example, the
      'sysdev' link from the ACPI device node to the processor device's
      directory is gone and a 'physical_node' link is present instead
      and a corresponding 'firmware_node' is present in the processor
      device's directory, the processor driver is now visible under
      /sys/bus/cpu/drivers/ and bound to the processor device), but
      that shouldn't affect the functionality that users care about
      (frequency scaling, C-states and thermal management).
      
      Tested on my venerable Toshiba Portege R500.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NToshi Kani <toshi.kani@hp.com>
      ac212b69
    • R
      ACPI / hotplug: Use device offline/online for graceful hot-removal · 683058e3
      Rafael J. Wysocki 提交于
      Modify the generic ACPI hotplug code to be able to check if devices
      scheduled for hot-removal may be gracefully removed from the system
      using the device offline/online mechanism introduced previously.
      
      Namely, make acpi_scan_hot_remove() handling device hot-removal call
      device_offline() for all physical companions of the ACPI device nodes
      involved in the operation and check the results.  If any of the
      device_offline() calls fails, the function will not progress to the
      removal phase (which cannot be aborted), unless its (new) force
      argument is set (in case of a failing offline it will put the devices
      offlined by it back online).
      
      In support of 'forced' device hot-removal, add a new sysfs attribute
      'force_remove' that will reside under /sys/firmware/acpi/hotplug/.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NToshi Kani <toshi.kani@hp.com>
      683058e3
  13. 25 3月, 2013 1 次提交
  14. 22 3月, 2013 1 次提交
    • R
      ACPI / scan: Add special handler for Intel Lynxpoint LPSS devices · f58b082a
      Rafael J. Wysocki 提交于
      Devices on the Intel Lynxpoint Low Power Subsystem (LPSS) have some
      common features that aren't shared with any other platform devices,
      including the clock and LTR (Latency Tolerance Reporting) registers.
      It is better to handle those features in common code than to bother
      device drivers with doing that (I/O functionality-wise the LPSS
      devices are generally compatible with other devices that don't
      have those special registers and may be handled by the same drivers).
      
      The clock registers of the LPSS devices are now taken care of by
      the special clk-x86-lpss driver, but the MMIO mappings used for
      accessing those registers can also be used for accessing the LTR
      registers on those devices (LTR support for the Lynxpoint LPSS is
      going to be added by a subsequent patch).  Thus it is convenient
      to add a special ACPI scan handler for the Lynxpoint LPSS devices
      that will create the MMIO mappings for accessing the clock (and
      LTR in the future) registers and will register the LPSS devices'
      clocks, so the clk-x86-lpss driver will only need to take care of
      the main Lynxpoint LPSS clock.
      
      Introduce a special ACPI scan handler for Intel Lynxpoint LPSS
      devices as described above.  This also reduces overhead related to
      browsing the ACPI namespace in search of the LPSS devices before the
      registration of their clocks, removes some LPSS-specific (and
      somewhat ugly) code from acpi_platform.c and shrinks the overall code
      size slightly.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NMike Turquette <mturquette@linaro.org>
      f58b082a
  15. 04 3月, 2013 2 次提交
    • R
      ACPI / scan: Make memory hotplug driver use struct acpi_scan_handler · 0a347644
      Rafael J. Wysocki 提交于
      Make the ACPI memory hotplug driver use struct acpi_scan_handler
      for representing the object used to set up ACPI memory hotplug
      functionality and to remove hotplug memory ranges and data
      structures used by the driver before unregistering ACPI device
      nodes representing memory.  Register the new struct acpi_scan_handler
      object with the help of acpi_scan_add_handler_with_hotplug() to allow
      user space to manipulate the attributes of the memory hotplug
      profile.
      
      This results in a significant reduction of the drvier's code size
      and removes some ACPI hotplug code duplication.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      Tested-by: NToshi Kani <toshi.kani@hp.com>
      0a347644
    • R
      ACPI / hotplug: Introduce user space interface for hotplug profiles · 3f8055c3
      Rafael J. Wysocki 提交于
      Introduce user space interface for manipulating hotplug profiles
      associated with ACPI scan handlers.
      
      The interface consists of sysfs directories under
      /sys/firmware/acpi/hotplug/, one for each hotplug profile, containing
      an attribute allowing user space to manipulate the enabled field of
      the corresponding profile.  Namely, switching the enabled attribute
      from '0' to '1' will cause the common hotplug notify handler to be
      installed for all ACPI namespace objects representing devices matching
      the scan handler associated with the given hotplug profile (and
      analogously for the converse switch).
      
      Drivers willing to use the new user space interface should add their
      ACPI scan handlers with the help of new funtion
      acpi_scan_add_handler_with_hotplug().
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      Tested-by: NToshi Kani <toshi.kani@hp.com>
      3f8055c3
  16. 24 2月, 2013 1 次提交
    • R
      ACPI / PM: Take unusual configurations of power resources into account · b5d667eb
      Rafael J. Wysocki 提交于
      Commit d2e5f0c1 (ACPI / PCI: Rework the setup and cleanup of device
      wakeup) moved the initial disabling of system wakeup for PCI devices
      into a place where it can actually work and that exposed a hidden old
      issue with crap^Wunusual system designs where the same power
      resources are used for both wakeup power and device power control at
      run time.
      
      Namely, say there is one power resource such that the ACPI power
      state D0 of a PCI device depends on that power resource (i.e. the
      device is in D0 when that power resource is "on") and it is used
      as a wakeup power resource for the same device.  Then, calling
      acpi_pci_sleep_wake(pci_dev, false) for the device in question will
      cause the reference counter of that power resource to drop to 0,
      which in turn will cause it to be turned off.  As a result, the
      device will go into D3cold at that point, although it should have
      stayed in D0.
      
      As it turns out, that happens to USB controllers on some laptops
      and USB becomes unusable on those machines as a result, which is
      a major regression from v3.8.
      
      To fix this problem, (1) increment the reference counters of wakup
      power resources during their initialization if they are "on"
      initially, (2) prevent acpi_disable_wakeup_device_power() from
      decrementing the reference counters of wakeup power resources that
      were not enabled for wakeup power previously, and (3) prevent
      acpi_enable_wakeup_device_power() from incrementing the reference
      counters of wakeup power resources that already are enabled for
      wakeup power.
      
      In addition to that, if it is impossible to determine the initial
      states of wakeup power resources, avoid enabling wakeup for devices
      whose wakeup power depends on those power resources.
      Reported-by: NDave Jones <davej@redhat.com>
      Reported-by: NFabio Baltieri <fabio.baltieri@linaro.org>
      Tested-by: NFabio Baltieri <fabio.baltieri@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      b5d667eb
  17. 16 2月, 2013 1 次提交
  18. 13 2月, 2013 1 次提交
  19. 30 1月, 2013 3 次提交
  20. 26 1月, 2013 1 次提交
  21. 24 1月, 2013 2 次提交
  22. 20 1月, 2013 2 次提交
  23. 17 1月, 2013 6 次提交
    • R
      ACPI: Use system level attribute of wakeup power resources · 0596a52b
      Rafael J. Wysocki 提交于
      The system level attribute of ACPI power resources is the lowest
      system sleep level (S0, S2 etc.) in which the given resource can be
      "on" (ACPI 5.0, Section 7.1).  On the other hand, wakeup power
      resources have to be "on" for devices depending on them to be able to
      signal wakeup.  Therefore devices cannot wake up the system from
      sleep states higher than the minimum of the system level attributes
      of their wakeup power resources.
      
      Use the wakeup power resources' system level values to get the
      deepest system sleep state (highest system sleep level) the given
      device can wake up the system from.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0596a52b
    • R
      ACPI: Take power resource initialization errors into account · e88c9c60
      Rafael J. Wysocki 提交于
      Some ACPI power resource initialization errors, like memory
      allocation errors, are not taken into account appropriately in some
      cases, which may lead to a device having an incomplete list of power
      resources that one of its power states depends on, for one example.
      
      Rework the power resource initialization and namespace scanning code
      so that power resource initialization errors are treated more
      seriously.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e88c9c60
    • R
      ACPI / scan: Consolidate extraction of power resources lists · ef85bdbe
      Rafael J. Wysocki 提交于
      The lists of ACPI power resources are currently extracted in two
      different ways, one for wakeup power resources and one for power
      resources that device power states depend on.  There is no reason
      why it should be done differently in those two cases, so introduce
      a common routine for extracting power resources lists from data
      returned by AML, acpi_extract_power_resources(), and make the
      namespace scanning code use it for both wakeup and device power
      states power resources.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ef85bdbe
    • R
      ACPI / PM: Take order attribute of power resources into account · 0b224527
      Rafael J. Wysocki 提交于
      ACPI power resources have an order attribute that should be taken
      into account when turning them on and off, but it is not used now.
      
      Modify the power resources management code to preserve the
      spec-compliant ordering of power resources that power states of
      devices depend on (analogous changes will be done separately for
      power resources used for wakeup).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0b224527
    • R
      ACPI / scan: Treat power resources in a special way · 82c7d5ef
      Rafael J. Wysocki 提交于
      ACPI power resources need to be treated in a special way by the
      namespace scanning code, because they need to be ready to use as
      soon as they have been discovered (even before registering ACPI
      device nodes using them for power management).
      
      For this reason, it doesn't make sense to separate the preparation
      of struct acpi_device objects representing them in the device
      hierarchy from the creation of struct acpi_power_resource objects
      actually used for power resource manipulation.  Accordingly, it
      doesn't make sense to define non-empty .add() and .remove() callbacks
      in the power resources "driver" (in fact, it is questionable whether
      or not it is useful to register such a "driver" at all).
      
      Rearrange the code in scan.c and power.c so that power resources are
      initialized entirely by one routine, acpi_add_power_resource(), that
      also prepares their struct acpi_device objects and registers them
      with the driver core, telling it to use a special release routine,
      acpi_release_power_resource(), for removing objects that represent
      power resources from memory.  Make the ACPI namespace scanning code
      in scan.c always use acpi_add_power_resource() for preparing and
      registering objects that represent power resources.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      82c7d5ef
    • R
      ACPI / PM: Rework the handling of devices depending on power resources · bc9b6407
      Rafael J. Wysocki 提交于
      Commit 0090def6 (ACPI: Add interface to register/unregister device
      to/from power resources) made it possible to indicate to the ACPI
      core that if the given device depends on any power resources, then
      it should be resumed as soon as all of the power resources required
      by it to transition to the D0 power state have been turned on.
      
      Unfortunately, however, this was a mistake, because all devices
      depending on power resources should be treated this way (i.e. they
      should be resumed when all power resources required by their D0
      state have been turned on) and for the majority of those devices
      the ACPI core can figure out by itself which (physical) devices
      depend on what power resources.
      
      For this reason, replace the code added by commit 0090def6 with a
      new, much more straightforward, mechanism that will be used
      internally by the ACPI core and remove all references to that code
      from kernel subsystems using ACPI.
      
      For the cases when there are (physical) devices that should be
      resumed whenever a not directly related ACPI device node goes into
      D0 as a result of power resources configuration changes, like in
      the SATA case, add two new routines, acpi_dev_pm_add_dependent()
      and acpi_dev_pm_remove_dependent(), allowing subsystems to manage
      such dependencies.  Convert the SATA subsystem to use the new
      functions accordingly.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      bc9b6407