Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1242805 > unrolled thread
| Started by | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| First post | 2015-10-09 00:00 +0200 |
| Last post | 2015-10-09 00:50 +0200 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v7 00/60] PCI: Resource allocation cleanup for v4.4 Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:00 +0200
[PATCH v7 21/60] PCI: Get new realloc size for bridge for last try Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:00 +0200
[PATCH v7 03/60] sparc/PCI: Unify pci_register_region() Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:00 +0200
Re: [PATCH v7 03/60] sparc/PCI: Unify pci_register_region() Khalid Aziz <khalid.aziz@oracle.com> - 2015-10-09 18:20 +0200
[PATCH v7 42/60] PCI: Move saved required resource list out of required+optional assigning Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:10 +0200
[PATCH v7 58/60] PCI: Introduce resource_disabled() Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:50 +0200
Re: [v7,58/60] PCI: Introduce resource_disabled() Michael Ellerman <mpe@ellerman.id.au> - 2015-10-13 11:50 +0200
[PATCH v7 50/60] PCI: Allow bridge optional only io port resource required size to be 0 Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:50 +0200
[PATCH v7 28/60] PCI: Don't add too much optional size for hotplug bridge MMIO Yinghai Lu <yinghai@kernel.org> - 2015-10-09 00:50 +0200
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:00 +0200 |
| Subject | [PATCH v7 00/60] PCI: Resource allocation cleanup for v4.4 |
| Message-ID | <qhrex-7rq-3@gated-at.bofh.it> |
Hi,
After 5b28541552ef (PCI: Restrict 64-bit prefetchable bridge windows
to 64-bit resources), we have several reports on resource allocation
failure, and we try to fix the problem with resource clip, and find
more problems.
One is realloc fail with two graphics cards above 4G.
One is from sparc that have problem with clip as we don't parse
mem64 for it.
Other report is about pci remove/rescan does not work on some setup
when BIOS tend to allocate small bus size.
This patchset enhance resource allocation to address those problems.
patch 1-10: parse MEM64 for sparc and other system with OF
patch 11-15: MMIO64 allocation enhancement
treat non-pref mmio64 if parent bridges are all pcie.
restore old pref allocation logic if hostbridge does not support mmio64.
patch 16-18: FIXED resource handling during realloc
don't realloc resource if device firmware does not support bar change.
patch 19-22: bridge MMIO allocation with hotplug and last try.
treat optional as required on first try when hotplug.
MMIO size set to 0 for last try during realloc
patch 22-56: enhancement for mmio resource allocation:
optimize bus mmio alignment calculation.
optimize bus mmio optional alignment calculation.
add support for alt size to prefer small bus size to small bus alignment.
treat ROM bar as optional resource.
during allocation, will pick up best fit resource, and allocate near end.
patch 57: add pci=assign_pref_bars to clear and assign pref bars.
patch 58-59: don't clear resource when allocation fails
patch 60: don't try io port allocation if root bus does not have io port.
I put latest copy at:
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-v4.4-next
That is based on v4.3-rc4+.
Yijing and Wei Yang both tested the branch, and the patchset fixs rescan
problem, and is working well on powerpc setup.
Khalid Aziz tested on some sparc platforms that have different offset to
mem space start or support 64bit mmio.
Thanks
Yinghai
v2:
- fix resource_disabled allocation from powerpc
- other warnings that were found by Fengguang's build robot.
- io port alignment clean up.
- rebased to v4.2-rc2
- better for two alt_size support.
v3:
- fix reset bridge resource on last try: only with bridge resources
- remove/rescan path checking with old_size.
v4:
- Update changelog according to Bjorn.
- split calculate_size patch to two.
- use required instead of must.
v5:
- update changelog
- add one debug patch
- add one patch that get resource allocation near end of avialable window
v6:
- reorder patches according to Bjorn.
v7:
- add some patches that fix problems on sparc that Khalid Aziz found.
Yinghai Lu (60):
sparc/PCI: Add mem64 resource parsing for root bus
sparc/PCI: Use correct bus address to resource offset
sparc/PCI: Unify pci_register_region()
sparc/PCI: Reserve legacy mmio after PCI mmio
sparc/PCI: Add IORESOURCE_MEM_64 for 64-bit resource in OF parsing
sparc/PCI: Keep resource idx order with bridge register number
PCI: kill wrong quirk about M7101
powerpc/PCI: Keep resource idx order with bridge register number
powerpc/PCI: Add IORESOURCE_MEM_64 for 64-bit resource in OF parsing
OF/PCI: Add IORESOURCE_MEM_64 for 64-bit resource
PCI: Check pref compatible bit for mem64 resource of PCIe device
PCI: Only treat non-pref mmio64 as pref if all bridges have MEM_64
PCI: Add has_mem64 for struct host_bridge
PCI: Only treat non-pref mmio64 as pref if host bridge has mmio64
PCI: Restore pref MMIO allocation logic for host bridge without mmio64
PCI: Don't release fixed resource for realloc
PCI: Claim fixed resource during remove/rescan path
PCI: Set resource to FIXED for LSI devices
PCI: Separate realloc list checking after allocation
PCI: Treat optional as required in first try for bridge rescan
PCI: Get new realloc size for bridge for last try
PCI: Don't release sibling bridge resources during hotplug
PCI: Cleanup res_to_dev_res() printout
PCI: Reuse res_to_dev_res() in reassign_resources_sorted()
PCI: Use correct align for optional only resources during sorting
PCI: Optimize bus min_align/size calculation during sizing
PCI: Optimize bus align/size calculation for optional during sizing
PCI: Don't add too much optional size for hotplug bridge MMIO
PCI: Reorder resources list for required/optional resources
PCI: Remove duplicated code for resource sorting
PCI: Rename pdev_sort_resources() to pdev_assign_resources_prepare()
PCI: Treat ROM resource as optional during realloc
PCI: Add debug printout during releasing partial assigned resources
PCI: Simplify res reference using in __assign_resources_sorted()
PCI: Add __add_to_list()
PCI: Cache window alignment value during bus sizing
PCI: Check if resource is allocated before trying to assign one
PCI: Separate out save_resources()/restore_resources()
PCI: Move comment to pci_need_to_release()
PCI: Separate required+optional assigning to another function
PCI: Skip required+optional if there is no optional
PCI: Move saved required resource list out of required+optional assigning
PCI: Add alt_size ressource allocation support
PCI: Add support for more than two alt_size entries under same bridge
PCI: Fix size calculation with old_size on rescan path
PCI: Don't add too much optional size for hotplug bridge io
PCI: Move ISA io port align out of calculate_iosize()
PCI: Don't add too much io port for hotplug bridge with old size
PCI: Unify calculate_size() for io port and MMIO
PCI: Allow bridge optional only io port resource required size to be 0
PCI: Unify skip_ioresource_align()
PCI: Kill macro checking for bus io port sizing
resources: Split out __allocate_resource()
resources: Make allocate_resource() return best fit resource
PCI, x86: Allocate from high in available window for MMIO
PCI: Add debug print out for min_align and alt_size
PCI, x86: Add pci=assign_pref_bars to reallocate pref BARs
PCI: Introduce resource_disabled()
PCI: Don't set flags to 0 when assign resource fail
PCI: Only try to assign io port only for root bus that support it
arch/alpha/kernel/pci.c | 2 +-
arch/ia64/pci/pci.c | 4 +-
arch/microblaze/pci/pci-common.c | 23 +-
arch/mn10300/unit-asb2305/pci-asb2305.c | 4 +-
arch/mn10300/unit-asb2305/pci.c | 4 +-
arch/powerpc/kernel/pci-common.c | 27 +-
arch/powerpc/kernel/pci_of_scan.c | 12 +-
arch/powerpc/platforms/powernv/pci-ioda.c | 12 +-
arch/s390/pci/pci.c | 2 +-
arch/sparc/kernel/of_device_32.c | 5 +-
arch/sparc/kernel/of_device_64.c | 5 +-
arch/sparc/kernel/pci.c | 30 +-
arch/sparc/kernel/pci_common.c | 125 +--
arch/sparc/kernel/pci_impl.h | 5 +
arch/x86/include/asm/pci_x86.h | 2 +-
arch/x86/pci/common.c | 7 +-
arch/x86/pci/i386.c | 86 +-
arch/xtensa/kernel/pci.c | 4 +-
drivers/iommu/intel-iommu.c | 3 +-
drivers/of/address.c | 4 +-
drivers/pci/bus.c | 6 +-
drivers/pci/host/pcie-rcar.c | 2 +-
drivers/pci/hotplug/acpiphp_glue.c | 1 +
drivers/pci/iov.c | 2 +-
drivers/pci/pci.c | 3 +-
drivers/pci/pci.h | 4 +
drivers/pci/probe.c | 48 +-
drivers/pci/quirks.c | 55 +-
drivers/pci/rom.c | 2 +-
drivers/pci/setup-bus.c | 1312 +++++++++++++++++++++--------
drivers/pci/setup-res.c | 18 +-
include/asm-generic/pci-bridge.h | 2 +
include/linux/ioport.h | 6 +-
include/linux/pci.h | 6 +
kernel/resource.c | 175 +++-
35 files changed, 1461 insertions(+), 547 deletions(-)
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:00 +0200 |
| Subject | [PATCH v7 21/60] PCI: Get new realloc size for bridge for last try |
| Message-ID | <qhrog-7CK-47@gated-at.bofh.it> |
| In reply to | #1242805 |
Current realloc path would not shrink bridge resource through
pbus_size_mem() checking with the old size.
That cause problem: when "required+optional" resource allocation fails,
the cached bridge resource size will prevent "required" resource to get
allocated smaller resource.
Clear the old resource size for last try or third and later try.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=81431
Tested-by: TJ <linux@iam.tj>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 5505942..278cb6d 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1695,6 +1695,17 @@ static enum enable_type pci_realloc_detect(struct pci_bus *bus,
}
#endif
+static void reset_bridge_resource_size(struct pci_dev *dev,
+ struct resource *res)
+{
+ int idx = res - &dev->resource[0];
+
+ if (idx >= PCI_BRIDGE_RESOURCES && idx <= PCI_BRIDGE_RESOURCE_END) {
+ res->start = 0;
+ res->end = res->start - 1;
+ }
+}
+
/*
* first try will not touch pci bridge res
* second and later try will clear small leaf bridge res
@@ -1779,8 +1790,13 @@ again:
res->start = fail_res->start;
res->end = fail_res->end;
res->flags = fail_res->flags;
- if (fail_res->dev->subordinate)
+ if (fail_res->dev->subordinate) {
res->flags = 0;
+ /* last or third times and later */
+ if (tried_times + 1 == pci_try_num ||
+ tried_times + 1 > 2)
+ reset_bridge_resource_size(fail_res->dev, res);
+ }
}
free_list(&fail_head);
@@ -1854,8 +1870,11 @@ again:
res->start = fail_res->start;
res->end = fail_res->end;
res->flags = fail_res->flags;
- if (fail_res->dev->subordinate)
+ if (fail_res->dev->subordinate) {
res->flags = 0;
+ /* last time */
+ reset_bridge_resource_size(fail_res->dev, res);
+ }
}
free_list(&fail_head);
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:00 +0200 |
| Subject | [PATCH v7 03/60] sparc/PCI: Unify pci_register_region() |
| Message-ID | <qhrog-7CK-51@gated-at.bofh.it> |
| In reply to | #1242805 |
We register regions for legacy and iommu and all have open code.
Unify them to pci_register_region() and call it accordingly.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/sparc/kernel/pci_common.c | 83 +++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 46 deletions(-)
diff --git a/arch/sparc/kernel/pci_common.c b/arch/sparc/kernel/pci_common.c
index 28e976a..c4b6989 100644
--- a/arch/sparc/kernel/pci_common.c
+++ b/arch/sparc/kernel/pci_common.c
@@ -328,41 +328,49 @@ void pci_get_pbm_props(struct pci_pbm_info *pbm)
}
}
-static void pci_register_legacy_regions(struct resource *io_res,
- struct resource *mem_res)
+static void pci_register_region(struct pci_pbm_info *pbm, const char *name,
+ resource_size_t rstart, resource_size_t size)
{
- struct resource *p;
+ struct resource *res, *conflict;
+ struct resource *mem_res = &pbm->mem_space;
+ resource_size_t offset = pbm->mem_offset;
+ resource_size_t mem_rstart, mem_rend;
+ resource_size_t rend = rstart + size - 1UL;
- /* VGA Video RAM. */
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
+ if (!mem_res->flags)
return;
- p->name = "Video RAM area";
- p->start = mem_res->start + 0xa0000UL;
- p->end = p->start + 0x1ffffUL;
- p->flags = IORESOURCE_BUSY;
- request_resource(mem_res, p);
+ mem_rstart = mem_res->start - offset;
+ mem_rend = mem_res->end - offset;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
+ /* contain checking */
+ if (!(mem_rstart <= rstart && mem_rend >= rend))
return;
- p->name = "System ROM";
- p->start = mem_res->start + 0xf0000UL;
- p->end = p->start + 0xffffUL;
- p->flags = IORESOURCE_BUSY;
- request_resource(mem_res, p);
-
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
+ res = kzalloc(sizeof(*res), GFP_KERNEL);
+ if (!res)
return;
- p->name = "Video ROM";
- p->start = mem_res->start + 0xc0000UL;
- p->end = p->start + 0x7fffUL;
- p->flags = IORESOURCE_BUSY;
- request_resource(mem_res, p);
+ res->name = name;
+ res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+ res->start = rstart + offset;
+ res->end = rend + offset;
+ conflict = request_resource_conflict(mem_res, res);
+ if (conflict) {
+ printk(KERN_DEBUG "PCI: %s can't claim %s %pR: address conflict with %s %pR\n",
+ pbm->name, res->name, res, conflict->name, conflict);
+ kfree(res);
+ }
+}
+
+static void pci_register_legacy_regions(struct pci_pbm_info *pbm)
+{
+ /* VGA Video RAM. */
+ pci_register_region(pbm, "Video RAM area", 0xa0000UL, 0x20000UL);
+
+ pci_register_region(pbm, "System ROM", 0xf0000UL, 0x10000UL);
+
+ pci_register_region(pbm, "Video ROM", 0xc0000UL, 0x8000UL);
}
static void pci_register_iommu_region(struct pci_pbm_info *pbm)
@@ -370,24 +378,8 @@ static void pci_register_iommu_region(struct pci_pbm_info *pbm)
const u32 *vdma = of_get_property(pbm->op->dev.of_node, "virtual-dma",
NULL);
- if (vdma) {
- struct resource *rp = kzalloc(sizeof(*rp), GFP_KERNEL);
-
- if (!rp) {
- pr_info("%s: Cannot allocate IOMMU resource.\n",
- pbm->name);
- return;
- }
- rp->name = "IOMMU";
- rp->start = pbm->mem_space.start + (unsigned long) vdma[0];
- rp->end = rp->start + (unsigned long) vdma[1] - 1UL;
- rp->flags = IORESOURCE_BUSY;
- if (request_resource(&pbm->mem_space, rp)) {
- pr_info("%s: Unable to request IOMMU resource.\n",
- pbm->name);
- kfree(rp);
- }
- }
+ if (vdma)
+ pci_register_region(pbm, "IOMMU", vdma[0], vdma[1]);
}
void pci_determine_mem_io_space(struct pci_pbm_info *pbm)
@@ -506,8 +498,7 @@ void pci_determine_mem_io_space(struct pci_pbm_info *pbm)
if (pbm->mem64_space.flags)
request_resource(&iomem_resource, &pbm->mem64_space);
- pci_register_legacy_regions(&pbm->io_space,
- &pbm->mem_space);
+ pci_register_legacy_regions(pbm);
pci_register_iommu_region(pbm);
}
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Khalid Aziz <khalid.aziz@oracle.com> |
|---|---|
| Date | 2015-10-09 18:20 +0200 |
| Subject | Re: [PATCH v7 03/60] sparc/PCI: Unify pci_register_region() |
| Message-ID | <qhIyK-7ea-21@gated-at.bofh.it> |
| In reply to | #1242808 |
On Thu, 2015-10-08 at 14:38 -0700, Yinghai Lu wrote: > We register regions for legacy and iommu and all have open code. > > Unify them to pci_register_region() and call it accordingly. > > Signed-off-by: Yinghai Lu <yinghai@kernel.org> Tested on sparc platforms Tested-by: Khalid Aziz <khalid.aziz@oracle.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:10 +0200 |
| Subject | [PATCH v7 42/60] PCI: Move saved required resource list out of required+optional assigning |
| Message-ID | <qhrxT-83b-11@gated-at.bofh.it> |
| In reply to | #1242805 |
We will need to share saved required list for alt_size support, so move
it out from required+optional assigning.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 5143ea2..ede619c 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -456,6 +456,9 @@ static bool has_addon(struct list_head *head,
int add_count = 0;
struct pci_dev_resource *dev_res, *tmp_res;
+ if (!realloc_head)
+ return false;
+
/* check if we have add really */
list_for_each_entry(dev_res, head, list) {
tmp_res = res_to_dev_res(realloc_head, dev_res->res);
@@ -492,9 +495,9 @@ static void restore_resource(struct pci_dev_resource *save_res,
}
static bool __assign_resources_required_optional_sorted(struct list_head *head,
+ struct list_head *save_head,
struct list_head *realloc_head)
{
- LIST_HEAD(save_head);
LIST_HEAD(local_fail_head);
struct pci_dev_resource *save_res;
struct pci_dev_resource *dev_res, *tmp_res;
@@ -502,12 +505,6 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head,
resource_size_t add_align, add_size;
struct resource *res;
- if (!has_addon(head, realloc_head))
- return false;
-
- if (!save_resources(head, &save_head))
- return false;
-
/* Update res in head list with add_size in realloc_head list */
list_for_each_entry(dev_res, head, list) {
res = dev_res->res;
@@ -548,7 +545,6 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head,
/* Remove head list from realloc_head list */
list_for_each_entry(dev_res, head, list)
remove_from_list(realloc_head, dev_res->res);
- free_list(&save_head);
free_list(head);
return true;
@@ -562,7 +558,7 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head,
if (res->parent && !pci_need_to_release(fail_type, res)) {
/* remove it from realloc_head list */
remove_from_list(realloc_head, res);
- remove_from_list(&save_head, res);
+ remove_from_list(save_head, res);
list_del(&dev_res->list);
kfree(dev_res);
}
@@ -581,11 +577,9 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head,
}
}
/* Restore start/end/flags from saved list */
- list_for_each_entry(save_res, &save_head, list)
+ list_for_each_entry(save_res, save_head, list)
restore_resource(save_res, save_res->res);
- free_list(&save_head);
-
return false;
}
@@ -603,16 +597,24 @@ static void __assign_resources_sorted(struct list_head *head,
* then try to reassign add_size for some resources.
*/
+ LIST_HEAD(save_head);
+
/* Check required+optional add */
- if (realloc_head &&
- __assign_resources_required_optional_sorted(head, realloc_head))
+ if (has_addon(head, realloc_head) &&
+ save_resources(head, &save_head) &&
+ __assign_resources_required_optional_sorted(head, &save_head,
+ realloc_head)) {
+ free_list(&save_head);
return;
+ }
sort_resources(head);
/* Satisfy the must-have resource requests */
assign_requested_resources_sorted(head, fail_head);
+ free_list(&save_head);
+
/* Try to satisfy any additional optional resource
requests */
if (realloc_head)
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:50 +0200 |
| Subject | [PATCH v7 58/60] PCI: Introduce resource_disabled() |
| Message-ID | <qhsaB-kH-1@gated-at.bofh.it> |
| In reply to | #1242805 |
Current is using !flags, and we are going to use
IORESOURCE_DISABLED instead of clearing resource flags.
Let's convert all !flags to helper function resource_disabled().
resource_disabled will check !flags and IORESOURCE_DISABLED both.
Cc: linux-alpha@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-am33-list@redhat.com
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s390@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: linux-xtensa@linux-xtensa.org
Cc: iommu@lists.linux-foundation.org
Cc: linux-sh@vger.kernel.org
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/alpha/kernel/pci.c | 2 +-
arch/ia64/pci/pci.c | 4 ++--
arch/microblaze/pci/pci-common.c | 15 ++++++++-------
arch/mn10300/unit-asb2305/pci-asb2305.c | 4 ++--
arch/mn10300/unit-asb2305/pci.c | 4 ++--
arch/powerpc/kernel/pci-common.c | 16 +++++++++-------
arch/powerpc/platforms/powernv/pci-ioda.c | 12 ++++++------
arch/s390/pci/pci.c | 2 +-
arch/sparc/kernel/pci.c | 2 +-
arch/x86/pci/i386.c | 4 ++--
arch/xtensa/kernel/pci.c | 4 ++--
drivers/iommu/intel-iommu.c | 3 ++-
drivers/pci/host/pcie-rcar.c | 2 +-
drivers/pci/iov.c | 2 +-
drivers/pci/probe.c | 2 +-
drivers/pci/quirks.c | 4 ++--
drivers/pci/rom.c | 2 +-
drivers/pci/setup-bus.c | 8 ++++----
drivers/pci/setup-res.c | 2 +-
include/linux/ioport.h | 4 ++++
20 files changed, 53 insertions(+), 45 deletions(-)
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5f387ee..c89c8ef 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -282,7 +282,7 @@ pcibios_claim_one_bus(struct pci_bus *b)
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
- if (r->parent || !r->start || !r->flags)
+ if (r->parent || !r->start || resource_disabled(r))
continue;
if (pci_has_flag(PCI_PROBE_ONLY) ||
(r->flags & IORESOURCE_PCI_FIXED)) {
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 7cc3be9..cc293ea 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -501,7 +501,7 @@ void pcibios_fixup_device_resources(struct pci_dev *dev)
for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) {
struct resource *r = &dev->resource[idx];
- if (!r->flags || r->parent || !r->start)
+ if (resource_disabled(r) || r->parent || !r->start)
continue;
pci_claim_resource(dev, idx);
@@ -519,7 +519,7 @@ static void pcibios_fixup_bridge_resources(struct pci_dev *dev)
for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
struct resource *r = &dev->resource[idx];
- if (!r->flags || r->parent || !r->start)
+ if (resource_disabled(r) || r->parent || !r->start)
continue;
pci_claim_bridge_resource(dev, idx);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 09b1af6..c123d3c 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -705,7 +705,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev)
}
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
struct resource *res = dev->resource + i;
- if (!res->flags)
+ if (resource_disabled(res))
continue;
if (res->start == 0) {
pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]",
@@ -806,7 +806,7 @@ static void pcibios_fixup_bridge(struct pci_bus *bus)
pci_bus_for_each_resource(bus, res, i) {
if (!res)
continue;
- if (!res->flags)
+ if (resource_disabled(res))
continue;
if (i >= 3 && bus->self->transparent)
continue;
@@ -985,7 +985,7 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
pci_domain_nr(bus), bus->number);
pci_bus_for_each_resource(bus, res, i) {
- if (!res || !res->flags
+ if (!res || resource_disabled(res)
|| res->start > res->end || res->parent)
continue;
if (bus->parent == NULL)
@@ -1087,7 +1087,8 @@ static void __init pcibios_allocate_resources(int pass)
r = &dev->resource[idx];
if (r->parent) /* Already allocated */
continue;
- if (!r->flags || (r->flags & IORESOURCE_UNSET))
+ if (resource_disabled(r) ||
+ (r->flags & IORESOURCE_UNSET))
continue; /* Not assigned at all */
/* We only allocate ROMs on pass 1 just in case they
* have been screwed up by firmware
@@ -1218,7 +1219,7 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
- if (r->parent || !r->start || !r->flags)
+ if (r->parent || !r->start || resource_disabled(r))
continue;
pr_debug("PCI: Claiming %s: ", pci_name(dev));
@@ -1278,7 +1279,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
res->start = (res->start + io_offset) & 0xffffffffu;
res->end = (res->end + io_offset) & 0xffffffffu;
- if (!res->flags) {
+ if (resource_disabled(res)) {
pr_warn("PCI: I/O resource not set for host ");
pr_cont("bridge %s (domain %d)\n",
hose->dn->full_name, hose->global_number);
@@ -1298,7 +1299,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
/* Hookup PHB Memory resources */
for (i = 0; i < 3; ++i) {
res = &hose->mem_resources[i];
- if (!res->flags) {
+ if (resource_disabled(res)) {
if (i > 0)
continue;
pr_err("PCI: Memory resource 0 not set for ");
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c
index b7ab837..7e70e51 100644
--- a/arch/mn10300/unit-asb2305/pci-asb2305.c
+++ b/arch/mn10300/unit-asb2305/pci-asb2305.c
@@ -103,7 +103,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
idx < PCI_NUM_RESOURCES;
idx++) {
r = &dev->resource[idx];
- if (!r->flags)
+ if (resource_disabled(r))
continue;
if (!r->start ||
pci_claim_bridge_resource(dev, idx) < 0) {
@@ -188,7 +188,7 @@ static int __init pcibios_assign_resources(void)
addresses. */
for_each_pci_dev(dev) {
r = &dev->resource[PCI_ROM_RESOURCE];
- if (!r->flags || !r->start)
+ if (resource_disabled(r) || !r->start)
continue;
if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
r->end -= r->start;
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 3dfe2d3..ad77b18 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -291,7 +291,7 @@ static void pcibios_fixup_device_resources(struct pci_dev *dev)
for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) {
struct resource *r = &dev->resource[idx];
- if (!r->flags || r->parent || !r->start)
+ if (resource_disabled(r) || r->parent || !r->start)
continue;
pci_claim_resource(dev, idx);
@@ -308,7 +308,7 @@ static void pcibios_fixup_bridge_resources(struct pci_dev *dev)
for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
struct resource *r = &dev->resource[idx];
- if (!r->flags || r->parent || !r->start)
+ if (resource_disabled(r) || r->parent || !r->start)
continue;
pci_claim_bridge_resource(dev, idx);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 8853667..a830e0c 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -810,7 +810,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev)
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
struct resource *res = dev->resource + i;
struct pci_bus_region reg;
- if (!res->flags)
+ if (resource_disabled(res))
continue;
/* If we're going to re-assign everything, we mark all resources
@@ -919,7 +919,7 @@ static void pcibios_fixup_bridge(struct pci_bus *bus)
struct pci_dev *dev = bus->self;
pci_bus_for_each_resource(bus, res, i) {
- if (!res || !res->flags)
+ if (!res || resource_disabled(res))
continue;
if (i >= 3 && bus->self->transparent)
continue;
@@ -1160,7 +1160,8 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
pci_domain_nr(bus), bus->number);
pci_bus_for_each_resource(bus, res, i) {
- if (!res || !res->flags || res->start > res->end || res->parent)
+ if (!res || resource_disabled(res) ||
+ res->start > res->end || res->parent)
continue;
/* If the resource was left unset at this point, we clear it */
@@ -1255,7 +1256,8 @@ static void __init pcibios_allocate_resources(int pass)
r = &dev->resource[idx];
if (r->parent) /* Already allocated */
continue;
- if (!r->flags || (r->flags & IORESOURCE_UNSET))
+ if (resource_disabled(r) ||
+ (r->flags & IORESOURCE_UNSET))
continue; /* Not assigned at all */
/* We only allocate ROMs on pass 1 just in case they
* have been screwed up by firmware
@@ -1393,7 +1395,7 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
- if (r->parent || !r->start || !r->flags)
+ if (r->parent || !r->start || resource_disabled(r))
continue;
pr_debug("PCI: Claiming %s: Resource %d: %pR\n",
@@ -1474,7 +1476,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
/* Hookup PHB IO resource */
res = &hose->io_resource;
- if (!res->flags) {
+ if (resource_disabled(res)) {
pr_info("PCI: I/O resource not set for host"
" bridge %s (domain %d)\n",
hose->dn->full_name, hose->global_number);
@@ -1489,7 +1491,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
/* Hookup PHB Memory resources */
for (i = 0; i < 3; ++i) {
res = &hose->mem_resources[i];
- if (!res->flags) {
+ if (resource_disabled(res)) {
if (i == 0)
printk(KERN_ERR "PCI: Memory resource 0 not set for "
"host bridge %s (domain %d)\n",
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 414fd1a..81484c1 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -874,7 +874,7 @@ static int pnv_pci_vf_resource_shift(struct pci_dev *dev, int offset)
num_vfs = pdn->num_vfs;
for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
res = &dev->resource[i + PCI_IOV_RESOURCES];
- if (!res->flags || !res->parent)
+ if (resource_disabled(res) || !res->parent)
continue;
if (!pnv_pci_is_mem_pref_64(res->flags))
@@ -905,7 +905,7 @@ static int pnv_pci_vf_resource_shift(struct pci_dev *dev, int offset)
*/
for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
res = &dev->resource[i + PCI_IOV_RESOURCES];
- if (!res->flags || !res->parent)
+ if (resource_disabled(res) || !res->parent)
continue;
if (!pnv_pci_is_mem_pref_64(res->flags))
@@ -1188,7 +1188,7 @@ static int pnv_pci_vf_assign_m64(struct pci_dev *pdev, u16 num_vfs)
for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
res = &pdev->resource[i + PCI_IOV_RESOURCES];
- if (!res->flags || !res->parent)
+ if (resource_disabled(res) || !res->parent)
continue;
if (!pnv_pci_is_mem_pref_64(res->flags))
@@ -2757,7 +2757,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
res = &pdev->resource[i + PCI_IOV_RESOURCES];
- if (!res->flags || res->parent)
+ if (resource_disabled(res) || res->parent)
continue;
if (!pnv_pci_is_mem_pref_64(res->flags)) {
dev_warn(&pdev->dev, " non M64 VF BAR%d: %pR\n",
@@ -2779,7 +2779,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
res = &pdev->resource[i + PCI_IOV_RESOURCES];
- if (!res->flags || res->parent)
+ if (resource_disabled(res) || res->parent)
continue;
if (!pnv_pci_is_mem_pref_64(res->flags)) {
dev_warn(&pdev->dev, "Skipping expanding VF BAR%d: %pR\n",
@@ -2820,7 +2820,7 @@ static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
BUG_ON(!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)));
pci_bus_for_each_resource(pe->pbus, res, i) {
- if (!res || !res->flags ||
+ if (!res || resource_disabled(res) ||
res->start > res->end)
continue;
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 7ef12a3..72c4676 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -653,7 +653,7 @@ int pcibios_add_device(struct pci_dev *pdev)
for (i = 0; i < PCI_BAR_COUNT; i++) {
res = &pdev->resource[i];
- if (res->parent || !res->flags)
+ if (res->parent || resource_disabled(res))
continue;
pci_claim_resource(pdev, i);
}
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 4113922..069e7ee 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -631,7 +631,7 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
- if (r->parent || !r->start || !r->flags)
+ if (r->parent || !r->start || resource_disabled(r))
continue;
if (ofpci_verbose)
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 6f27780..48c367c 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -224,7 +224,7 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev)
for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
r = &dev->resource[idx];
- if (!r->flags)
+ if (resource_disabled(r))
continue;
if (r->parent) /* Already allocated */
continue;
@@ -353,7 +353,7 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
* addresses.
*/
r = &dev->resource[PCI_ROM_RESOURCE];
- if (!r->flags || !r->start)
+ if (resource_disabled(r) || !r->start)
return;
if (r->parent) /* Already allocated */
return;
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index b848cc3..f34d061 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -142,7 +142,7 @@ static void __init pci_controller_apertures(struct pci_controller *pci_ctrl,
io_offset = (unsigned long)pci_ctrl->io_space.base;
res = &pci_ctrl->io_resource;
- if (!res->flags) {
+ if (resource_disabled(res)) {
if (io_offset)
printk (KERN_ERR "I/O resource not set for host"
" bridge %d\n", pci_ctrl->index);
@@ -156,7 +156,7 @@ static void __init pci_controller_apertures(struct pci_controller *pci_ctrl,
for (i = 0; i < 3; i++) {
res = &pci_ctrl->mem_resources[i];
- if (!res->flags) {
+ if (resource_disabled(res)) {
if (i > 0)
continue;
printk(KERN_ERR "Memory resource not set for "
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 041bc18..d4a06d2 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1771,7 +1771,8 @@ static int dmar_init_reserved_ranges(void)
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
r = &pdev->resource[i];
- if (!r->flags || !(r->flags & IORESOURCE_MEM))
+ if (resource_disabled(r) ||
+ !(r->flags & IORESOURCE_MEM))
continue;
iova = reserve_iova(&reserved_iova_list,
IOVA_PFN(r->start),
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 7678fe0..3f307a3 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -365,7 +365,7 @@ static int rcar_pcie_setup(int nr, struct pci_sys_data *sys)
for (i = 0; i < RCAR_PCI_MAX_RESOURCES; i++) {
res = &pcie->res[i];
- if (!res->flags)
+ if (resource_disabled(res))
continue;
rcar_pcie_setup_window(i, pcie);
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ee0ebff..808d08b 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -438,7 +438,7 @@ found:
res = &dev->resource[i + PCI_IOV_RESOURCES];
bar64 = __pci_read_base(dev, pci_bar_unknown, res,
pos + PCI_SRIOV_BAR + i * 4);
- if (!res->flags)
+ if (resource_disabled(res))
continue;
if (resource_size(res) & (PAGE_SIZE - 1)) {
rc = -EIO;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index edc8d08..f9589d9 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2203,7 +2203,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
struct resource *res = &b->busn_res;
int ret;
- if (!res->flags || !res->parent)
+ if (resource_disabled(res) || !res->parent)
return;
ret = release_resource(res);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6fe342c..f0f9873 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -336,7 +336,7 @@ static void quirk_bar_fixed(struct pci_dev *dev)
for (i = 0; i < PCI_STD_RESOURCE_END; i++) {
struct resource *r = &dev->resource[i];
- if (!r->start || !r->flags)
+ if (!r->start || resource_disabled(r))
continue;
r->flags |= IORESOURCE_PCI_FIXED;
}
@@ -350,7 +350,7 @@ static void quirk_allocate_fixed(struct pci_dev *dev)
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
- if (r->parent ||
+ if (r->parent || resource_disabled(r) ||
!(r->flags & IORESOURCE_PCI_FIXED) ||
!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
continue;
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index eb0ad53..585a9d3 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -28,7 +28,7 @@ int pci_enable_rom(struct pci_dev *pdev)
struct pci_bus_region region;
u32 rom_addr;
- if (!res->flags)
+ if (resource_disabled(res))
return -1;
pcibios_resource_to_bus(pdev->bus, ®ion, res);
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 673778c..23318bd 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -223,7 +223,7 @@ static void pdev_assign_resources_prepare(struct pci_dev *dev,
if (r->flags & IORESOURCE_PCI_FIXED)
continue;
- if (!(r->flags) || r->parent)
+ if (resource_disabled(r) || r->parent)
continue;
r_align = __pci_resource_alignment(dev, r, realloc_head);
@@ -319,7 +319,7 @@ static void reassign_resources_sorted(struct list_head *realloc_head,
list_for_each_entry_safe(add_res, tmp, realloc_head, list) {
res = add_res->res;
/* skip resource that has been reset */
- if (!res->flags)
+ if (resource_disabled(res))
goto out;
/* skip this resource if not found in head list */
@@ -2124,7 +2124,7 @@ static void pci_bus_dump_res(struct pci_bus *bus)
int i;
pci_bus_for_each_resource(bus, res, i) {
- if (!res || !res->end || !res->flags)
+ if (!res || !res->end || resource_disabled(res))
continue;
dev_printk(KERN_DEBUG, &bus->dev, "resource %d %pR\n", i, res);
@@ -2207,7 +2207,7 @@ static int iov_resources_unassigned(struct pci_dev *dev, void *data)
struct pci_bus_region region;
/* Not assigned or rejected by kernel? */
- if (!r->flags)
+ if (resource_disabled(r))
continue;
pcibios_resource_to_bus(dev->bus, ®ion, r);
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 26aedde..55caf7a 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -40,7 +40,7 @@ void pci_update_resource(struct pci_dev *dev, int resno)
* Ignore resources for unimplemented BARs and unused resource slots
* for 64 bit BARs.
*/
- if (!res->flags)
+ if (resource_disabled(res))
return;
if (res->flags & IORESOURCE_UNSET)
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 27dbb18..fb21179 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -179,6 +179,10 @@ static inline bool resource_contains(struct resource *r1, struct resource *r2)
return r1->start <= r2->start && r1->end >= r2->end;
}
+static inline bool resource_disabled(struct resource *r)
+{
+ return !r->flags || (r->flags & IORESOURCE_DISABLED);
+}
/* Convenience shorthand with allocation */
#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name), 0)
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2015-10-13 11:50 +0200 |
| Subject | Re: [v7,58/60] PCI: Introduce resource_disabled() |
| Message-ID | <qj4nw-2GQ-19@gated-at.bofh.it> |
| In reply to | #1242824 |
On Thu, 2015-08-10 at 21:39:17 UTC, Yinghai Lu wrote:
> Current is using !flags, and we are going to use
> IORESOURCE_DISABLED instead of clearing resource flags.
>
> Let's convert all !flags to helper function resource_disabled().
> resource_disabled will check !flags and IORESOURCE_DISABLED both.
>
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 8853667..a830e0c 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -810,7 +810,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev)
> for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> struct resource *res = dev->resource + i;
> struct pci_bus_region reg;
> - if (!res->flags)
> + if (resource_disabled(res))
> continue;
>
> /* If we're going to re-assign everything, we mark all resources
> @@ -919,7 +919,7 @@ static void pcibios_fixup_bridge(struct pci_bus *bus)
> struct pci_dev *dev = bus->self;
>
> pci_bus_for_each_resource(bus, res, i) {
> - if (!res || !res->flags)
> + if (!res || resource_disabled(res))
> continue;
> if (i >= 3 && bus->self->transparent)
> continue;
> @@ -1160,7 +1160,8 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
> pci_domain_nr(bus), bus->number);
>
> pci_bus_for_each_resource(bus, res, i) {
> - if (!res || !res->flags || res->start > res->end || res->parent)
> + if (!res || resource_disabled(res) ||
> + res->start > res->end || res->parent)
> continue;
>
> /* If the resource was left unset at this point, we clear it */
> @@ -1255,7 +1256,8 @@ static void __init pcibios_allocate_resources(int pass)
> r = &dev->resource[idx];
> if (r->parent) /* Already allocated */
> continue;
> - if (!r->flags || (r->flags & IORESOURCE_UNSET))
> + if (resource_disabled(r) ||
> + (r->flags & IORESOURCE_UNSET))
> continue; /* Not assigned at all */
> /* We only allocate ROMs on pass 1 just in case they
> * have been screwed up by firmware
> @@ -1393,7 +1395,7 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
> for (i = 0; i < PCI_NUM_RESOURCES; i++) {
> struct resource *r = &dev->resource[i];
>
> - if (r->parent || !r->start || !r->flags)
> + if (r->parent || !r->start || resource_disabled(r))
> continue;
>
> pr_debug("PCI: Claiming %s: Resource %d: %pR\n",
> @@ -1474,7 +1476,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
> /* Hookup PHB IO resource */
> res = &hose->io_resource;
>
> - if (!res->flags) {
> + if (resource_disabled(res)) {
> pr_info("PCI: I/O resource not set for host"
> " bridge %s (domain %d)\n",
> hose->dn->full_name, hose->global_number);
> @@ -1489,7 +1491,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
> /* Hookup PHB Memory resources */
> for (i = 0; i < 3; ++i) {
> res = &hose->mem_resources[i];
> - if (!res->flags) {
> + if (resource_disabled(res)) {
> if (i == 0)
> printk(KERN_ERR "PCI: Memory resource 0 not set for "
> "host bridge %s (domain %d)\n",
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 414fd1a..81484c1 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -874,7 +874,7 @@ static int pnv_pci_vf_resource_shift(struct pci_dev *dev, int offset)
> num_vfs = pdn->num_vfs;
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> res = &dev->resource[i + PCI_IOV_RESOURCES];
> - if (!res->flags || !res->parent)
> + if (resource_disabled(res) || !res->parent)
> continue;
>
> if (!pnv_pci_is_mem_pref_64(res->flags))
> @@ -905,7 +905,7 @@ static int pnv_pci_vf_resource_shift(struct pci_dev *dev, int offset)
> */
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> res = &dev->resource[i + PCI_IOV_RESOURCES];
> - if (!res->flags || !res->parent)
> + if (resource_disabled(res) || !res->parent)
> continue;
>
> if (!pnv_pci_is_mem_pref_64(res->flags))
> @@ -1188,7 +1188,7 @@ static int pnv_pci_vf_assign_m64(struct pci_dev *pdev, u16 num_vfs)
>
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> res = &pdev->resource[i + PCI_IOV_RESOURCES];
> - if (!res->flags || !res->parent)
> + if (resource_disabled(res) || !res->parent)
> continue;
>
> if (!pnv_pci_is_mem_pref_64(res->flags))
> @@ -2757,7 +2757,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
>
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> res = &pdev->resource[i + PCI_IOV_RESOURCES];
> - if (!res->flags || res->parent)
> + if (resource_disabled(res) || res->parent)
> continue;
> if (!pnv_pci_is_mem_pref_64(res->flags)) {
> dev_warn(&pdev->dev, " non M64 VF BAR%d: %pR\n",
> @@ -2779,7 +2779,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
>
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> res = &pdev->resource[i + PCI_IOV_RESOURCES];
> - if (!res->flags || res->parent)
> + if (resource_disabled(res) || res->parent)
> continue;
> if (!pnv_pci_is_mem_pref_64(res->flags)) {
> dev_warn(&pdev->dev, "Skipping expanding VF BAR%d: %pR\n",
> @@ -2820,7 +2820,7 @@ static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
> BUG_ON(!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)));
>
> pci_bus_for_each_resource(pe->pbus, res, i) {
> - if (!res || !res->flags ||
> + if (!res || resource_disabled(res) ||
> res->start > res->end)
> continue;
Those conversions all look correct to me.
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:50 +0200 |
| Subject | [PATCH v7 50/60] PCI: Allow bridge optional only io port resource required size to be 0 |
| Message-ID | <qhsaC-kH-7@gated-at.bofh.it> |
| In reply to | #1242805 |
When there is no child device under the non hotplug bridge,
We can use 0 for required size, and do not use old size as required size.
That will save some io port range for other bridges, as BIOS could do
some partial assign, and we want to use those not used io port range.
When there is child device, size will not be 0.
when the bridge supports hotplug, min_size will not be 0.
So they will still honor the old size as required size.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index a6eea60..bbc10d8 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1230,8 +1230,9 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
size = size_aligned_for_isa(size);
size += size1;
- size0 = calculate_size(size, min_size,
- resource_size(b_res), min_align);
+ if (size || min_size)
+ size0 = calculate_size(size, min_size,
+ resource_size(b_res), min_align);
sum_add_size = size_aligned_for_isa(sum_add_size);
sum_add_size += sum_add_size1;
if (sum_add_size < min_sum_size)
@@ -1247,7 +1248,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
return;
}
- b_res->start = min_align;
+ b_res->start = size0 ? min_align : 0;
b_res->end = b_res->start + size0 - 1;
b_res->flags |= IORESOURCE_STARTALIGN;
if (size1 > size0 && realloc_head) {
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-09 00:50 +0200 |
| Subject | [PATCH v7 28/60] PCI: Don't add too much optional size for hotplug bridge MMIO |
| Message-ID | <qhsaC-kH-13@gated-at.bofh.it> |
| In reply to | #1242805 |
Current code will always add 2M for hotplug bridge MMIO even
there is child device under it already.
For example:
40:03.0 --- 43:00.0 --- 44:02.0 -+- 45:00.0
\- 45:00.1
44:02.0 will need 1M as must for 45:00.0 and 45:00.1
When we calculate add_size for 44:02.0, we pass 2M as additional
size for hotplug bridge, total will be 3M.
That is different from code before changes for optional support,
or even current code that treat optional as required directly by
not passing realloc list. We only need 2M as total.
The optional size should be 1M, and total size should be 2M.
This patch change to comparing required+optional with min_sum_size to
get smaller optional size.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 0c6977c9..5e1cc7e 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1199,7 +1199,6 @@ out:
* @type2: second match type
* @type3: third match type
* @min_size : the minimum memory window that must to be allocated
- * @add_size : additional optional memory window
* @realloc_head : track the additional memory window on this list
*
* Calculate the size of the bus and minimal alignment which
@@ -1212,10 +1211,11 @@ out:
static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
unsigned long type, unsigned long type2,
unsigned long type3,
- resource_size_t min_size, resource_size_t add_size,
+ resource_size_t min_size,
struct list_head *realloc_head)
{
struct pci_dev *dev;
+ resource_size_t min_sum_size = 0;
resource_size_t min_align = 0, min_add_align = 0;
resource_size_t max_align = 0, max_add_align = 0;
resource_size_t size = 0, size0 = 0, size1 = 0, sum_add_size = 0;
@@ -1227,6 +1227,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
if (!b_res)
return -ENOSPC;
+ if (realloc_head) {
+ min_sum_size = min_size;
+ min_size = 0;
+ }
+
list_for_each_entry(dev, &bus->devices, bus_list) {
int i;
@@ -1298,8 +1303,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
}
free_align_test_list(&align_test_list);
- if ((sum_add_size - size) < add_size)
- sum_add_size = size + add_size;
+ if (sum_add_size < min_sum_size)
+ sum_add_size = min_sum_size;
if (sum_add_size > size && realloc_head) {
min_add_align = calculate_mem_align(&align_test_add_list,
max_add_align, sum_add_size,
@@ -1436,7 +1441,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
{
struct pci_dev *dev;
unsigned long mask, prefmask, type2 = 0, type3 = 0;
- resource_size_t additional_mem_size = 0, additional_io_size = 0;
+ resource_size_t min_mem_size = 0, additional_io_size = 0;
struct resource *b_res;
int ret;
@@ -1473,7 +1478,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
case PCI_CLASS_BRIDGE_PCI:
if (bus->self->is_hotplug_bridge) {
additional_io_size = pci_hotplug_io_size;
- additional_mem_size = pci_hotplug_mem_size;
+ min_mem_size = pci_hotplug_mem_size;
}
/* Fall through */
default:
@@ -1493,8 +1498,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
prefmask |= IORESOURCE_MEM_64;
ret = pbus_size_mem(bus, prefmask, prefmask,
prefmask, prefmask,
- realloc_head ? 0 : additional_mem_size,
- additional_mem_size, realloc_head);
+ min_mem_size, realloc_head);
/*
* If successful, all non-prefetchable resources
@@ -1517,8 +1521,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
prefmask &= ~IORESOURCE_MEM_64;
ret = pbus_size_mem(bus, prefmask, prefmask,
prefmask, prefmask,
- realloc_head ? 0 : additional_mem_size,
- additional_mem_size, realloc_head);
+ min_mem_size, realloc_head);
/*
* If successful, only non-prefetchable resources
@@ -1527,7 +1530,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
if (ret == 0)
mask = prefmask;
else
- additional_mem_size += additional_mem_size;
+ min_mem_size += min_mem_size;
type2 = type3 = IORESOURCE_MEM;
}
@@ -1548,8 +1551,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
* window.
*/
pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
- realloc_head ? 0 : additional_mem_size,
- additional_mem_size, realloc_head);
+ min_mem_size, realloc_head);
break;
}
}
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web