1. 11 6月, 2014 1 次提交
  2. 24 5月, 2014 3 次提交
    • B
      PCI: Add resource allocation comments · 67d29b5c
      Bjorn Helgaas 提交于
      Add comments in the code to match the allocation strategy of 7c671426dfc3
      ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources").
      
      No functional change.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      67d29b5c
    • B
      PCI: Simplify __pci_assign_resource() coding style · d3689df0
      Bjorn Helgaas 提交于
      If an allocation succeeds, we can return success immediately.  Then we
      don't have to test for success in the subsequent code.
      
      No functional change.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      d3689df0
    • Y
      PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources · 5b285415
      Yinghai Lu 提交于
      This patch changes the way we handle 64-bit prefetchable bridge windows to
      make it more likely that we can assign space to all devices.
      
      Previously we put all prefetchable resources in the prefetchable bridge
      window.  If any of those resources was 32-bit only, we restricted the
      window to be below 4GB.
      
      After this patch, we only put 64-bit prefetchable resources in a 64-bit
      prefetchable window.  We put all 32-bit prefetchable resources in the
      non-prefetchable window, even if there are no 64-bit prefetchable
      resources.
      
      With the previous approach, if there was a 32-bit prefetchable resource
      behind a bridge, we forced the bridge's prefetchable window below 4GB,
      which meant that even if there was plenty of space above 4GB available, we
      couldn't use it, and assignment of large 64-bit resources could fail, as
      in the bugzilla below.
      
      The new strategy is:
      
        1) If the prefetchable window is 64 bits wide, we put only 64-bit
           prefetchable resources in it.  Any 32-bit prefetchable resources go in
           the non-prefetchable window.
      
        2) If the prefetchable window is 32 bits wide, we put both 32- and 64-bit
           prefetchable resources in it.
      
        3) If there is no prefetchable window, all MMIO resources go in the
           non-prefetchable window.
      
      This reduces performance for 32-bit prefetchable resources below a bridge
      with a 64-bit prefetchable window.  We previously assigned prefetchable
      space, but now we'll assign non-prefetchable space.  This is the case even
      if there are no 64-bit prefetchable resources, or if they would all fit
      below 4GB.  In those cases, the old strategy would work and would have
      better performance.
      
      [bhelgaas: write changelog, add bugzilla link, fold in mem64_mask removal]
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=74151Tested-by: NGuo Chao <yan@linux.vnet.ibm.com>
      Tested-by: NWei Yang <weiyang@linux.vnet.ibm.com>
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      5b285415
  3. 15 4月, 2014 1 次提交
  4. 20 3月, 2014 1 次提交
    • B
      PCI: Don't enable decoding if BAR hasn't been assigned an address · 3cedcc36
      Bjorn Helgaas 提交于
      Don't enable memory or I/O decoding if we haven't assigned or claimed the
      BAR's resource.
      
      If we enable decoding for a BAR that hasn't been assigned an address, we'll
      likely cause bus conflicts.  This declines to enable decoding for resources
      with IORESOURCE_UNSET.
      
      Note that drivers can use pci_enable_device_io() or pci_enable_device_mem()
      if they only care about specific types of BARs.  In that case, we don't
      bother checking whether the corresponding resources are assigned or
      claimed.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      3cedcc36
  5. 28 2月, 2014 4 次提交
  6. 22 12月, 2013 1 次提交
    • Y
      PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev · fc279850
      Yinghai Lu 提交于
      These interfaces:
      
        pcibios_resource_to_bus(struct pci_dev *dev, *bus_region, *resource)
        pcibios_bus_to_resource(struct pci_dev *dev, *resource, *bus_region)
      
      took a pci_dev, but they really depend only on the pci_bus.  And we want to
      use them in resource allocation paths where we have the bus but not a
      device, so this patch converts them to take the pci_bus instead of the
      pci_dev:
      
        pcibios_resource_to_bus(struct pci_bus *bus, *bus_region, *resource)
        pcibios_bus_to_resource(struct pci_bus *bus, *resource, *bus_region)
      
      In fact, with standard PCI-PCI bridges, they only depend on the host
      bridge, because that's the only place address translation occurs, but
      we aren't going that far yet.
      
      [bhelgaas: changelog]
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      fc279850
  7. 15 11月, 2013 1 次提交
  8. 16 4月, 2013 1 次提交
  9. 12 7月, 2012 2 次提交
  10. 10 7月, 2012 1 次提交
    • B
      PCI: disable MEM decoding while updating 64-bit MEM BARs · 9aac537e
      Bjorn Helgaas 提交于
      When we update 64-bit BARs, we have to perform two config writes.  Between
      the writes, the half-written BAR value could match a MEM access intended
      for another device.  This could result in corruption of this device (for
      writes) or an unexpected response machine check (for reads).
      
      To prevent this, disable MEM decoding while updating such BARs.  This uses
      the same safety test as 253d2e54, which disables both MEM and IO while
      sizing BARs, namely, we don't disable decoding for host bridge devices.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      9aac537e
  11. 25 2月, 2012 1 次提交
  12. 15 2月, 2012 5 次提交
    • Y
      PCI: Move pdev_sort_resources() to setup-bus.c · 78c3b329
      Yinghai Lu 提交于
      This allows us to move the definition of struct resource_list to
      setup_bus.c and later convert resource_list to a regular list.
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      78c3b329
    • Y
      PCI : Calculate right add_size · a4ac9fea
      Yinghai Lu 提交于
      During debug of one SRIOV enabled hotplug device, we found found that
      add_size is not passed properly.
      
      The device has devices under two level bridges:
      
       +-[0000:80]-+-00.0-[81-8f]--
       |           +-01.0-[90-9f]--
       |           +-02.0-[a0-af]----00.0-[a1-a3]--+-02.0-[a2]--+-00.0  Oracle Corporation Device
       |           |                               \-03.0-[a3]--+-00.0  Oracle Corporation Device
      
      Which means later the parent bridge will not try to add a big enough range:
      
      [  557.455077] pci 0000:a0:00.0: BAR 14: assigned [mem 0xf9000000-0xf93fffff]
      [  557.461974] pci 0000:a0:00.0: BAR 15: assigned [mem 0xf6000000-0xf61fffff pref]
      [  557.469340] pci 0000:a1:02.0: BAR 14: assigned [mem 0xf9000000-0xf91fffff]
      [  557.476231] pci 0000:a1:02.0: BAR 15: assigned [mem 0xf6000000-0xf60fffff pref]
      [  557.483582] pci 0000:a1:03.0: BAR 14: assigned [mem 0xf9200000-0xf93fffff]
      [  557.490468] pci 0000:a1:03.0: BAR 15: assigned [mem 0xf6100000-0xf61fffff pref]
      [  557.497833] pci 0000:a1:03.0: BAR 14: can't assign mem (size 0x200000)
      [  557.504378] pci 0000:a1:03.0: failed to add optional resources res=[mem 0xf9200000-0xf93fffff]
      [  557.513026] pci 0000:a1:02.0: BAR 14: can't assign mem (size 0x200000)
      [  557.519578] pci 0000:a1:02.0: failed to add optional resources res=[mem 0xf9000000-0xf91fffff]
      
      It turns out we did not calculate size1 properly.
      
      static resource_size_t calculate_memsize(resource_size_t size,
                      resource_size_t min_size,
                      resource_size_t size1,
                      resource_size_t old_size,
                      resource_size_t align)
      {
              if (size < min_size)
                      size = min_size;
              if (old_size == 1 )
                      old_size = 0;
              if (size < old_size)
                      size = old_size;
              size = ALIGN(size + size1, align);
              return size;
      }
      
      We should not pass add_size with min_size in calculate_memsize since
      that will make add_size not contribute final add_size.
      
      So just pass add_size with size1 to calculate_memsize().
      
      With this change, we should have chance to remove extra addon in
      pci_reassign_resource.
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      a4ac9fea
    • M
      PCI: Fix typo in setup-res.c · 0dea210b
      Masanari Iida 提交于
      Correct spelling "resouce" to "resource" in
      dricers/pci/setup-res.c
      Signed-off-by: NMasanari Iida <standby24x7@gmail.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      0dea210b
    • M
      x86/PCI: Convert maintaining FW-assigned BIOS BAR values to use a list · 6535943f
      Myron Stowe 提交于
      This patch converts the underlying maintenance aspects of FW-assigned
      BIOS BAR values from a statically allocated array within struct pci_dev
      to a list of temporary, stand alone, entries.
      Signed-off-by: NMyron Stowe <myron.stowe@redhat.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      6535943f
    • M
      PCI: Fix starting basis for resource requests · 351fc6d1
      Myron Stowe 提交于
      pci_revert_fw_address() is used to reinstate a PCI device's original
      FW-assigned BIOS BAR value(s) if normal resource assignment fails.
      
      When attempting to reinstate an address, the point within the resource
      tree from which to attempt the new resource request should be the parent
      resource corresponding to the device, not the base of the resource tree
      (ioport_resource or iomem_resource).  For PCI devices this would
      typically be the resource corresponding to the upstream PCI host bridge
      or P2P bridge aperture.
      
      This patch sets the point within the resource tree to attempt a new
      resource assignment request to the PCI device's parent resource and only
      if that fails does it fall back to the base ioport_resource or
      iomem_resource.
      Signed-off-by: NMyron Stowe <myron.stowe@redhat.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      351fc6d1
  13. 07 1月, 2012 1 次提交
  14. 01 11月, 2011 1 次提交
  15. 02 8月, 2011 1 次提交
    • R
      PCI : ability to relocate assigned pci-resources · 2bbc6942
      Ram Pai 提交于
      Currently pci-bridges are allocated enough resources to satisfy their immediate
      requirements.  Any additional resource-requests fail if additional free space,
      contiguous to the one already allocated, is not available. This behavior is not
      reasonable since sufficient contiguous resources, that can satisfy the request,
      are available at a different location.
      
      This patch provides the ability to expand and relocate a allocated resource.
      
      	v2: Changelog: Fixed size calculation in pci_reassign_resource()
      	v3: Changelog : Split this patch. The resource.c changes are already
      			upstream. All the pci driver changes are in here.
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      2bbc6942
  16. 23 7月, 2011 1 次提交
    • B
      PCI: fold pci_calc_resource_flags() into decode_bar() · 28c6821a
      Bjorn Helgaas 提交于
      decode_bar() and pci_calc_resource_flags() both looked at the PCI BAR
      type information, and it's simpler to just do it all in one place.
      
      decode_bar() sets IORESOURCE_IO, IORESOURCE_MEM, and IORESOURCE_MEM_64
      as appropriate, so res->flags contains all the information pci_bar_type
      does, so we don't need to test the pci_bar_type return value.
      
      decode_bar() used to return pci_bar_type, which we no longer need.  We
      can simplify it a bit by returning the struct resource flags rather than
      updating them internally.
      
      In pci_update_resource(), there's no need to decode the BAR type bits
      again; we can just test for IORESOURCE_MEM_64 directly.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      28c6821a
  17. 18 10月, 2010 1 次提交
  18. 17 7月, 2010 1 次提交
    • B
      PCI: fall back to original BIOS BAR addresses · 58c84eda
      Bjorn Helgaas 提交于
      If we fail to assign resources to a PCI BAR, this patch makes us try the
      original address from BIOS rather than leaving it disabled.
      
      Linux tries to make sure all PCI device BARs are inside the upstream
      PCI host bridge or P2P bridge apertures, reassigning BARs if necessary.
      Windows does similar reassignment.
      
      Before this patch, if we could not move a BAR into an aperture, we left
      the resource unassigned, i.e., at address zero.  Windows leaves such BARs
      at the original BIOS addresses, and this patch makes Linux do the same.
      
      This is a bit ugly because we disable the resource long before we try to
      reassign it, so we have to keep track of the BIOS BAR address somewhere.
      For lack of a better place, I put it in the struct pci_dev.
      
      I think it would be cleaner to attempt the assignment immediately when the
      claim fails, so we could easily remember the original address.  But we
      currently claim motherboard resources in the middle, after attempting to
      claim PCI resources and before assigning new PCI resources, and changing
      that is a fairly big job.
      
      Addresses https://bugzilla.kernel.org/show_bug.cgi?id=16263Reported-by: NAndrew <nitr0@seti.kr.ua>
      Tested-by: NAndrew <nitr0@seti.kr.ua>
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      58c84eda
  19. 12 6月, 2010 1 次提交
  20. 25 3月, 2010 1 次提交
  21. 05 11月, 2009 3 次提交
  22. 07 10月, 2009 1 次提交
  23. 10 9月, 2009 1 次提交
  24. 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
  25. 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
  26. 18 6月, 2009 1 次提交
  27. 12 6月, 2009 1 次提交
  28. 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