1. 26 1月, 2013 1 次提交
    • Y
      PCI: Skip attaching driver in device_add() · 58d9a38f
      Yinghai Lu 提交于
      We want to add PCI devices to the device tree as early as possible but
      delay attaching drivers.
      
      device_add() adds a device to the device hierarchy and (via
      device_attach()) attaches a matching driver and calls its .probe() method.
      We want to separate adding the device to the hierarchy from attaching the
      driver.
      
      This patch does that by adding "match_driver" in struct pci_dev.  When
      false, we return failure from pci_bus_match(), which makes device_attach()
      believe there's no matching driver.
      
      Later, we set "match_driver = true" and call device_attach() again, which
      now attaches the driver and calls its .probe() method.
      
      [bhelgaas: changelog, explicitly init dev->match_driver,
      fold device_attach() call into pci_bus_add_device()]
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      58d9a38f
  2. 05 12月, 2012 1 次提交
    • H
      PCI/PM: Keep runtime PM enabled for unbound PCI devices · 967577b0
      Huang Ying 提交于
      For unbound PCI devices, what we need is:
      
       - Always in D0 state, because some devices do not work again after
         being put into D3 by the PCI bus.
      
       - In SUSPENDED state if allowed, so that the parent devices can still
         be put into low power state.
      
      To satisfy these requirements, the runtime PM for the unbound PCI
      devices are disabled and set to SUSPENDED state.  One issue of this
      solution is that the PCI devices will be put into SUSPENDED state even
      if the SUSPENDED state is forbidden via the sysfs interface
      (.../power/control) of the device.  This is not an issue for most
      devices, because most PCI devices are not used at all if unbound.
      But there are exceptions.  For example, unbound VGA card can be used
      for display, but suspending its parents makes it stop working.
      
      To fix the issue, we keep the runtime PM enabled when the PCI devices
      are unbound.  But the runtime PM callbacks will do nothing if the PCI
      devices are unbound.  This way, we can put the PCI devices into
      SUSPENDED state without putting the PCI devices into D3 state.
      
      Reference: https://bugzilla.kernel.org/show_bug.cgi?id=48201Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      CC: stable@vger.kernel.org          # v3.6+
      967577b0
  3. 29 11月, 2012 2 次提交
  4. 08 11月, 2012 1 次提交
    • D
      PCI: Don't touch card regs after runtime suspend D3 · 42eca230
      Dave Airlie 提交于
      If the driver takes care of state saving, don't touch any registers on it.
      
      Optimus (dual-gpu) laptops seem to have their own form of D3cold, but
      unfortunately enter it on normal D3 transitions via the ACPI callback.
      
      So when we use runtime PM to transition to D3, the card disappears off
      the PCI bus, however we then try to access registers on it in the
      runtime suspend finish, which really doesn't work.
      
      This patch checks whether the pci state is saved and doesn't attempt to hit
      any registers after that point if it is.
      
      (Looks okay to Rafael)
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      42eca230
  5. 03 11月, 2012 1 次提交
  6. 20 9月, 2012 1 次提交
    • A
      PM: Prevent runtime suspend during system resume · 88d26136
      Alan Stern 提交于
      This patch (as1591) moves the pm_runtime_get_noresume() and
      pm_runtime_put_sync() calls from __device_suspend() and
      device_resume() to device_prepare() and device_complete() in the PM
      core.
      
      The reason for doing this is to make sure that parent devices remain
      at full power (i.e., don't go into runtime suspend) while their
      children are being resumed from a system sleep.
      
      The PCI core already contained equivalent code to serve the same
      purpose.  The patch removes the duplicated code, since it is no longer
      needed.  One of the comments from the PCI core gets moved into the PM
      core, and a second comment is added to explain whe the _get_noresume
      and _put_sync calls are present.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      88d26136
  7. 18 9月, 2012 1 次提交
  8. 22 8月, 2012 1 次提交
  9. 16 8月, 2012 1 次提交
  10. 11 7月, 2012 1 次提交
    • A
      PCI: EHCI: fix crash during suspend on ASUS computers · dbf0e4c7
      Alan Stern 提交于
      Quite a few ASUS computers experience a nasty problem, related to the
      EHCI controllers, when going into system suspend.  It was observed
      that the problem didn't occur if the controllers were not put into the
      D3 power state before starting the suspend, and commit
      151b6128 (USB: EHCI: fix crash during
      suspend on ASUS computers) was created to do this.
      
      It turned out this approach messed up other computers that didn't have
      the problem -- it prevented USB wakeup from working.  Consequently
      commit c2fb8a3f (USB: add
      NO_D3_DURING_SLEEP flag and revert 151b6128) was merged; it
      reverted the earlier commit and added a whitelist of known good board
      names.
      
      Now we know the actual cause of the problem.  Thanks to AceLan Kao for
      tracking it down.
      
      According to him, an engineer at ASUS explained that some of their
      BIOSes contain a bug that was added in an attempt to work around a
      problem in early versions of Windows.  When the computer goes into S3
      suspend, the BIOS tries to verify that the EHCI controllers were first
      quiesced by the OS.  Nothing's wrong with this, but the BIOS does it
      by checking that the PCI COMMAND registers contain 0 without checking
      the controllers' power state.  If the register isn't 0, the BIOS
      assumes the controller needs to be quiesced and tries to do so.  This
      involves making various MMIO accesses to the controller, which don't
      work very well if the controller is already in D3.  The end result is
      a system hang or memory corruption.
      
      Since the value in the PCI COMMAND register doesn't matter once the
      controller has been suspended, and since the value will be restored
      anyway when the controller is resumed, we can work around the BIOS bug
      simply by setting the register to 0 during system suspend.  This patch
      (as1590) does so and also reverts the second commit mentioned above,
      which is now unnecessary.
      
      In theory we could do this for every PCI device.  However to avoid
      introducing new problems, the patch restricts itself to EHCI host
      controllers.
      
      Finally the affected systems can suspend with USB wakeup working
      properly.
      
      Reference: https://bugzilla.kernel.org/show_bug.cgi?id=37632
      Reference: https://bugzilla.kernel.org/show_bug.cgi?id=42728Based-on-patch-by: NAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NDâniel Fraga <fragabr@gmail.com>
      Tested-by: NJavier Marcet <jmarcet@gmail.com>
      Tested-by: NAndrey Rahmatullin <wrar@wrar.name>
      Tested-by: NOleksij Rempel <bug-track@fisher-privat.net>
      Tested-by: NPavel Pisa <pisa@cmp.felk.cvut.cz>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dbf0e4c7
  11. 06 7月, 2012 1 次提交
    • R
      PCI / PM: restore the original behavior of pci_set_power_state() · db288c9c
      Rafael J. Wysocki 提交于
      Commit cc2893b6 (PCI: Ensure we re-enable devices on resume)
      addressed the problem with USB not being powered after resume on
      recent Lenovo machines, but it did that in a suboptimal way.
      Namely, it should have changed the relevant code paths only,
      which are pci_pm_resume_noirq() and pci_pm_restore_noirq() supposed
      to restore the device's power and standard configuration registers
      after system resume from suspend or hibernation.  Instead, however,
      it modified pci_set_power_state() which is executed in several
      other situations too.  That resulted in some undesirable effects,
      like attempting to change a device's power state in the same way
      multiple times in a row (up to as many as 4 times in a row in the
      snd_hda_intel driver).
      
      Fix the bug addressed by commit cc2893b6 in an alternative way,
      by forcibly powering up all devices in pci_pm_default_resume_early(),
      which is called by pci_pm_resume_noirq() and pci_pm_restore_noirq()
      to restore the device's power and standard configuration registers,
      and modifying pci_pm_runtime_resume() to avoid the forcible power-up
      if not necessary.  Then, revert the changes made by commit cc2893b6
      to make the confusion introduced by it go away.
      Acked-by: NMatthew Garrett <mjg@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      db288c9c
  12. 24 6月, 2012 1 次提交
    • H
      PCI/PM: add PCIe runtime D3cold support · 448bd857
      Huang Ying 提交于
      This patch adds runtime D3cold support and corresponding ACPI platform
      support.  This patch only enables runtime D3cold support; it does not
      enable D3cold support during system suspend/hibernate.
      
      D3cold is the deepest power saving state for a PCIe device, where its main
      power is removed.  While it is in D3cold, you can't access the device at
      all, not even its configuration space (which is still accessible in D3hot).
      Therefore the PCI PM registers can not be used to transition into/out of
      the D3cold state; that must be done by platform logic such as ACPI _PR3.
      
      To support wakeup from D3cold, a system may provide auxiliary power, which
      allows a device to request wakeup using a Beacon or the sideband WAKE#
      signal.  WAKE# is usually connected to platform logic such as ACPI GPE.
      This is quite different from other power saving states, where devices
      request wakeup via a PME message on the PCIe link.
      
      Some devices, such as those in plug-in slots, have no direct platform
      logic.  For example, there is usually no ACPI _PR3 for them.  D3cold
      support for these devices can be done via the PCIe Downstream Port leading
      to the device.  When the PCIe port is powered on/off, the device is powered
      on/off too.  Wakeup events from the device will be notified to the
      corresponding PCIe port.
      
      For more information about PCIe D3cold and corresponding ACPI support,
      please refer to:
      
      - PCI Express Base Specification Revision 2.0
      - Advanced Configuration and Power Interface Specification Revision 5.0
      
      [bhelgaas: changelog]
      Reviewed-by: NRafael J. Wysocki <rjw@sisk.pl>
      Originally-by: NZheng Yan <zheng.z.yan@intel.com>
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      448bd857
  13. 05 5月, 2012 1 次提交
    • K
      PCI: disable Bus Master on PCI device shutdown · b566a22c
      Khalid Aziz 提交于
      Disable Bus Master bit on the device in pci_device_shutdown() to ensure PCI
      devices do not continue to DMA data after shutdown.  This can cause memory
      corruption in case of a kexec where the current kernel shuts down and
      transfers control to a new kernel while a PCI device continues to DMA to
      memory that does not belong to it any more in the new kernel.
      
      I have tested this code on two laptops, two workstations and a 16-socket
      server.  kexec worked correctly on all of them.
      Signed-off-by: NKhalid Aziz <khalid.aziz@hp.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      b566a22c
  14. 18 2月, 2012 1 次提交
    • R
      PCI / PM: Disable wakeup during shutdown for devices not enabled to wake up · 5b415f1e
      Rafael J. Wysocki 提交于
      If a PCI device is enabled to generate wakeup signals (PME) when put
      into a low-power state by runtime PM, it will be still enabled to
      generate those signals after the system shutdown, unless its driver's
      .shutdown() callback takes care of the wakeup signals generation
      setting.  Moreover, there are devices that are not enabled to wake
      up the system and that are configured by runtime PM to generate
      wakeup signals so that (runtime) remote wakeup works with them.
      Those devices should be reconfigured during system shutdown so that
      they don't generate wakeup signals, but at least some drivers don't
      do that.  However, that very well may be done by the PCI core so
      that drivers don't have to worry about it.  For this reason, modify
      pci_device_shutdown() to disable the generation of wakeup events for
      devices not supposed to wake up the system.
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=37952Reported-and-tested-by: NKamil Iskra <kamil.54002@iskra.name>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      5b415f1e
  15. 27 1月, 2012 1 次提交
  16. 25 1月, 2012 1 次提交
    • A
      Dynamic ID addition doesn't need get_driver() · cef9bc56
      Alan Stern 提交于
      As part of the removal of get_driver()/put_driver(), this patch
      (as1511) changes all the places that add dynamic IDs for drivers.
      Since these additions are done by writing to the drivers' sysfs
      attribute files, and the attributes are removed when the drivers are
      unregistered, there is no reason to take an extra reference to the
      drivers.
      
      The one exception is the pci-stub driver, which calls pci_add_dynid()
      as part of its registration.  But again, there's no reason to take an
      extra reference here, because the driver can't be unloaded while it is
      being registered.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      CC: Jiri Kosina <jkosina@suse.cz>
      CC: Jesse Barnes <jbarnes@virtuousgeek.org>
      CC: Dominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      cef9bc56
  17. 07 1月, 2012 1 次提交
  18. 06 7月, 2011 1 次提交
    • R
      PCI / PM: Detect early wakeup in pci_pm_prepare() · eea3fc03
      Rafael J. Wysocki 提交于
      A subsequent patch is going to move the invocation of
      pm_runtime_barrier() from dpm_prepare() to __device_suspend().
      Consequently, early wakeup events resulting from runtime resume
      requests for wakeup devices queued up right before system suspend
      will only be detected after all of the subsystem-level .prepare()
      callbacks have run.  However, the PCI bus type calls
      pm_runtime_get_sync() from its pci_pm_prepare() callback routine,
      so it would destroy the early wakeup events information regarding PCI
      devices.  To prevent this from happening add an early wakeup
      detection mechanism, analogous to the one currently in dpm_prepare(),
      to pci_pm_prepare().
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      eea3fc03
  19. 22 6月, 2011 1 次提交
    • R
      PCI / PM: Block races between runtime PM and system sleep · a5f76d5e
      Rafael J. Wysocki 提交于
      After commit e8665002
      (PM: Allow pm_runtime_suspend() to succeed during system suspend) it
      is possible that a device resumed by the pm_runtime_resume(dev) in
      pci_pm_prepare() will be suspended immediately from a work item,
      timer function or otherwise, defeating the very purpose of calling
      pm_runtime_resume(dev) from there.  To prevent that from happening
      it is necessary to increment the runtime PM usage counter of the
      device by replacing pm_runtime_resume() with pm_runtime_get_sync().
      Moreover, the incremented runtime PM usage counter has to be
      decremented by the corresponding pci_pm_complete(), via
      pm_runtime_put_sync().
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: stable@kernel.org
      Acked-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      a5f76d5e
  20. 12 4月, 2011 1 次提交
    • R
      PM / Hibernate: Introduce CONFIG_HIBERNATE_CALLBACKS · 1f112cee
      Rafael J. Wysocki 提交于
      Xen save/restore is going to use hibernate device callbacks for
      quiescing devices and putting them back to normal operations and it
      would need to select CONFIG_HIBERNATION for this purpose.  However,
      that also would cause the hibernate interfaces for user space to be
      enabled, which might confuse user space, because the Xen kernels
      don't support hibernation.  Moreover, it would be wasteful, as it
      would make the Xen kernels include a substantial amount of code that
      they would never use.
      
      To address this issue introduce new power management Kconfig option
      CONFIG_HIBERNATE_CALLBACKS, such that it will only select the code
      that is necessary for the hibernate device callbacks to work and make
      CONFIG_HIBERNATION select it.  Then, Xen save/restore will be able to
      select CONFIG_HIBERNATE_CALLBACKS without dragging the entire
      hibernate code along with it.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Tested-by: NShriram Rajagopalan <rshriram@cs.ubc.ca>
      1f112cee
  21. 15 3月, 2011 1 次提交
  22. 24 12月, 2010 2 次提交
  23. 31 7月, 2010 1 次提交
    • A
      PCI: change device runtime PM settings for probe and remove · f3ec4f87
      Alan Stern 提交于
      This patch (as1388) changes the way the PCI core handles runtime PM
      settings when probing or unbinding drivers.  Now the core will make
      sure the device is enabled for runtime PM, with a usage count >= 1,
      when a driver is probed.  It does the same when calling a driver's
      remove method.
      
      If the driver wants to use runtime PM, all it has to do is call
      pm_runtime_pu_noidle() near the end of its probe routine (to cancel
      the core's usage increment) and pm_runtime_get_noresume() near the
      start of its remove routine (to restore the usage count).  It does not
      need to mess around with setting the runtime state to enabled,
      disabled, active, or suspended.
      
      The patch updates e1000e and r8169, the only PCI drivers that already
      use the existing runtime PM interface.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      f3ec4f87
  24. 23 2月, 2010 1 次提交
  25. 15 9月, 2009 2 次提交
  26. 10 9月, 2009 1 次提交
  27. 21 8月, 2009 1 次提交
  28. 25 7月, 2009 1 次提交
  29. 24 7月, 2009 1 次提交
  30. 31 3月, 2009 4 次提交
  31. 21 3月, 2009 2 次提交
  32. 13 3月, 2009 1 次提交
  33. 05 2月, 2009 1 次提交
    • R
      PCI PM: make the PM core more careful with drivers using the new PM framework · 5294e256
      Rafael J. Wysocki 提交于
      Currently, the PM core always attempts to manage devices with drivers
      that use the new PM framework.  In particular, it attempts to disable
      the devices (which is unnecessary), to save their state (which may be
      undesirable if the driver has done that already) and to put them into
      low power states (again, this may be undesirable if the driver has
      already put the device into a low power state).  That need not be
      the right thing to do, so make the core be more careful in this
      respect.
      
      Generally, there are the following categories of devices to consider:
      * bridge devices without drivers
      * non-bridge devices without drivers
      * bridge devices with drivers
      * non-bridge devices with drivers
      and each of them should be handled differently.
      
      For bridge devices without drivers the PCI PM core will save their
      state on suspend and restore it (early) during resume, after putting
      them into D0 if necessary.  It will not attempt to do anything else
      to these devices.
      
      For non-bridge devices without drivers the PCI PM core will disable
      them and save their state on suspend.  During resume, it will put
      them into D0, if necessary, restore their state (early) and reenable
      them.
      
      For bridge devices with drivers the PCI PM core will only save
      their state on suspend if the driver hasn't done that already.
      Still, the core will restore their state (early) during resume,
      after putting them into D0, if necessary.
      
      For non-bridge devices with drivers the PCI PM core will only save
      their state on suspend if the driver hasn't done that already.  Also,
      if the state of the device hasn't been saved by the driver, the core
      will attempt to put the device into a low power state.  During
      resume the core will restore the state of the device (early), after
      putting it into D0, if necessary.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      5294e256