1. 12 7月, 2011 4 次提交
    • R
      PM / Domains: Allow callbacks to execute all runtime PM helpers · c6d22b37
      Rafael J. Wysocki 提交于
      A deadlock may occur if one of the PM domains' .start_device() or
      .stop_device() callbacks or a device driver's .runtime_suspend() or
      .runtime_resume() callback executed by the core generic PM domain
      code uses a "wrong" runtime PM helper function.  This happens, for
      example, if .runtime_resume() from one device's driver calls
      pm_runtime_resume() for another device in the same PM domain.
      A similar situation may take place if a device's parent is in the
      same PM domain, in which case the runtime PM framework may execute
      pm_genpd_runtime_resume() automatically for the parent (if it is
      suspended at the moment).  This, of course, is undesirable, so
      the generic PM domains code should be modified to prevent it from
      happening.
      
      The runtime PM framework guarantees that pm_genpd_runtime_suspend()
      and pm_genpd_runtime_resume() won't be executed in parallel for
      the same device, so the generic PM domains code need not worry
      about those cases.  Still, it needs to prevent the other possible
      race conditions between pm_genpd_runtime_suspend(),
      pm_genpd_runtime_resume(), pm_genpd_poweron() and pm_genpd_poweroff()
      from happening and it needs to avoid deadlocks at the same time.
      To this end, modify the generic PM domains code to relax
      synchronization rules so that:
      
      * pm_genpd_poweron() doesn't wait for the PM domain status to
        change from GPD_STATE_BUSY.  If it finds that the status is
        not GPD_STATE_POWER_OFF, it returns without powering the domain on
        (it may modify the status depending on the circumstances).
      
      * pm_genpd_poweroff() returns as soon as it finds that the PM
        domain's status changed from GPD_STATE_BUSY after it's released
        the PM domain's lock.
      
      * pm_genpd_runtime_suspend() doesn't wait for the PM domain status
        to change from GPD_STATE_BUSY after executing the domain's
        .stop_device() callback and executes pm_genpd_poweroff() only
        if pm_genpd_runtime_resume() is not executed in parallel.
      
      * pm_genpd_runtime_resume() doesn't wait for the PM domain status
        to change from GPD_STATE_BUSY after executing pm_genpd_poweron()
        and sets the domain's status to GPD_STATE_BUSY and increments its
        counter of resuming devices (introduced by this change) immediately
        after acquiring the lock.  The counter of resuming devices is then
        decremented after executing __pm_genpd_runtime_resume() for the
        device and the domain's status is reset to GPD_STATE_ACTIVE (unless
        there are more resuming devices in the domain, in which case the
        status remains GPD_STATE_BUSY).
      
      This way, for example, if a device driver's .runtime_resume()
      callback executes pm_runtime_resume() for another device in the same
      PM domain, pm_genpd_poweron() called by pm_genpd_runtime_resume()
      invoked by the runtime PM framework will not block and it will see
      that there's nothing to do for it.  Next, the PM domain's lock will
      be acquired without waiting for its status to change from
      GPD_STATE_BUSY and the device driver's .runtime_resume() callback
      will be executed.  In turn, if pm_runtime_suspend() is executed by
      one device driver's .runtime_resume() callback for another device in
      the same PM domain, pm_genpd_poweroff() executed by
      pm_genpd_runtime_suspend() invoked by the runtime PM framework as a
      result will notice that one of the devices in the domain is being
      resumed, so it will return immediately.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      c6d22b37
    • R
      PM / Domains: Do not execute device callbacks under locks · 17b75eca
      Rafael J. Wysocki 提交于
      Currently, the .start_device() and .stop_device() callbacks from
      struct generic_pm_domain() as well as the device drivers' runtime PM
      callbacks used by the generic PM domains code are executed under
      the generic PM domain lock.  This, unfortunately, is prone to
      deadlocks, for example if a device and its parent are boths members
      of the same PM domain.  For this reason, it would be better if the
      PM domains code didn't execute device callbacks under the lock.
      
      Rework the locking in the generic PM domains code so that the lock
      is dropped for the execution of device callbacks.  To this end,
      introduce PM domains states reflecting the current status of a PM
      domain and such that the PM domain lock cannot be acquired if the
      status is GPD_STATE_BUSY.  Make threads attempting to acquire a PM
      domain's lock wait until the status changes to either
      GPD_STATE_ACTIVE or GPD_STATE_POWER_OFF.
      
      This change by itself doesn't fix the deadlock problem mentioned
      above, but the mechanism introduced by it will be used for for this
      purpose by a subsequent patch.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      17b75eca
    • R
      PM / Domains: Make failing pm_genpd_prepare() clean up properly · b6c10c84
      Rafael J. Wysocki 提交于
      If pm_generic_prepare() in pm_genpd_prepare() returns error code,
      the PM domains counter of "prepared" devices should be decremented
      and its suspend_power_off flag should be reset if this counter drops
      down to zero.  Otherwise, the PM domain runtime PM code will not
      handle the domain correctly (it will permanently think that system
      suspend is in progress).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      b6c10c84
    • R
      PM / Domains: Set device state to "active" during system resume · 6f00ff78
      Rafael J. Wysocki 提交于
      The runtime PM status of devices in a power domain that is not
      powered off in pm_genpd_complete() should be set to "active", because
      those devices are operational at this point.  Some of them may not be
      in use, though, so make pm_genpd_complete() call pm_runtime_idle()
      in addition to pm_runtime_set_active() for each of them.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      6f00ff78
  2. 10 7月, 2011 7 次提交
  3. 02 7月, 2011 20 次提交
  4. 01 7月, 2011 7 次提交
  5. 30 6月, 2011 2 次提交
    • K
      xen/pci: Use the INT_SRC_OVR IRQ (instead of GSI) to preset the ACPI SCI IRQ. · 155a16f2
      Konrad Rzeszutek Wilk 提交于
      In the past we would use the GSI value to preset the ACPI SCI
      IRQ which worked great as GSI == IRQ:
      
      ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level)
      
      While that is most often seen, there are some oddities:
      
      ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low level)
      
      which means that GSI 20 (or pin 20) is to be overriden for IRQ 9.
      Our code that presets the interrupt for ACPI SCI however would
      use the GSI 20 instead of IRQ 9 ending up with:
      
      xen: sci override: global_irq=20 trigger=0 polarity=1
      xen: registering gsi 20 triggering 0 polarity 1
      xen: --> pirq=20 -> irq=20
      xen: acpi sci 20
      .. snip..
      calling  acpi_init+0x0/0xbc @ 1
      ACPI: SCI (IRQ9) allocation failed
      ACPI Exception: AE_NOT_ACQUIRED, Unable to install System Control Interrupt handler (20110413/evevent-119)
      ACPI: Unable to start the ACPI Interpreter
      
      as the ACPI interpreter made a call to 'acpi_gsi_to_irq' which got nine.
      It used that value to request an IRQ (request_irq) and since that was not
      present it failed.
      
      The fix is to recognize that for interrupts that are overriden (in our
      case we only care about the ACPI SCI) we should use the IRQ number
      to present the IRQ instead of the using GSI. End result is that we get:
      
      xen: sci override: global_irq=20 trigger=0 polarity=1
      xen: registering gsi 20 triggering 0 polarity 1
      xen: --> pirq=20 -> irq=9 (gsi=9)
      xen: acpi sci 9
      
      which fixes the ACPI interpreter failing on startup.
      
      CC: stable@kernel.org
      Reported-by: NLiwei <xieliwei@gmail.com>
      Tested-by: NLiwei <xieliwei@gmail.com>
      [http://lists.xensource.com/archives/html/xen-devel/2011-06/msg01727.html]
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      155a16f2
    • K
      xen/mmu: Fix for linker errors when CONFIG_SMP is not defined. · 32dd1194
      Konrad Rzeszutek Wilk 提交于
      Simple enough - we use an extern defined symbol which is not
      defined when CONFIG_SMP is not defined. This fixes the linker
      dying.
      
      CC: stable@kernel.org
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      32dd1194