1. 24 1月, 2015 1 次提交
    • R
      PCI / PM: Avoid resuming PCI devices during system suspend · bac2a909
      Rafael J. Wysocki 提交于
      Commit f25c0ae2 (ACPI / PM: Avoid resuming devices in ACPI PM
      domain during system suspend) modified the ACPI PM domain's system
      suspend callbacks to allow devices attached to it to be left in the
      runtime-suspended state during system suspend so as to optimize
      the suspend process.
      
      This was based on the general mechanism introduced by commit
      aae4518b (PM / sleep: Mechanism to avoid resuming runtime-suspended
      devices unnecessarily).
      
      Extend that approach to PCI devices by modifying the PCI bus type's
      ->prepare callback to return 1 for devices that are runtime-suspended
      when it is being executed and that are in a suitable power state and
      need not be resumed going forward.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      bac2a909
  2. 04 12月, 2014 1 次提交
  3. 29 10月, 2014 1 次提交
  4. 04 9月, 2014 1 次提交
  5. 20 6月, 2014 1 次提交
  6. 11 6月, 2014 2 次提交
  7. 29 5月, 2014 1 次提交
    • A
      PCI: Introduce new device binding path using pci_dev.driver_override · 782a985d
      Alex Williamson 提交于
      The driver_override field allows us to specify the driver for a device
      rather than relying on the driver to provide a positive match of the
      device.  This shortcuts the existing process of looking up the vendor and
      device ID, adding them to the driver new_id, binding the device, then
      removing the ID, but it also provides a couple advantages.
      
      First, the above existing process allows the driver to bind to any device
      matching the new_id for the window where it's enabled.  This is often not
      desired, such as the case of trying to bind a single device to a meta
      driver like pci-stub or vfio-pci.  Using driver_override we can do this
      deterministically using:
      
        echo pci-stub > /sys/bus/pci/devices/0000:03:00.0/driver_override
        echo 0000:03:00.0 > /sys/bus/pci/devices/0000:03:00.0/driver/unbind
        echo 0000:03:00.0 > /sys/bus/pci/drivers_probe
      
      Previously we could not invoke drivers_probe after adding a device to
      new_id for a driver as we get non-deterministic behavior whether the driver
      we intend or the standard driver will claim the device.  Now it becomes a
      deterministic process, only the driver matching driver_override will probe
      the device.
      
      To return the device to the standard driver, we simply clear the
      driver_override and reprobe the device:
      
        echo > /sys/bus/pci/devices/0000:03:00.0/driver_override
        echo 0000:03:00.0 > /sys/bus/pci/devices/0000:03:00.0/driver/unbind
        echo 0000:03:00.0 > /sys/bus/pci/drivers_probe
      
      Another advantage to this approach is that we can specify a driver override
      to force a specific binding or prevent any binding.  For instance when an
      IOMMU group is exposed to userspace through VFIO we require that all
      devices within that group are owned by VFIO.  However, devices can be
      hot-added into an IOMMU group, in which case we want to prevent the device
      from binding to any driver (override driver = "none") or perhaps have it
      automatically bind to vfio-pci.  With driver_override it's a simple matter
      for this field to be set internally when the device is first discovered to
      prevent driver matches.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: NAlexander Graf <agraf@suse.de>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      782a985d
  8. 28 5月, 2014 1 次提交
  9. 30 4月, 2014 2 次提交
    • B
      PCI: Remove dead code · efdd4070
      Bjorn Helgaas 提交于
      "pdev" can never be NULL here, so remove the test.
      
      Found by Coverity (CID 744313).
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      efdd4070
    • B
      PCI: Fail new_id for vendor/device values already built into driver · 8895d3bc
      Bandan Das 提交于
      While using the sysfs new_id interface, the user can unintentionally feed
      incorrect values if the driver static table has a matching entry.  This is
      possible since only the device and vendor fields are mandatory and the rest
      are optional.  As a result, store_new_id() will fill in default values that
      are then passed on to the driver and can have unintended consequences.
      
      As an example, consider the ixgbe driver and the 82599EB network card:
      
        echo "8086 10fb" > /sys/bus/pci/drivers/ixgbe/new_id
      
      This will pass a pci_device_id with driver_data = 0 to ixgbe_probe(), which
      uses that zero to index a table of card operations.  The zeroth entry of
      the table does *not* correspond to the 82599 operations.
      
      This change returns an error if the user attempts to add a dynid for a
      vendor/device combination for which a static entry already exists.
      However, if the user intentionally wants a different set of values, she
      must provide all the 7 fields and that will be accepted.
      
      [bhelgaas: drop KVM text since the problem isn't KVM-specific]
      Signed-off-by: NBandan Das <bsd@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NAlex Williamson <alex.williamson@redhat.com>
      8895d3bc
  10. 04 3月, 2014 1 次提交
    • R
      PCI / PM: Resume runtime-suspended devices later during system suspend · 7cd0602d
      Rafael J. Wysocki 提交于
      Runtime-suspended devices are resumed during system suspend by
      pci_pm_prepare() for two reasons: First, because they may need
      to be reprogrammed in order to change their wakeup settings and,
      second, because they may need to be operatonal for their children
      to be successfully suspended.  That is a problem, though, if there
      are many runtime-suspended devices that need to be resumed this
      way during system suspend, because the .prepare() PM callbacks of
      devices are executed sequentially and the times taken by them
      accumulate, which may increase the total system suspend time quite
      a bit.
      
      For this reason, move the resume of runtime-suspended devices up
      to the next phase of device suspend (during system suspend), except
      for the ones that have power.ignore_children set.  The exception is
      made, because the devices with power.ignore_children set may still
      be necessary for their children to be successfully suspended (during
      system suspend) and they won't be resumed automatically as a result
      of the runtime resume of their children.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      7cd0602d
  11. 08 12月, 2013 1 次提交
  12. 26 11月, 2013 1 次提交
  13. 15 11月, 2013 1 次提交
  14. 07 11月, 2013 1 次提交
    • S
      PCI: Warn on driver probe return value greater than zero · f92d74c1
      Stephen M. Cameron 提交于
      Ages ago, drivers could return values greater than zero from their probe
      function and this would be regarded as success.
      
      But after f3ec4f87 ("PCI: change device runtime PM settings for probe
      and remove") and 967577b0 ("PCI/PM: Keep runtime PM enabled for unbound
      PCI devices"), we set dev->driver to NULL if the driver's probe function
      returns a value greater than zero.
      
      __pci_device_probe() treats this as success, and drivers can still mostly
      work even with dev->driver == NULL, but PCI power management doesn't work,
      and we don't call the driver's remove function on rmmod.
      
      To help catch these driver problems, issue a warning in this case.
      
      [bhelgaas: changelog]
      Signed-off-by: NStephen M. Cameron <scameron@beardog.cce.hp.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      f92d74c1
  15. 08 10月, 2013 5 次提交
  16. 27 9月, 2013 2 次提交
  17. 23 8月, 2013 1 次提交
  18. 04 6月, 2013 1 次提交
  19. 03 4月, 2013 1 次提交
  20. 12 2月, 2013 2 次提交
  21. 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
  22. 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
  23. 29 11月, 2012 2 次提交
  24. 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
  25. 03 11月, 2012 1 次提交
  26. 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
  27. 18 9月, 2012 1 次提交
  28. 22 8月, 2012 1 次提交
  29. 16 8月, 2012 1 次提交
  30. 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
  31. 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