1. 02 8月, 2011 2 次提交
    • 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
    • Y
      PCI: honor child buses add_size in hot plug configuration · be768912
      Yinghai Lu 提交于
      git commit c8adf9a3
          "PCI: pre-allocate additional resources to devices only after
      	successful allocation of essential resources."
      
      fails to take into consideration the optional-resources needed by children
      devices while calculating the optional-resource needed by the bridge.
      
      This can be a problem on some setup. For example, if a hotplug bridge has 8
      children hotplug bridges, the bridge should have enough resources to accomodate
      the hotplug requirements for each of its children hotplug bridges.  Currently
      this is not the case.
      
      This patch fixes the problem.
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Reviewed-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      be768912
  2. 23 7月, 2011 1 次提交
  3. 09 7月, 2011 1 次提交
  4. 22 5月, 2011 1 次提交
    • Y
      PCI: update bridge resources to get more big ranges when allocating space (again) · da7822e5
      Yinghai Lu 提交于
      With Ram's fixes, this should be safe to do again.  So let's give it
      another try.
      
      BIOS separates IO ranges between several IOHs, and on some slots, BIOS
      assigns resources to a bridge, but stops assigning resources to the
      device under that bridge, because the device needs a big resource.
      
      So:
      1. allocate resources and record the failed device resources
      2. clear the BIOS assigned resources of the parent bridge of failing device
      3. go back and call pci assign unassigned
      4. if it still fails, go up the tree, clear more bridges. and try again
      
      Now Ram's allocate requested resource already got into mainline. could
      put this one again.
      Reviewed-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      da7822e5
  5. 17 5月, 2011 1 次提交
    • Y
      PCI: Clear bridge resource flags if requested size is 0 · 93d2175d
      Yinghai Lu 提交于
      During pci remove/rescan testing found:
      
        pci 0000:c0:03.0: PCI bridge to [bus c4-c9]
        pci 0000:c0:03.0:   bridge window [io  0x1000-0x0fff]
        pci 0000:c0:03.0:   bridge window [mem 0xf0000000-0xf00fffff]
        pci 0000:c0:03.0:   bridge window [mem 0xfc180000000-0xfc197ffffff 64bit pref]
        pci 0000:c0:03.0: device not available (can't reserve [io  0x1000-0x0fff])
        pci 0000:c0:03.0: Error enabling bridge (-22), continuing
        pci 0000:c0:03.0: enabling bus mastering
        pci 0000:c0:03.0: setting latency timer to 64
        pcieport 0000:c0:03.0: device not available (can't reserve [io  0x1000-0x0fff])
        pcieport: probe of 0000:c0:03.0 failed with error -22
      
      This bug was caused by commit c8adf9a3 ("PCI: pre-allocate
      additional resources to devices only after successful allocation of
      essential resources.")
      
      After that commit, pci_hotplug_io_size is changed to additional_io_size
      from minium size.  So it will not go through resource_size(res) != 0
      path, and will not be reset.
      
      The root cause is: pci_bridge_check_ranges will set RESOURCE_IO flag for
      pci bridge, and later if children do not need IO resource.  those bridge
      resources will not need to be allocated.  but flags is still there.
      that will confuse the the pci_enable_bridges later.
      
      related code:
      
         static void assign_requested_resources_sorted(struct resource_list *head,
                                          struct resource_list_x *fail_head)
         {
                 struct resource *res;
                 struct resource_list *list;
                 int idx;
      
                 for (list = head->next; list; list = list->next) {
                         res = list->res;
                         idx = res - &list->dev->resource[0];
                         if (resource_size(res) && pci_assign_resource(list->dev, idx)) {
         ...
                                 reset_resource(res);
                         }
                 }
         }
      
      At last, We have to clear the flags in pbus_size_mem/io when requested
      size == 0 and !add_head.  becasue this case it will not go through
      adjust_resources_sorted().
      
      Just make size1 = size0 when !add_head. it will make flags get cleared.
      
      At the same time when requested size == 0, add_size != 0, will still
      have in head and add_list.  because we do not clear the flags for it.
      
      After this, we will get right result:
      
        pci 0000:c0:03.0: PCI bridge to [bus c4-c9]
        pci 0000:c0:03.0:   bridge window [io  disabled]
        pci 0000:c0:03.0:   bridge window [mem 0xf0000000-0xf00fffff]
        pci 0000:c0:03.0:   bridge window [mem 0xfc180000000-0xfc197ffffff 64bit pref]
        pci 0000:c0:03.0: enabling bus mastering
        pci 0000:c0:03.0: setting latency timer to 64
        pcieport 0000:c0:03.0: setting latency timer to 64
        pcieport 0000:c0:03.0: irq 160 for MSI/MSI-X
        pcieport 0000:c0:03.0: Signaling PME through PCIe PME interrupt
        pci 0000:c4:00.0: Signaling PME through PCIe PME interrupt
        pcie_pme 0000:c0:03.0:pcie01: service driver pcie_pme loaded
        aer 0000:c0:03.0:pcie02: service driver aer loaded
        pciehp 0000:c0:03.0:pcie04: Hotplug Controller:
      
      v3: more simple fix. also fix one typo in pbus_size_mem
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Reviewed-by: NRam Pai <linuxram@us.ibm.com>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      93d2175d
  6. 12 4月, 2011 1 次提交
  7. 05 3月, 2011 4 次提交
    • R
      PCI: pre-allocate additional resources to devices only after successful... · c8adf9a3
      Ram Pai 提交于
      PCI: pre-allocate additional resources to devices only after successful allocation of essential resources.
      
      Linux tries to pre-allocate minimal resources to hotplug bridges. This
      works fine as long as there are enough resources  to satisfy all other
      genuine resource requirements. However if enough resources are not
      available to satisfy any of these nice-to-have pre-allocations, the
      resource-allocator reports errors and returns failure.
      
      This patch distinguishes between must-have resource from nice-to-have
      resource.  Any failure to allocate nice-to-have resources are ignored.
      
      This behavior can be particularly useful to trigger automatic
      reallocation when the OS discovers genuine allocation-conflicts or
      genuine unallocated-requests caused by buggy allocation behavior of the
      native BIOS/uEFI.
      
      https://bugzilla.kernel.org/show_bug.cgi?id=15960 captures the
      movitation behind the patch. This patch is verified to resolve the above
      bug.
      
          changelog v2:  o  fixed a bug where pci_assign_resource() was called on a
          		  resource of zero resource size.
      
          changelog v3:  addressed Bjorn's comment
          	       o  "Please don't indent and right-justify the changelog".
          	       o  removed add_size from struct resource.  The additional
          		  size is now tracked using a linked list.
      
          changelog v4:  o moved freeing up of elements in head list from
          		assign_requested_resources_sorted() to
          		__assign_resources_sorted().
          	       o removed a wrong reference to 'add_size' in
          			pbus_size_mem().
          	       o some code optimizations in adjust_resources_sorted()
          			and assign_requested_resources_sorted()
      
          changelog v5:  o moved freeing up of elements in head list from
          		assign_requested_resources_sorted() to
          		__assign_resources_sorted().
          	       o removed a wrong reference to 'add_size' in
          			pbus_size_mem().
          	       o some code optimizations in adjust_resources_sorted()
          			and assign_requested_resources_sorted()
      
          changelog v5:  o factored out common code and made them into
      		separate independent patches
          	       o added comments in kdoc format
      	       o added a BUG_ON in pci_assign_unassigned_resources()
      		 to catch for memory leak.
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      c8adf9a3
    • R
      PCI: introduce reset_resource() · fc075e1d
      Ram Pai 提交于
      Introduce reset_resource() which factors out resource reset logic.
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      fc075e1d
    • R
      PCI: data structure agnostic free list function · 094732a5
      Ram Pai 提交于
      Replace free_failed_list() with a free_list() call. free_list() can
      handle 'resource_list_x', 'resource_list' and any linked list linked
      through ->next
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      094732a5
    • R
      PCI: refactor io size calculation code · 13583b16
      Ram Pai 提交于
      Refactor code that calculates the io size in pbus_size_io() and
      pbus_mem_io() into separate functions.
      Signed-off-by: NRam Pai <linuxram@us.ibm.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      13583b16
  8. 31 7月, 2010 1 次提交
  9. 13 5月, 2010 1 次提交
  10. 01 3月, 2010 1 次提交
  11. 24 2月, 2010 1 次提交
  12. 23 2月, 2010 9 次提交
  13. 05 12月, 2009 1 次提交
  14. 05 11月, 2009 3 次提交
  15. 28 10月, 2009 1 次提交
  16. 08 10月, 2009 1 次提交
    • Y
      PCI: get larger bridge ranges when space is available · 308cf8e1
      Yinghai Lu 提交于
      Found one system:
      [   71.120590] pci 0000:40:05.0: scanning behind bridge, config 4f4a40, pass 0
      [   71.138283] PCI: Scanning bus 0000:4a
      [   71.140341] pci 0000:4a:00.0: found [15b3:6278] class 000c06 header type 00
      [   71.157173] pci 0000:4a:00.0: reg 10 64bit mmio: [0x000000-0x0fffff]
      [   71.161697] pci 0000:4a:00.0: reg 18 64bit mmio pref: [0x000000-0x7fffff]
      [   71.179403] pci 0000:4a:00.0: reg 20 64bit mmio pref: [0x000000-0xfffffff]
      [   71.185366] pci 0000:4a:00.0: calling quirk_resource_alignment+0x0/0x1dd
      [   71.200846] pci 0000:4a:00.0: disabling ASPM on pre-1.1 PCIe device.  You can enable it with 'pcie_aspm=force'
      [   71.219623] PCI: Fixups for bus 0000:4a
      [   71.222194] pci 0000:40:05.0: bridge 32bit mmio: [0xcf000000-0xcf0fffff]
      [   71.238662] pci 0000:40:05.0: bridge 64bit mmio pref: [0xcd800000-0xcdffffff]
      [   71.255793] PCI: Bus scan for 0000:4a returning with max=4a
      
      Device needs a big pref mmio, but BIOS doesn't allocate mmio to it aside
      from a small MMIO range.  Later, the kernel will not allocate resources to
      that to the device:
      [   99.574030] pci 0000:4a:00.0: BAR 4: can't allocate mem resource [0xd0000000-0xcdffffff]
      [   99.580102] pci 0000:4a:00.0: BAR 2: got res [0xcd800000-0xcdffffff] bus [0xcd800000-0xcdffffff] flags 0x12120c
      [   99.602307] pci 0000:4a:00.0: BAR 2: moved to bus [0xcd800000-0xcdffffff] flags 0x12120c
      [   99.615991] pci 0000:4a:00.0: BAR 0: got res [0xcf000000-0xcf0fffff] bus [0xcf000000-0xcf0fffff] flags 0x120204
      [   99.634499] pci 0000:4a:00.0: BAR 0: moved to bus [0xcf000000-0xcf0fffff] flags 0x120204
      [   99.654318] pci 0000:40:05.0: PCI bridge, secondary bus 0000:4a
      [   99.658766] pci 0000:40:05.0:   IO window: disabled
      [   99.675478] pci 0000:40:05.0:   MEM window: 0xcf000000-0xcf0fffff
      [   99.681663] pci 0000:40:05.0:   PREFETCH window: 0x000000cd800000-0x000000cdffffff
      
      So try to get a big range in the pci bridge if there is no child using
      that range.  With the patch we get:
      [   99.104525] pci 0000:4a:00.0: BAR 4: got res [0xfc080000000-0xfc08fffffff] bus [0xfc080000000-0xfc08fffffff] flags 0x12120c
      [   99.123624] pci 0000:4a:00.0: BAR 4: moved to bus [0xfc080000000-0xfc08fffffff] flags 0x12120c
      [   99.131977] pci 0000:4a:00.0: BAR 2: got res [0xfc090000000-0xfc0907fffff] bus [0xfc090000000-0xfc0907fffff] flags 0x12120c
      [   99.149788] pci 0000:4a:00.0: BAR 2: moved to bus [0xfc090000000-0xfc0907fffff] flags 0x12120c
      [   99.169248] pci 0000:4a:00.0: BAR 0: got res [0xc0200000-0xc02fffff] bus [0xc0200000-0xc02fffff] flags 0x120204
      [   99.189508] pci 0000:4a:00.0: BAR 0: moved to bus [0xc0200000-0xc02fffff] flags 0x120204
      [   99.206402] pci 0000:40:05.0: PCI bridge, secondary bus 0000:4a
      [   99.210637] pci 0000:40:05.0:   IO window: disabled
      [   99.224856] pci 0000:40:05.0:   MEM window: 0xc0200000-0xc03fffff
      [   99.230019] pci 0000:40:05.0:   PREFETCH window: 0x000fc080000000-0x000fc097ffffff
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      308cf8e1
  17. 10 9月, 2009 1 次提交
  18. 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
  19. 12 6月, 2009 2 次提交
  20. 23 4月, 2009 1 次提交
  21. 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
  22. 21 3月, 2009 1 次提交
  23. 20 3月, 2009 1 次提交
  24. 08 1月, 2009 2 次提交