1. 17 1月, 2013 5 次提交
    • 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: Do not use device power states of power resources · 722c929f
      Rafael J. Wysocki 提交于
      ACPI power resource objects have struct acpi_device components, but
      they are only used for registering those resources in the device
      hierarchy.  In particular, power state information stored in them is
      completely useless (amnong other things, because the power resources
      "devices" are not power manageable), so there is no reason for the
      power resources management code to keep it up to date.
      
      Remove the code updating device power states of power resources from
      drivers/acpi/power.c.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      722c929f
    • R
      ACPI: Drop power resources driver · 781d737c
      Rafael J. Wysocki 提交于
      The ACPI power resources driver is not very useful, because the only
      thing it really does is to restore the state of the power resources
      that were "on" before system suspend or hibernation, but that may be
      achieved in a different way.
      
      Drop the ACPI power resources driver entirely and add
      acpi_resume_power_resources() that will walk the list of all
      registered power resources during system resume and turn on the ones
      that were "on" before the preceding system suspend or hibernation.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      781d737c
    • 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
  2. 03 1月, 2013 1 次提交
    • R
      ACPI / power: Remove useless message from device registering routine · 0271f4f1
      Rafael J. Wysocki 提交于
      After commit 71fbad6c (PCI/ACPI: Notify PCI devices when their power
      resource is turned on) made acpi_pci_bind() call
      acpi_power_resource_register_device(), the debug message at the end
      of the latter appears in the kernel log for every PCI device that
      doesn't happen to have power resources assigned (which is the vast
      majority of them).  However, this message is totally useless, because
      it doesn't even say which device it is about.  Moreover, it is
      misleading, because it only means that the given device has no power
      resources, which isn't exceptional at all.
      
      Remove that useless message altogether and simplify
      acpi_power_resource_register_device() slightly.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0271f4f1
  3. 15 11月, 2012 1 次提交
  4. 15 9月, 2012 1 次提交
  5. 14 9月, 2012 1 次提交
    • L
      ACPI / PM: Fix resource_lock dead lock in acpi_power_on_device · 40bf66ec
      Lin Ming 提交于
      Commit 0090def6("ACPI: Add interface to register/unregister device
      to/from power resources") used resource_lock to protect the devices list
      that relies on power resource. It caused a mutex dead lock, as below
      
          acpi_power_on ---> lock resource_lock
            __acpi_power_on
              acpi_power_on_device
                acpi_power_get_inferred_state
                  acpi_power_get_list_state ---> lock resource_lock
      
      This patch adds a new mutex "devices_lock" to protect the devices list
      and calls acpi_power_on_device in acpi_power_on, instead of
      __acpi_power_on, after the resource_lock is released.
      
      [rjw: Changed data type of a boolean variable to bool.]
      Signed-off-by: NLin Ming <ming.m.lin@intel.com>
      Signed-off-by: NAaron Lu <aaron.lu@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      40bf66ec
  6. 10 8月, 2012 1 次提交
  7. 01 7月, 2012 1 次提交
  8. 29 6月, 2012 1 次提交
  9. 30 5月, 2012 1 次提交
    • R
      ACPI / PM: Make __acpi_bus_get_power() cover D3cold correctly · 38c92fff
      Rafael J. Wysocki 提交于
      After recent changes of the ACPI device power states definitions, if
      power resources are not used for the device's power management, the
      state returned by __acpi_bus_get_power() cannot exceed D3hot, because
      the return values of _PSC are 0 through 3.  However, if the _PR3
      method is not present for the device and _PS3 returns 3, we have to
      assume that the device is in D3cold, so the value returned by
      __acpi_bus_get_power() in that case should be 4.
      
      Similarly, acpi_power_get_inferred_state() should take the power
      resources for the D3hot state into account in general, so that it
      can return 3 if those resources are "on" or 4 (D3cold) otherwise.
      
      Fix the the above two issues and make sure that if both _PSC and
      _PR3 are present for the device, the power resources listed by _PR3
      will be used to determine if the number 3 returned by _PSC is meant
      to represent D3cold or D3hot.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      38c92fff
  10. 18 5月, 2012 1 次提交
    • R
      ACPI / PCI / PM: Fix device PM regression related to D3hot/D3cold · 5c7dd710
      Rafael J. Wysocki 提交于
      Commit 1cc0c998 ("ACPI: Fix D3hot v D3cold confusion") introduced a
      bug in __acpi_bus_set_power() and changed the behavior of
      acpi_pci_set_power_state() in such a way that it generally doesn't work
      as expected if PCI_D3hot is passed to it as the second argument.
      
      First off, if ACPI_STATE_D3 (equal to ACPI_STATE_D3_COLD) is passed to
      __acpi_bus_set_power() and the explicit_set flag is set for the D3cold
      state, the function will try to execute AML method called "_PS4", which
      doesn't exist.
      
      Fix this by adding a check to ensure that the name of the AML method
      to execute for transitions to ACPI_STATE_D3_COLD is correct in
      __acpi_bus_set_power().  Also make sure that the explicit_set flag
      for ACPI_STATE_D3_COLD will be set if _PS3 is present and modify
      acpi_power_transition() to avoid accessing power resources for
      ACPI_STATE_D3_COLD, because they don't exist.
      
      Second, if PCI_D3hot is passed to acpi_pci_set_power_state() as the
      target state, the function will request a transition to
      ACPI_STATE_D3_HOT instead of ACPI_STATE_D3.  However,
      ACPI_STATE_D3_HOT is now only marked as supported if the _PR3 AML
      method is defined for the given device, which is rare.  This causes
      problems to happen on systems where devices were successfully put
      into ACPI D3 by pci_set_power_state(PCI_D3hot) which doesn't work
      now.  In particular, some unused graphics adapters are not turned
      off as a result.
      
      To fix this issue restore the old behavior of
      acpi_pci_set_power_state(), which is to request a transition to
      ACPI_STATE_D3 (equal to ACPI_STATE_D3_COLD) if either PCI_D3hot or
      PCI_D3cold is passed to it as the argument.
      
      This approach is not ideal, because generally power should not
      be removed from devices if PCI_D3hot is the target power state,
      but since this behavior is relied on, we have no choice but to
      restore it at the moment and spend more time on designing a
      better solution in the future.
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=43228Reported-by: Nrocko <rockorequin@hotmail.com>
      Reported-by: NCristian Rodríguez <crrodriguez@opensuse.org>
      Reported-and-tested-by: NPeter <lekensteyn@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5c7dd710
  11. 05 5月, 2012 1 次提交
    • L
      ACPI: Fix D3hot v D3cold confusion · 1cc0c998
      Lin Ming 提交于
      Before this patch, ACPI_STATE_D3 incorrectly referenced D3hot
      in some places, but D3cold in other places.
      
      After this patch, ACPI_STATE_D3 always means ACPI_STATE_D3_COLD;
      and all references to D3hot use ACPI_STATE_D3_HOT.
      
      ACPI's _PR3 method is used to enter both D3hot and D3cold states.
      What distinguishes D3hot from D3cold is the presence _PR3
      (Power Resources for D3hot)  If these resources are all ON,
      then the state is D3hot.  If _PR3 is not present,
      or all _PR0 resources for the devices are OFF,
      then the state is D3cold.
      
      This patch applies after Linux-3.4-rc1.
      A future syntax cleanup may remove ACPI_STATE_D3
      to emphasize that it always means ACPI_STATE_D3_COLD.
      Signed-off-by: NLin Ming <ming.m.lin@intel.com>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NAaron Lu <aaron.lu@amd.com>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      1cc0c998
  12. 30 3月, 2012 2 次提交
  13. 12 1月, 2011 6 次提交
  14. 02 12月, 2010 2 次提交
  15. 23 10月, 2010 1 次提交
    • R
      ACPI / PM: Fix reference counting of power resources · 3e384ee6
      Rafael J. Wysocki 提交于
      The reference counting of ACPI power resources is currently broken
      for a few reasons.  First, instead of using a simple reference
      counter per power resource it uses a list of objects representing
      refereces to the given power resource from devices.  This leads to
      the second breakage, because it prevents power resources from
      being referenced more than once by one device, which is necessary
      if the device is configured to signal wakeup.  Namely, when putting
      the device into a low power state we first call
      acpi_enable_wakeup_device_power() that should reference count power
      resources needed for signaling wakeup and then we call
      acpi_power_transition() to power off the device.  The latter call
      drops references to the device's power resources, possibly including
      the ones added by acpi_enable_wakeup_device_power(), so the device
      can't signal wakeup as a result.  Apart from this, the locking
      in acpi_power_on() and acpi_power_off_device() doesn't prevent
      all possible races from happening, which may be problematic for
      runtime PM and asynchronous suspend and resume.
      
      Fix the problem by using a counter for power resources reference
      counting and putting the evaluation of ACPI _ON and _OFF methods
      under the power resource mutex.
      Reported-by: NMatthew Garrett <mjg@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      3e384ee6
  16. 15 8月, 2010 2 次提交
  17. 01 4月, 2010 1 次提交
  18. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  19. 17 1月, 2010 1 次提交
    • M
      acpi: make ACPI device id constant · c97adf9e
      Márton Németh 提交于
      The ids field of the struct acpi_driver is constant in <linux/acpi/acpi_bus.h>
      so it is worth to make the initialization data also constant.
      
      The semantic match that finds this kind of pattern is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @r@
      disable decl_init,const_decl_init;
      identifier I1, I2, x;
      @@
      	struct I1 {
      	  ...
      	  const struct I2 *x;
      	  ...
      	};
      @s@
      identifier r.I1, y;
      identifier r.x, E;
      @@
      	struct I1 y = {
      	  .x = E,
      	};
      @c@
      identifier r.I2;
      identifier s.E;
      @@
      	const struct I2 E[] = ... ;
      @depends on !c@
      identifier r.I2;
      identifier s.E;
      @@
      +	const
      	struct I2 E[] = ...;
      // </smpl>
      Signed-off-by: NMárton Németh <nm127@freemail.hu>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: cocci@diku.dk
      Signed-off-by: NLen Brown <len.brown@intel.com>
      c97adf9e
  20. 10 9月, 2009 1 次提交
    • R
      ACPI PM: Replace wakeup.prepared with reference counter · 9b83ccd2
      Rafael J. Wysocki 提交于
      The wakeup.prepared flag is used for marking devices that have the
      wake-up power already enabled, so that the wake-up power is not
      enabled twice in a row for the same device.  This assumes, however,
      that device wake-up power will only be enabled once, while the device
      is being prepared for a system-wide sleep transition, and the second
      attempt is made by acpi_enable_wakeup_device_prep().
      
      With the upcoming PCI wake-up rework this assumption will not hold
      any more for PCI bridges and the root bridge whose wake-up power
      may be enabled as a result of wake-up enable propagation from other
      devices (eg. add-on devices that are not associated with any GPEs).
      Thus, there may be many attempts to enable wake-up power on a PCI
      bridge or the root bridge during a system power state transition
      and it's better to replace wakeup.prepared with a reference counter.
      Reviewed-by: NMatthew Garrett <mjg59@srcf.ucam.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      9b83ccd2
  21. 29 8月, 2009 1 次提交
  22. 28 5月, 2009 1 次提交
  23. 03 4月, 2009 1 次提交
  24. 28 3月, 2009 1 次提交
  25. 31 12月, 2008 1 次提交
  26. 08 11月, 2008 1 次提交
  27. 28 10月, 2008 2 次提交