1. 18 4月, 2013 1 次提交
  2. 13 4月, 2013 1 次提交
  3. 26 1月, 2013 2 次提交
    • Y
      PCI: Put pci_dev in device tree as early as possible · 4f535093
      Yinghai Lu 提交于
      We want to put pci_dev structs in the device tree as soon as possible so
      for_each_pci_dev() iteration will not miss them, but driver attachment
      needs to be delayed until after pci_assign_unassigned_resources() to make
      sure all devices have resources assigned first.
      
      This patch moves device registering from pci_bus_add_devices() to
      pci_device_add(), which happens earlier, leaving driver attachment in
      pci_bus_add_devices().
      
      It also removes unattached child bus handling in pci_bus_add_devices().
      That's not needed because child bus via pci_add_new_bus() is already
      in parent bus children list.
      
      [bhelgaas: changelog]
      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>
      4f535093
    • 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
  4. 08 1月, 2013 1 次提交
  5. 06 12月, 2012 1 次提交
  6. 03 11月, 2012 1 次提交
    • H
      PCI/PM: Fix deadlock when unbinding device if parent in D3cold · 90b5c1d7
      Huang Ying 提交于
      If a PCI device and its parents are put into D3cold, unbinding the
      device will trigger deadlock as follow:
      
      - driver_unbind
        - device_release_driver
          - device_lock(dev)				<--- previous lock here
          - __device_release_driver
            - pm_runtime_get_sync
              ...
                - rpm_resume(dev)
                  - rpm_resume(dev->parent)
                    ...
                      - pci_pm_runtime_resume
                        ...
                        - pci_set_power_state
                          - __pci_start_power_transition
                            - pci_wakeup_bus(dev->parent->subordinate)
                              - pci_walk_bus
                                - device_lock(dev)	<--- deadlock here
      
      
      If we do not do device_lock in pci_walk_bus, we can avoid deadlock.
      Device_lock in pci_walk_bus is introduced in commit:
      d71374da, corresponding email thread
      is: https://lkml.org/lkml/2006/5/26/38.  The patch author Zhang Yanmin
      said device_lock is added to pci_walk_bus because:
      
        Some error handling functions call pci_walk_bus. For example, PCIe
        aer. Here we lock the device, so the driver wouldn't detach from the
        device, as the cb might call driver's callback function.
      
      So I fixed the deadlock as follows:
      
      - remove device_lock from pci_walk_bus
      - add device_lock into callback if callback will call driver's callback
      
      I checked pci_walk_bus users one by one, and found only PCIe aer needs
      device lock.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      CC: stable@vger.kernel.org		# v3.6+
      CC: Zhang Yanmin <yanmin.zhang@intel.com>
      90b5c1d7
  7. 19 9月, 2012 1 次提交
    • Y
      PCI: Use correct type when freeing bus resource list · 817a2685
      Yinghai Lu 提交于
      Should use struct pci_bus_resource instead of struct pci_host_bridge_window
      
      Commit 45ca9e97 ("PCI: add helpers for building PCI bus resource lists")
      added pci_free_resource_list() and used it in pci_bus_remove_resources().
      Later it was also used for host bridge aperture lists, which was fine until
      commit 0efd5aab ("PCI: add struct pci_host_bridge_window with CPU/bus
      address offset").  That commit added offset information, so we needed a
      struct pci_host_bridge_window that was separate from struct
      pci_bus_resource.
      
      Commit 0efd5aab should have split the host bridge aperture users of
      pci_free_resource_list() from the pci_bus_resource user
      (pci_bus_remove_resources()), but it did not.
      
      [bhelgaas: changelog -- 0efd5aab was mine, so this is all my fault]
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      817a2685
  8. 16 7月, 2012 1 次提交
  9. 10 7月, 2012 1 次提交
    • M
      PCI: call final fixups hot-added devices · 735bff10
      Myron Stowe 提交于
      Final fixups are currently applied only at boot-time by
      pci_apply_final_quirks(), which is an fs_initcall().  Hot-added devices
      don't get these fixups, so they may not be completely initialized.
      
      This patch makes us run final fixups for hot-added devices in
      pci_bus_add_device() just before the new device becomes eligible for driver
      binding.
      
      This patch keeps the fs_initcall() for devices present at boot because we
      do resource assignment between pci_bus_add_device and the fs_initcall(),
      and we don't want to break any fixups that depend on that assignment.  This
      is a design issue that may be addressed in the future -- any resource
      assignment should be done *before* device_add().
      
      [bhelgaas: changelog]
      Signed-off-by: NMyron Stowe <myron.stowe@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      735bff10
  10. 24 2月, 2012 1 次提交
    • B
      PCI: add struct pci_host_bridge_window with CPU/bus address offset · 0efd5aab
      Bjorn Helgaas 提交于
      Some PCI host bridges apply an address offset, so bus addresses on PCI are
      different from CPU addresses.  This patch adds a way for architectures to
      tell the PCI core about this offset.  For example:
      
          LIST_HEAD(resources);
          pci_add_resource_offset(&resources, host->io_space, host->io_offset);
          pci_add_resource_offset(&resources, host->mem_space, host->mem_offset);
          pci_scan_root_bus(parent, bus, ops, sysdata, &resources);
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      0efd5aab
  11. 07 1月, 2012 1 次提交
  12. 22 5月, 2011 1 次提交
  13. 18 12月, 2010 2 次提交
  14. 13 11月, 2010 1 次提交
    • B
      PCI: fix pci_bus_alloc_resource() hang, prefer positive decode · 82e3e767
      Bjorn Helgaas 提交于
      When a PCI bus has two resources with the same start/end, e.g.,
      
          pci_bus 0000:04: resource 2 [mem 0xd0000000-0xd7ffffff pref]
          pci_bus 0000:04: resource 7 [mem 0xd0000000-0xd7ffffff]
      
      the previous pci_bus_find_resource_prev() implementation would alternate
      between them forever:
      
          pci_bus_find_resource_prev(... [mem 0xd0000000-0xd7ffffff pref])
              returns [mem 0xd0000000-0xd7ffffff]
          pci_bus_find_resource_prev(... [mem 0xd0000000-0xd7ffffff])
              returns [mem 0xd0000000-0xd7ffffff pref]
          pci_bus_find_resource_prev(... [mem 0xd0000000-0xd7ffffff pref])
              returns [mem 0xd0000000-0xd7ffffff]
          ...
      
      This happened because there was no ordering between two resources with the
      same start and end.  A resource that had the same start and end as the
      cursor, but was not itself the cursor, was considered to be before the
      cursor.
      
      This patch fixes the hang by making a fixed ordering between any two
      resources.
      
      In addition, it tries to allocate from positively decoded regions before
      using any subtractively decoded resources.  This means we will use a
      positive decode region before a subtractive decode one, even if it means
      using a smaller address.
      
      Reference: https://bugzilla.kernel.org/show_bug.cgi?id=22062Reported-by: NBorislav Petkov <bp@amd64.org>
      Tested-by: NBorislav Petkov <bp@amd64.org>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      82e3e767
  15. 27 10月, 2010 1 次提交
    • B
      PCI: allocate bus resources from the top down · b126b470
      Bjorn Helgaas 提交于
      Allocate space from the highest-address PCI bus resource first, then work
      downward.
      
      Previously, we looked for space in PCI host bridge windows in the order
      we discovered the windows.  For example, given the following windows
      (discovered via an ACPI _CRS method):
      
          pci_root PNP0A03:00: host bridge window [mem 0x000a0000-0x000bffff]
          pci_root PNP0A03:00: host bridge window [mem 0x000c0000-0x000effff]
          pci_root PNP0A03:00: host bridge window [mem 0x000f0000-0x000fffff]
          pci_root PNP0A03:00: host bridge window [mem 0xbff00000-0xf7ffffff]
          pci_root PNP0A03:00: host bridge window [mem 0xff980000-0xff980fff]
          pci_root PNP0A03:00: host bridge window [mem 0xff97c000-0xff97ffff]
          pci_root PNP0A03:00: host bridge window [mem 0xfed20000-0xfed9ffff]
      
      we attempted to allocate from [mem 0x000a0000-0x000bffff] first, then
      [mem 0x000c0000-0x000effff], and so on.
      
      With this patch, we allocate from [mem 0xff980000-0xff980fff] first, then
      [mem 0xff97c000-0xff97ffff], [mem 0xfed20000-0xfed9ffff], etc.
      
      Allocating top-down follows Windows practice, so we're less likely to
      trip over BIOS defects in the _CRS description.
      
      On the machine above (a Dell T3500), the [mem 0xbff00000-0xbfffffff] region
      doesn't actually work and is likely a BIOS defect.  The symptom is that we
      move the AHCI controller to 0xbff00000, which leads to "Boot has failed,
      sleeping forever," a BUG in ahci_stop_engine(), or some other boot failure.
      
      Reference: https://bugzilla.kernel.org/show_bug.cgi?id=16228#c43
      Reference: https://bugzilla.redhat.com/show_bug.cgi?id=620313
      Reference: https://bugzilla.redhat.com/show_bug.cgi?id=629933Reported-by: NBrian Bloniarz <phunge0@hotmail.com>
      Reported-and-tested-by: NStefan Becker <chemobejk@gmail.com>
      Reported-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      b126b470
  16. 18 10月, 2010 1 次提交
  17. 31 7月, 2010 2 次提交
  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. 08 3月, 2010 1 次提交
    • G
      Driver core: create lock/unlock functions for struct device · 8e9394ce
      Greg Kroah-Hartman 提交于
      In the future, we are going to be changing the lock type for struct
      device (once we get the lockdep infrastructure properly worked out)  To
      make that changeover easier, and to possibly burry the lock in a
      different part of struct device, let's create some functions to lock and
      unlock a device so that no out-of-core code needs to be changed in the
      future.
      
      This patch creates the device_lock/unlock/trylock() functions, and
      converts all in-tree users to them.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jean Delvare <khali@linux-fr.org>
      Cc: Dave Young <hidave.darkstar@gmail.com>
      Cc: Ming Lei <tom.leiming@gmail.com>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Phil Carmody <ext-phil.2.carmody@nokia.com>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: Rafael J. Wysocki <rjw@sisk.pl>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Magnus Damm <damm@igel.co.jp>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      Cc: Vegard Nossum <vegard.nossum@gmail.com>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Alex Chiang <achiang@hp.com>
      Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andrew Patterson <andrew.patterson@hp.com>
      Cc: Yu Zhao <yu.zhao@intel.com>
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Cc: Samuel Ortiz <sameo@linux.intel.com>
      Cc: Wolfram Sang <w.sang@pengutronix.de>
      Cc: CHENG Renquan <rqcheng@smu.edu.sg>
      Cc: Oliver Neukum <oliver@neukum.org>
      Cc: Frans Pop <elendil@planet.nl>
      Cc: David Vrabel <david.vrabel@csr.com>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      8e9394ce
  20. 24 2月, 2010 2 次提交
    • B
      PCI: augment bus resource table with a list · 2fe2abf8
      Bjorn Helgaas 提交于
      Previously we used a table of size PCI_BUS_NUM_RESOURCES (16) for resources
      forwarded to a bus by its upstream bridge.  We've increased this size
      several times when the table overflowed.
      
      But there's no good limit on the number of resources because host bridges
      and subtractive decode bridges can forward any number of ranges to their
      secondary buses.
      
      This patch reduces the table to only PCI_BRIDGE_RESOURCE_NUM (4) entries,
      which corresponds to the number of windows a PCI-to-PCI (3) or CardBus (4)
      bridge can positively decode.  Any additional resources, e.g., PCI host
      bridge windows or subtractively-decoded regions, are kept in a list.
      
      I'd prefer a single list rather than this split table/list approach, but
      that requires simultaneous changes to every architecture.  This approach
      only requires immediate changes where we set up (a) host bridges with more
      than four windows and (b) subtractive-decode P2P bridges, and we can
      incrementally change other architectures to use the list.
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      2fe2abf8
    • B
      PCI: add pci_bus_for_each_resource(), remove direct bus->resource[] refs · 89a74ecc
      Bjorn Helgaas 提交于
      No functional change; this converts loops that iterate from 0 to
      PCI_BUS_NUM_RESOURCES through pci_bus resource[] table to use the
      pci_bus_for_each_resource() iterator instead.
      
      This doesn't change the way resources are stored; it merely removes
      dependencies on the fact that they're in a table.
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      89a74ecc
  21. 23 2月, 2010 2 次提交
  22. 17 6月, 2009 1 次提交
  23. 12 6月, 2009 1 次提交
  24. 07 4月, 2009 1 次提交
    • Y
      PCI: Setup disabled bridges even if buses are added · 296ccb08
      Yuji Shimada 提交于
      This patch sets up disabled bridges even if buses have already been
      added.
      
      pci_assign_unassigned_resources is called after buses are added.
      pci_assign_unassigned_resources calls pci_bus_assign_resources.
      pci_bus_assign_resources calls pci_setup_bridge to configure BARs of
      bridges.
      
      Currently pci_setup_bridge returns immediately if the bus have already
      been added. So pci_assign_unassigned_resources can't configure BARs of
      bridges that were added in a disabled state; this patch fixes the issue.
      
      On logical hot-add, we need to prevent the kernel from re-initializing
      bridges that have already been initialized. To achieve this,
      pci_setup_bridge returns immediately if the bridge have already been
      enabled.
      
      We don't need to check whether the specified bus is a root bus or not.
      pci_setup_bridge is not called on a root bus, because a root bus does
      not have a bridge.
      
      The patch adds a new helper function, pci_is_enabled. I made the
      function name similar to pci_is_managed. The codes which use
      enable_cnt directly are changed to use pci_is_enabled.
      Acked-by: NAlex Chiang <achiang@hp.com>
      Signed-off-by: NYuji Shimada <shimada-yxb@necst.nec.co.jp>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      296ccb08
  25. 21 3月, 2009 1 次提交
  26. 20 3月, 2009 1 次提交
  27. 08 1月, 2009 3 次提交
  28. 21 10月, 2008 1 次提交
  29. 21 4月, 2008 2 次提交
  30. 14 3月, 2008 1 次提交
    • G
      PCI: fix issue with busses registering multiple times in sysfs · cc74d96f
      Greg Kroah-Hartman 提交于
      PCI busses can be registered multiple times, so we need to detect if we
      have registered our bus structure in sysfs already.  If so, don't do it
      again.
      
      Thanks to Guennadi Liakhovetski <g.liakhovetski@gmx.de> for reporting
      the problem, and to Linus for poking me to get me to believe that it was
      a real problem.
      
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      cc74d96f
  31. 05 3月, 2008 1 次提交
  32. 02 2月, 2008 1 次提交
    • G
      PCI: make pci_bus a struct device · fd7d1ced
      Greg Kroah-Hartman 提交于
      This moves the pci_bus class device to be a real struct device and at
      the same time, place it in the device tree in the correct location.
      
      Note, the old "bridge" symlink is now gone, but this was a non-standard
      link and no userspace program used it.  If you need to determine the
      device that the bus is on, follow the standard device symlink, or walk
      up the device tree.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fd7d1ced