1. 30 8月, 2009 1 次提交
    • C
      PCI SR-IOV: correct broken resource alignment calculations · 6faf17f6
      Chris Wright 提交于
      An SR-IOV capable device includes an SR-IOV PCIe capability which
      describes the Virtual Function (VF) BAR requirements.  A typical SR-IOV
      device can support multiple VFs whose BARs must be in a contiguous region,
      effectively an array of VF BARs.  The BAR reports the size requirement
      for a single VF.  We calculate the full range needed by simply multiplying
      the VF BAR size with the number of possible VFs and create a resource
      spanning the full range.
      
      This all seems sane enough except it artificially inflates the alignment
      requirement for the VF BAR.  The VF BAR need only be aligned to the size
      of a single BAR not the contiguous range of VF BARs.  This can cause us
      to fail to allocate resources for the BAR despite the fact that we
      actually have enough space.
      
      This patch adds a thin PCI specific layer over the generic
      resource_alignment() function which is aware of the special nature of
      VF BARs and does sorting and allocation based on the smaller alignment
      requirement.
      
      I recognize that while resource_alignment is generic, it's basically a
      PCI helper.  An alternative to this patch is to add PCI VF BAR specific
      information to struct resource.  I opted for the extra layer rather than
      adding such PCI specific information to struct resource.  This does
      have the slight downside that we don't cache the BAR size and re-read
      for each alignment query (happens a small handful of times during boot
      for each VF BAR).
      Signed-off-by: NChris Wright <chrisw@sous-sol.org>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthew Wilcox <matthew@wil.cx>
      Cc: Yu Zhao <yu.zhao@intel.com>
      Cc: stable@kernel.org
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      6faf17f6
  2. 03 8月, 2009 1 次提交
    • L
      Make pci_claim_resource() use request_resource() rather than insert_resource() · 79896cf4
      Linus Torvalds 提交于
      This function has traditionally used "insert_resource()", because before
      commit cebd78a8 ("Fix pci_claim_resource") it used to just insert the
      resource into whatever root resource tree that was indicated by
      "pcibios_select_root()".
      
      So there Matthew fixed it to actually look up the proper parent
      resource, which means that now it's actively wrong to then traverse the
      resource tree any more: we already know exactly where the new resource
      should go.
      
      And when we then did commit a76117df ("x86: Use pci_claim_resource"),
      which changed the x86 PCI code from the open-coded
      
      	pr = pci_find_parent_resource(dev, r);
      	if (!pr || request_resource(pr, r) < 0) {
      
      to using
      
      	if (pci_claim_resource(dev, idx) < 0) {
      
      that "insert_resource()" now suddenly became a problem, and causes a
      regression covered by
      
      	http://bugzilla.kernel.org/show_bug.cgi?id=13891
      
      which this fixes.
      Reported-and-tested-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Matthew Wilcox <willy@linux.intel.com>
      Cc: Andrew Patterson <andrew.patterson@hp.com>
      Cc: Linux PCI <linux-pci@vger.kernel.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      79896cf4
  3. 18 6月, 2009 1 次提交
  4. 12 6月, 2009 1 次提交
  5. 21 3月, 2009 1 次提交
    • Y
      PCI: allow assignment of memory resources with a specified alignment · 32a9a682
      Yuji Shimada 提交于
      This patch allows memory resources to be assigned with a specified
      alignment at boot-time or run-time. The patch is useful when we use PCI
      pass-through, because page-aligned memory resources are required to
      securely share PCI resources with guest drivers.
      
      If you want to assign the resource at boot time, please set
      "pci=resource_alignment=" boot parameter.
      
      This is format of "pci=resource_alignment=" boot parameter:
      
              [<order of align>@][<domain>:]<bus>:<slot>.<func>[; ...]
                      Specifies alignment and device to reassign
                      aligned memory resources.
                      If <order of align> is not specified, PAGE_SIZE is
                      used as alignment.
                      PCI-PCI bridge can be specified, if resource
                      windows need to be expanded.
      
      This is example:
      
              pci=resource_alignment=20@07:00.0;18@0f:00.0;00:1d.7
      
      If you want to assign the resource at run-time, please set
      "/sys/bus/pci/resource_alignment" file, and hot-remove the device and
      hot-add the device.  For this purpose, fakephp or PCI hotplug interfaces
      can be used.
      
      The format of "/sys/bus/pci/resource_alignment" file is the same with
      boot parameter. You can use "," instead of ";".
      
      For example:
      
              # cd /sys/bus/pci
              # echo -n 20@12:00.0 > resource_alignment
              # echo 1 > devices/0000:12:00.0/remove
              # echo 1 > rescan
      Reviewed-by: NAlex Chiang <achiang@hp.com>
      Reviewed-by: NYu Zhao <yu.zhao@intel.com>
      Signed-off-by: NYuji Shimada <shimada-yxb@necst.nec.co.jp>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      32a9a682
  6. 08 1月, 2009 3 次提交
  7. 21 10月, 2008 2 次提交
  8. 26 6月, 2008 1 次提交
    • B
      PCI: use dev_printk when possible · 80ccba11
      Bjorn Helgaas 提交于
      Convert printks to use dev_printk().
      
      I converted pr_debug() to dev_dbg().  Both use KERN_DEBUG and are enabled
      only when DEBUG is defined.
      
      I converted printk(KERN_DEBUG) to dev_printk(KERN_DEBUG), not to dev_dbg(),
      because dev_dbg() is only enabled when DEBUG is defined.
      
      I converted DBG(KERN_INFO) (only in setup-bus.c) to dev_info().  The DBG()
      name makes it sound like debug, but it's been enabled forever, so dev_info()
      preserves the previous behavior.
      
      I tried to make the resource assignment formats more consistent, e.g.,
        "BAR %d: got res [%#llx-%#llx] bus [%#llx-%#llx] flags %#lx\n"
      instead of sometimes using "start-end" and sometimes using "size@start".
      I'm not attached to one or the other; I'd just like them consistent.
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      80ccba11
  9. 21 4月, 2008 3 次提交
    • I
      PCI: clean up resource alignment management · 88452565
      Ivan Kokshaysky 提交于
      Done per Linus' request and suggestions. Linus has explained that
      better than I'll be able to explain:
      
      On Thu, Mar 27, 2008 at 10:12:10AM -0700, Linus Torvalds wrote:
      > Actually, before we go any further, there might be a less intrusive
      > alternative: add just a couple of flags to the resource flags field (we
      > still have something like 8 unused bits on 32-bit), and use those to
      > implement a generic "resource_alignment()" routine.
      >
      > Two flags would do it:
      >
      >  - IORESOURCE_SIZEALIGN: size indicates alignment (regular PCI device
      >    resources)
      >
      >  - IORESOURCE_STARTALIGN: start field is alignment (PCI bus resources
      >    during probing)
      >
      > and then the case of both flags zero (or both bits set) would actually be
      > "invalid", and we would also clear the IORESOURCE_STARTALIGN flag when we
      > actually allocate the resource (so that we don't use the "start" field as
      > alignment incorrectly when it no longer indicates alignment).
      >
      > That wouldn't be totally generic, but it would have the nice property of
      > automatically at least add sanity checking for that whole "res->start has
      > the odd meaning of 'alignment' during probing" and remove the need for a
      > new field, and it would allow us to have a generic "resource_alignment()"
      > routine that just gets a resource pointer.
      
      Besides, I removed IORESOURCE_BUS_HAS_VGA flag which was unused for ages.
      Signed-off-by: NIvan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Gary Hade <garyhade@us.ibm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      88452565
    • B
      PCI: add generic pci_enable_resources() · 842de40d
      Bjorn Helgaas 提交于
      Each architecture has its own pcibios_enable_resources() implementation.
      These differ in many minor ways that have nothing to do with actual
      architectural differences.  Follow-on patches will make most arches
      use this generic version instead.
      
      This version is based on powerpc, which seemed most up-to-date.  The only
      functional difference from the x86 version is that this uses "!r->parent"
      to check for resource collisions instead of "!r->start && r->end".
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Acked-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      842de40d
    • A
      PCI: #if 0 pci_assign_resource_fixed() · 2baad5f9
      Adrian Bunk 提交于
      An unused function that bloated the kernel only when CONFIG_EMBEDDED was
      enabled...
      Signed-off-by: NAdrian Bunk <bunk@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2baad5f9
  10. 02 2月, 2008 2 次提交
  11. 03 5月, 2007 1 次提交
    • S
      pci: do not mark exported functions as __devinit · 96bde06a
      Sam Ravnborg 提交于
      Functions marked __devinit will be removed after kernel init.  But being
      exported they are potentially called by a module much later.
      
      So the safer choice seems to be to keep the function even in the non
      CONFIG_HOTPLUG case.
      
      This silence the follwoing section mismatch warnings:
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_bus_add_device from __ksymtab_gpl between '__ksymtab_pci_bus_add_device' (at offset 0x20) and '__ksymtab_pci_walk_bus'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_create_bus from __ksymtab_gpl between '__ksymtab_pci_create_bus' (at offset 0x40) and '__ksymtab_pci_stop_bus_device'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_bus_max_busnr from __ksymtab_gpl between '__ksymtab_pci_bus_max_busnr' (at offset 0xc0) and '__ksymtab_pci_assign_resource_fixed'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_claim_resource from __ksymtab_gpl between '__ksymtab_pci_claim_resource' (at offset 0xe0) and '__ksymtab_pcie_port_bus_type'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_bus_add_devices from __ksymtab between '__ksymtab_pci_bus_add_devices' (at offset 0x70) and '__ksymtab_pci_bus_alloc_resource'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_scan_bus_parented from __ksymtab between '__ksymtab_pci_scan_bus_parented' (at offset 0x90) and '__ksymtab_pci_root_buses'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_bus_assign_resources from __ksymtab between '__ksymtab_pci_bus_assign_resources' (at offset 0x4d0) and '__ksymtab_pci_bus_size_bridges'
      WARNING: drivers/built-in.o - Section mismatch: reference to .init.text:pci_bus_size_bridges from __ksymtab between '__ksymtab_pci_bus_size_bridges' (at offset 0x4e0) and '__ksymtab_pci_setup_cardbus'
      Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      96bde06a
  12. 21 12月, 2006 1 次提交
    • R
      PCI legacy resource fix · fb0f2b40
      Ralf Baechle 提交于
      Since commit 368c73d4 the kernel will try
      to update the non-writeable BAR registers 0..3 of PIIX4 IDE adapters if
      pci_assign_unassigned_resources() is used to do full resource assignment of
      the bus.  This fails because in the PIIX4 these BAR registers have
      implicitly assumed values and read back as zero; it used to work because
      the kernel used to just write zero to that register the read back value did
      match what was written.
      
      The fix is a new resource flag IORESOURCE_PCI_FIXED used to mark a resource
      as non-movable.  This will also be useful to keep other import system
      resources from being moved around - for example system consoles on PCI
      busses.
      
      [akpm@osdl.org: cleanup]
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      Acked-by: NAlan Cox <alan@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fb0f2b40
  13. 28 6月, 2006 2 次提交
  14. 22 6月, 2006 1 次提交
    • K
      [PATCH] PCI: Add pci_assign_resource_fixed -- allow fixed address assignments · 75acfeca
      Kumar Gala 提交于
      PCI: Add pci_assign_resource_fixed -- allow fixed address assignments
      
      On some embedded systems the PCI address for hotplug devices are not only
      known a priori but are required to be at a given PCI address for other
      master in the system to be able to access.
      
      An example of such a system would be an FPGA which is setup from user space
      after the system has booted.  The FPGA may be access by DSPs in the system
      and those DSPs expect the FPGA at a fixed PCI address.
      
      Added pci_assign_resource_fixed() as a way to allow assignment of the PCI
      devices's BARs at fixed PCI addresses.
      Signed-off-by: NKumar Gala <galak@kernel.crashing.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      75acfeca
  15. 01 2月, 2006 1 次提交
  16. 09 9月, 2005 2 次提交
    • D
      [PATCH] Make sparc64 use setup-res.c · 085ae41f
      David S. Miller 提交于
      There were three changes necessary in order to allow
      sparc64 to use setup-res.c:
      
      1) Sparc64 roots the PCI I/O and MEM address space using
         parent resources contained in the PCI controller structure.
         I'm actually surprised no other platforms do this, especially
         ones like Alpha and PPC{,64}.  These resources get linked into the
         iomem/ioport tree when PCI controllers are probed.
      
         So the hierarchy looks like this:
      
         iomem --|
      	   PCI controller 1 MEM space --|
      				        device 1
      					device 2
      					etc.
      	   PCI controller 2 MEM space --|
      				        ...
         ioport --|
                  PCI controller 1 IO space --|
      					...
                  PCI controller 2 IO space --|
      					...
      
         You get the idea.  The drivers/pci/setup-res.c code allocates
         using plain iomem_space and ioport_space as the root, so that
         wouldn't work with the above setup.
      
         So I added a pcibios_select_root() that is used to handle this.
         It uses the PCI controller struct's io_space and mem_space on
         sparc64, and io{port,mem}_resource on every other platform to
         keep current behavior.
      
      2) quirk_io_region() is buggy.  It takes in raw BUS view addresses
         and tries to use them as a PCI resource.
      
         pci_claim_resource() expects the resource to be fully formed when
         it gets called.  The sparc64 implementation would do the translation
         but that's absolutely wrong, because if the same resource gets
         released then re-claimed we'll adjust things twice.
      
         So I fixed up quirk_io_region() to do the proper pcibios_bus_to_resource()
         conversion before passing it on to pci_claim_resource().
      
      3) I was mistakedly __init'ing the function methods the PCI controller
         drivers provide on sparc64 to implement some parts of these
         routines.  This was, of course, easy to fix.
      
      So we end up with the following, and that nasty SPARC64 makefile
      ifdef in drivers/pci/Makefile is finally zapped.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      085ae41f
    • J
      [PATCH] PCI: restore BAR values after D3hot->D0 for devices that need it · 064b53db
      John W. Linville 提交于
      Some PCI devices (e.g. 3c905B, 3c556B) lose all configuration
      (including BARs) when transitioning from D3hot->D0.  This leaves such
      a device in an inaccessible state.  The patch below causes the BARs
      to be restored when enabling such a device, so that its driver will
      be able to access it.
      
      The patch also adds pci_restore_bars as a new global symbol, and adds a
      correpsonding EXPORT_SYMBOL_GPL for that.
      
      Some firmware (e.g. Thinkpad T21) leaves devices in D3hot after a
      (re)boot.  Most drivers call pci_enable_device very early, so devices
      left in D3hot that lose configuration during the D3hot->D0 transition
      will be inaccessible to their drivers.
      
      Drivers could be modified to account for this, but it would
      be difficult to know which drivers need modification.  This is
      especially true since often many devices are covered by the same
      driver.  It likely would be necessary to replicate code across dozens
      of drivers.
      
      The patch below should trigger only when transitioning from D3hot->D0
      (or at boot), and only for devices that have the "no soft reset" bit
      cleared in the PM control register.  I believe it is safe to include
      this patch as part of the PCI infrastructure.
      
      The cleanest implementation of pci_restore_bars was to call
      pci_update_resource.  Unfortunately, that does not currently exist
      for the sparc64 architecture.  The patch below includes a null
      implemenation of pci_update_resource for sparc64.
      
      Some have expressed interest in making general use of the the
      pci_restore_bars function, so that has been exported to GPL licensed
      modules.
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      064b53db
  17. 27 8月, 2005 1 次提交
    • L
      Ignore disabled ROM resources at setup · 755528c8
      Linus Torvalds 提交于
      Writing even a disabled value seems to mess up some matrox graphics
      cards.  It may be a card-related issue, but we may also be writing
      reserved low bits in the result.
      
      This was a fall-out of switching x86 over to the generic PCI resource
      allocation code, and needs more debugging.  In particular, the old x86
      code defaulted to not doing any resource allocations at all for ROM
      resources.
      
      In the meantime, this has been reported to make X happier by Helge
      Hafting <helgehaf@aitel.hist.no>.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      755528c8
  18. 09 8月, 2005 1 次提交
  19. 08 8月, 2005 1 次提交
    • I
      [PATCH] Fix restore of 64-bit PCI BAR's · cf7bee5a
      Ivan Kokshaysky 提交于
      For 64-bit BAR[i] only pci_dev->resource[i] is valid, ->resource[i+1]
      slot is unused and contains zeroes in all fields.
      
      So when we update a PCI BAR, all we need is just to check that we're
      going to update a _valid_ resource.
      
      Also make sure to write high bits - use "x >> 16 >> 16" (rather than the
      simpler ">> 32") to avoid warnings on 32-bit architectures where we're
      not going to have any high bits.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      cf7bee5a
  20. 05 8月, 2005 1 次提交
    • J
      [PATCH] PCI: restore BAR values after D3hot->D0 for devices that need it · fec59a71
      John W. Linville 提交于
      Some PCI devices (e.g. 3c905B, 3c556B) lose all configuration
      (including BARs) when transitioning from D3hot->D0.  This leaves such
      a device in an inaccessible state.  The patch below causes the BARs
      to be restored when enabling such a device, so that its driver will
      be able to access it.
      
      The patch also adds pci_restore_bars as a new global symbol, and adds a
      correpsonding EXPORT_SYMBOL_GPL for that.
      
      Some firmware (e.g. Thinkpad T21) leaves devices in D3hot after a
      (re)boot.  Most drivers call pci_enable_device very early, so devices
      left in D3hot that lose configuration during the D3hot->D0 transition
      will be inaccessible to their drivers.
      
      Drivers could be modified to account for this, but it would
      be difficult to know which drivers need modification.  This is
      especially true since often many devices are covered by the same
      driver.  It likely would be necessary to replicate code across dozens
      of drivers.
      
      The patch below should trigger only when transitioning from D3hot->D0
      (or at boot), and only for devices that have the "no soft reset" bit
      cleared in the PM control register.  I believe it is safe to include
      this patch as part of the PCI infrastructure.
      
      The cleanest implementation of pci_restore_bars was to call
      pci_update_resource.  Unfortunately, that does not currently exist
      for the sparc64 architecture.  The patch below includes a null
      implemenation of pci_update_resource for sparc64.
      
      Some have expressed interest in making general use of the the
      pci_restore_bars function, so that has been exported to GPL licensed
      modules.
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      fec59a71
  21. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4