Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-11 Thread Wei Yang
On Thu, Jul 09, 2015 at 10:49:06PM -0700, Yinghai Lu wrote:
>On Thu, Jul 9, 2015 at 7:48 PM, Yinghai Lu  wrote:
>> On Thu, Jul 9, 2015 at 7:30 PM, Wei Yang  wrote:
>>> If you could update your for-pci-v4.3-next branch, that would be more
>>> convenient for me to do the test.
>>
>> Just updated that branch, please check it.
>>
>
>just updated the branch again.
>
>If you don't want to re get it again, please apply attached patch.

Yinghai,

I have tested you latest branch with this one as the last commit:

ec94cc7 PCI: Don't set flags to 0 when assign resource fail

My P8 machine boots up.

Another issue is the SRIOV couldn't be enabled, I am checking the reason. 
This may not related to this patch series.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-11 Thread Yinghai Lu
On Fri, Jul 10, 2015 at 5:03 PM, Wei Yang  wrote:
> On Thu, Jul 09, 2015 at 10:49:06PM -0700, Yinghai Lu wrote:

> I have tested you latest branch with this one as the last commit:
>
> ec94cc7 PCI: Don't set flags to 0 when assign resource fail
>
> My P8 machine boots up.

Good.

>
> Another issue is the SRIOV couldn't be enabled, I am checking the reason.
> This may not related to this patch series.

wonder if could be related to :

https://git.kernel.org/cgit/linux/kernel/git/yinghai/linux-yinghai.git/patch/?id=c642f79dcd6becbb92741816e0b5e81f7664acc7
PCI: Restore pref mmio allocation logic for hostbridge without mmio64

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-11 Thread Wei Yang
On Fri, Jul 10, 2015 at 05:42:10PM -0700, Yinghai Lu wrote:
>On Fri, Jul 10, 2015 at 5:03 PM, Wei Yang  wrote:
>> On Thu, Jul 09, 2015 at 10:49:06PM -0700, Yinghai Lu wrote:
>
>> I have tested you latest branch with this one as the last commit:
>>
>> ec94cc7 PCI: Don't set flags to 0 when assign resource fail
>>
>> My P8 machine boots up.
>
>Good.
>
>>
>> Another issue is the SRIOV couldn't be enabled, I am checking the reason.
>> This may not related to this patch series.
>
>wonder if could be related to :
>
>https://git.kernel.org/cgit/linux/kernel/git/yinghai/linux-yinghai.git/patch/?id=c642f79dcd6becbb92741816e0b5e81f7664acc7
>PCI: Restore pref mmio allocation logic for hostbridge without mmio64
>

Looks no.

I have tried to revert all your patches, still not work. Need to get more time
to investigate.

>Yinghai

-- 
Richard Yang
Help you, Help me

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-11 Thread Wei Yang
On Thu, Jul 09, 2015 at 10:49:06PM -0700, Yinghai Lu wrote:
On Thu, Jul 9, 2015 at 7:48 PM, Yinghai Lu ying...@kernel.org wrote:
 On Thu, Jul 9, 2015 at 7:30 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 If you could update your for-pci-v4.3-next branch, that would be more
 convenient for me to do the test.

 Just updated that branch, please check it.


just updated the branch again.

If you don't want to re get it again, please apply attached patch.

Yinghai,

I have tested you latest branch with this one as the last commit:

ec94cc7 PCI: Don't set flags to 0 when assign resource fail

My P8 machine boots up.

Another issue is the SRIOV couldn't be enabled, I am checking the reason. 
This may not related to this patch series.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-11 Thread Wei Yang
On Fri, Jul 10, 2015 at 05:42:10PM -0700, Yinghai Lu wrote:
On Fri, Jul 10, 2015 at 5:03 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 On Thu, Jul 09, 2015 at 10:49:06PM -0700, Yinghai Lu wrote:

 I have tested you latest branch with this one as the last commit:

 ec94cc7 PCI: Don't set flags to 0 when assign resource fail

 My P8 machine boots up.

Good.


 Another issue is the SRIOV couldn't be enabled, I am checking the reason.
 This may not related to this patch series.

wonder if could be related to :

https://git.kernel.org/cgit/linux/kernel/git/yinghai/linux-yinghai.git/patch/?id=c642f79dcd6becbb92741816e0b5e81f7664acc7
PCI: Restore pref mmio allocation logic for hostbridge without mmio64


Looks no.

I have tried to revert all your patches, still not work. Need to get more time
to investigate.

Yinghai

-- 
Richard Yang
Help you, Help me

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-11 Thread Yinghai Lu
On Fri, Jul 10, 2015 at 5:03 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 On Thu, Jul 09, 2015 at 10:49:06PM -0700, Yinghai Lu wrote:

 I have tested you latest branch with this one as the last commit:

 ec94cc7 PCI: Don't set flags to 0 when assign resource fail

 My P8 machine boots up.

Good.


 Another issue is the SRIOV couldn't be enabled, I am checking the reason.
 This may not related to this patch series.

wonder if could be related to :

https://git.kernel.org/cgit/linux/kernel/git/yinghai/linux-yinghai.git/patch/?id=c642f79dcd6becbb92741816e0b5e81f7664acc7
PCI: Restore pref mmio allocation logic for hostbridge without mmio64

Yinghai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Yinghai Lu
On Thu, Jul 9, 2015 at 7:48 PM, Yinghai Lu  wrote:
> On Thu, Jul 9, 2015 at 7:30 PM, Wei Yang  wrote:
>> If you could update your for-pci-v4.3-next branch, that would be more
>> convenient for me to do the test.
>
> Just updated that branch, please check it.
>

just updated the branch again.

If you don't want to re get it again, please apply attached patch.
---
 drivers/pci/bus.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/pci/bus.c
===
--- linux-2.6.orig/drivers/pci/bus.c
+++ linux-2.6/drivers/pci/bus.c
@@ -140,7 +140,7 @@ static int pci_bus_alloc_from_region(str
 	type_mask |= IORESOURCE_TYPE_BITS;
 
 	pci_bus_for_each_resource(bus, r, i) {
-		if (!r)
+		if (!r || resource_disabled(r))
 			continue;
 
 		/* type_mask must match */


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Yinghai Lu
On Thu, Jul 9, 2015 at 7:30 PM, Wei Yang  wrote:
> If you could update your for-pci-v4.3-next branch, that would be more
> convenient for me to do the test.

Just updated that branch, please check it.

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Wei Yang
On Thu, Jul 09, 2015 at 09:20:08AM -0700, Yinghai Lu wrote:
>On Wed, Jul 8, 2015 at 11:04 PM, Wei Yang  wrote:
>> This one is on top of the last one ? or replace the last one?
>
>should be just before last one.

I can't apply this on top of 

b0b9229 PCI, x86: Add pci=assign_pref_bars to re-allocate pref bars

If you could update your for-pci-v4.3-next branch, that would be more
convenient for me to do the test.


>
>Yinghai

-- 
Richard Yang
Help you, Help me

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Yinghai Lu
On Wed, Jul 8, 2015 at 11:04 PM, Wei Yang  wrote:
> This one is on top of the last one ? or replace the last one?

should be just before last one.

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Wei Yang
This one is on top of the last one ? or replace the last one?

On Wed, Jul 08, 2015 at 10:01:47PM -0700, Yinghai Lu wrote:
>On Wed, Jul 8, 2015 at 8:30 PM, Wei Yang  wrote:
>> Hi, Yinghai
>>
>> This patch may introduce some problem.
>>
>> On my P8 machine, after applying this patch, I see following error:
>>
>> [0.589948] pnv_ioda_setup_pe_seg: trigger IO SEG 0
>> [0.589992] pnv_ioda_setup_pe_seg: res[io  0x1000-0x3fff] 100
>>
>> The last 0x100 is the res->flags, which indicates the UNSET and DISABLED bit
>> is not set.
>
>Maybe we should introduce resource_disabled() for that.
>
>Please check if attached patch would fix the problem.
>
>Thanks
>
>Yinghai

>Subject: [PATCH] PCI: Introduce resource_disabled()
>
>so we can cover !flags and IORESOURCE_DISABLED both.
>
>Signed-off-by: Yinghai Lu 
>
>diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>index 82f738e..91a7153 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 = >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 = >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 = >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 ae838ed..67848f8 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;
>@@ -993,7 +993,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)
>@@ -1095,7 +1095,8 @@ static void __init pcibios_allocate_resources(int pass)
>   r = >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
>@@ -1226,7 +1227,7 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
>   for (i = 0; i < PCI_NUM_RESOURCES; i++) {
>   struct resource *r = >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));
>@@ -1286,7 +1287,7 @@ static void 

Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Yinghai Lu
On Thu, Jul 9, 2015 at 7:48 PM, Yinghai Lu ying...@kernel.org wrote:
 On Thu, Jul 9, 2015 at 7:30 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 If you could update your for-pci-v4.3-next branch, that would be more
 convenient for me to do the test.

 Just updated that branch, please check it.


just updated the branch again.

If you don't want to re get it again, please apply attached patch.
---
 drivers/pci/bus.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/pci/bus.c
===
--- linux-2.6.orig/drivers/pci/bus.c
+++ linux-2.6/drivers/pci/bus.c
@@ -140,7 +140,7 @@ static int pci_bus_alloc_from_region(str
 	type_mask |= IORESOURCE_TYPE_BITS;
 
 	pci_bus_for_each_resource(bus, r, i) {
-		if (!r)
+		if (!r || resource_disabled(r))
 			continue;
 
 		/* type_mask must match */


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Wei Yang
On Thu, Jul 09, 2015 at 09:20:08AM -0700, Yinghai Lu wrote:
On Wed, Jul 8, 2015 at 11:04 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 This one is on top of the last one ? or replace the last one?

should be just before last one.

I can't apply this on top of 

b0b9229 PCI, x86: Add pci=assign_pref_bars to re-allocate pref bars

If you could update your for-pci-v4.3-next branch, that would be more
convenient for me to do the test.



Yinghai

-- 
Richard Yang
Help you, Help me

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Yinghai Lu
On Thu, Jul 9, 2015 at 7:30 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 If you could update your for-pci-v4.3-next branch, that would be more
 convenient for me to do the test.

Just updated that branch, please check it.

Thanks

Yinghai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Wei Yang
This one is on top of the last one ? or replace the last one?

On Wed, Jul 08, 2015 at 10:01:47PM -0700, Yinghai Lu wrote:
On Wed, Jul 8, 2015 at 8:30 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 Hi, Yinghai

 This patch may introduce some problem.

 On my P8 machine, after applying this patch, I see following error:

 [0.589948] pnv_ioda_setup_pe_seg: trigger IO SEG 0
 [0.589992] pnv_ioda_setup_pe_seg: res[io  0x1000-0x3fff] 100

 The last 0x100 is the res-flags, which indicates the UNSET and DISABLED bit
 is not set.

Maybe we should introduce resource_disabled() for that.

Please check if attached patch would fix the problem.

Thanks

Yinghai

Subject: [PATCH] PCI: Introduce resource_disabled()

so we can cover !flags and IORESOURCE_DISABLED both.

Signed-off-by: Yinghai Lu ying...@kernel.org

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 82f738e..91a7153 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 ae838ed..67848f8 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;
@@ -993,7 +993,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)
@@ -1095,7 +1095,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
@@ -1226,7 +1227,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));
@@ -1286,7 +1287,7 @@ static void pcibios_setup_phb_resources(struct 
pci_controller *hose,
   res-start = (res-start + io_offset)  0xu;
   res-end = (res-end + 

Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-09 Thread Yinghai Lu
On Wed, Jul 8, 2015 at 11:04 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 This one is on top of the last one ? or replace the last one?

should be just before last one.

Yinghai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-08 Thread Yinghai Lu
On Wed, Jul 8, 2015 at 8:30 PM, Wei Yang  wrote:
> Hi, Yinghai
>
> This patch may introduce some problem.
>
> On my P8 machine, after applying this patch, I see following error:
>
> [0.589948] pnv_ioda_setup_pe_seg: trigger IO SEG 0
> [0.589992] pnv_ioda_setup_pe_seg: res[io  0x1000-0x3fff] 100
>
> The last 0x100 is the res->flags, which indicates the UNSET and DISABLED bit
> is not set.

Maybe we should introduce resource_disabled() for that.

Please check if attached patch would fix the problem.

Thanks

Yinghai
Subject: [PATCH] PCI: Introduce resource_disabled()

so we can cover !flags and IORESOURCE_DISABLED both.

Signed-off-by: Yinghai Lu 

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 82f738e..91a7153 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 = >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 = >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 = >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 ae838ed..67848f8 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;
@@ -993,7 +993,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)
@@ -1095,7 +1095,8 @@ static void __init pcibios_allocate_resources(int pass)
 			r = >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
@@ -1226,7 +1227,7 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
 		for (i = 0; i < PCI_NUM_RESOURCES; i++) {
 			struct resource *r = >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));
@@ -1286,7 +1287,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
 	res->start = (res->start + io_offset) & 0xu;
 	res->end = (res->end + io_offset) & 0xu;
 
-	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);
@@ -1306,7 +1307,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
 	/* Hookup PHB Memory resources */
 	for (i = 0; i < 3; ++i) {
 		res = >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 b5b036f..a249821 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 = >resource[idx];
-if (!r->flags)
+if (resource_disabled(r))
 	continue;
 if (!r->start 

Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-08 Thread Wei Yang
Hi, Yinghai

This patch may introduce some problem.

On my P8 machine, after applying this patch, I see following error:

[0.589948] pnv_ioda_setup_pe_seg: trigger IO SEG 0
[0.589992] pnv_ioda_setup_pe_seg: res[io  0x1000-0x3fff] 100

The last 0x100 is the res->flags, which indicates the UNSET and DISABLED bit
is not set.

On P8, we don't have IO window, which means the IO BAR will not be assigned.
And those io_segmap is not allocated. The following trace is printed since the
io_segmap is accessed, while it is NULL.

[0.590050] Unable to handle kernel paging request for data at address 
0x
[0.590115] Faulting instruction address: 0xc00759b8
[0.590172] Oops: Kernel access of bad area, sig: 11 [#1]
[0.590216] SMP NR_CPUS=1024 NUMA PowerNV
[0.590262] Modules linked in:
[0.590309] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.2.0-rc1eeh_refactor+ 
#244
[0.590375] task: c02ff438 ti: c02ff6084000 task.ti: 
c02ff6084000
[0.590440] NIP: c00759b8 LR: c0075960 CTR: 3004a1bc
[0.590506] REGS: c02ff6087620 TRAP: 0300   Not tainted  
(4.2.0-rc1eeh_refactor+)
[0.590572] MSR: 90009032   CR: 2228  XER: 
2000
[0.590727] CFAR: c0008468 DAR:  DSISR: 4200 
SOFTE: 1 
GPR00: c0075960 c02ff60878a0 c1534f00 0031 
GPR04: 0001 0003   
GPR08: 0006   03f2 
GPR12: 2222 cfda c0b82c88  
GPR16: 3fff  1000 c0b82cc8 
GPR20: c0b82c50 c0b82c70 c1452148 c02fffb2d900 
GPR24: c0923c40 c02fffb4c810 c02fffb4c300 00102000 
GPR28: c02fffb40720 c01ff42aa500 c02fffb4c580  
[0.591603] NIP [c00759b8] .pnv_pci_ioda_fixup+0xaa8/0xb20
[0.591658] LR [c0075960] .pnv_pci_ioda_fixup+0xa50/0xb20
[0.591713] Call Trace:
[0.591736] [c02ff60878a0] [c0075960] 
.pnv_pci_ioda_fixup+0xa50/0xb20 (unreliable)
[0.591824] [c02ff6087a40] [c0caf0a8] 
.pcibios_resource_survey+0x3a8/0x404
[0.591901] [c02ff6087b60] [c0cae7f0] .pcibios_init+0xa0/0xd4
[0.591968] [c02ff6087bf0] [c000ad30] 
.do_one_initcall+0x110/0x280
[0.592045] [c02ff6087ce0] [c0ca45c4] 
.kernel_init_freeable+0x274/0x35c
[0.592122] [c02ff6087db0] [c000b5e4] .kernel_init+0x24/0x140
[0.592188] [c02ff6087e30] [c00094e8] 
.ret_from_kernel_thread+0x58/0x70
[0.592265] Instruction dump:
[0.592298] 7d3107b4 7f084840 7e525214 7fb09040 4099f7b8 419cf7b4 e93e0180 
811c0024 
[0.592408] 7a2a1764 38a3 7a270420 38c0 <7d09512e> a09c0026 e87e0018 
4bff1c59 
[0.592524] ---[ end trace 856c9d223a60380c ]---
[0.593584] 
[2.593742] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x000b
[2.593742] 
[2.605223] Rebooting in 10 seconds..


On Mon, Jul 06, 2015 at 04:39:26PM -0700, Yinghai Lu wrote:
>make flags take IORESOURCE_UNSET | IORESOURCE_DISABLED instead.
>
>Signed-off-by: Yinghai Lu 
>---
> drivers/pci/setup-bus.c | 52 +
> drivers/pci/setup-res.c | 11 +++
> 2 files changed, 38 insertions(+), 25 deletions(-)
>
>diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
>index 9b27e15..e82655b 100644
>--- a/drivers/pci/setup-bus.c
>+++ b/drivers/pci/setup-bus.c
>@@ -255,7 +255,8 @@ static void pdev_check_resources(struct pci_dev *dev,
>   if (r->flags & IORESOURCE_PCI_FIXED)
>   continue;
>
>-  if (!(r->flags) || r->parent)
>+  if (!r->flags || r->parent ||
>+  (r->flags & IORESOURCE_DISABLED))
>   continue;
>
>   r_align = __pci_resource_alignment(dev, r, realloc_head);
>@@ -296,13 +297,6 @@ static void __dev_check_resources(struct pci_dev *dev,
>   pdev_check_resources(dev, realloc_head, head);
> }
>
>-static inline void reset_resource(struct resource *res)
>-{
>-  res->start = 0;
>-  res->end = 0;
>-  res->flags = 0;
>-}
>-
> static void __sort_resources(struct list_head *head)
> {
>   struct pci_dev_resource *res1, *tmp_res, *res2;
>@@ -387,7 +381,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 (res->flags & IORESOURCE_DISABLED)
>   goto out;
>
>   /* skip this resource if not found in head list */
>@@ -405,7 +399,7 @@ static void reassign_resources_sorted(struct list_head 
>*realloc_head,
>   

Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-08 Thread Yinghai Lu
On Wed, Jul 8, 2015 at 8:30 PM, Wei Yang weiy...@linux.vnet.ibm.com wrote:
 Hi, Yinghai

 This patch may introduce some problem.

 On my P8 machine, after applying this patch, I see following error:

 [0.589948] pnv_ioda_setup_pe_seg: trigger IO SEG 0
 [0.589992] pnv_ioda_setup_pe_seg: res[io  0x1000-0x3fff] 100

 The last 0x100 is the res-flags, which indicates the UNSET and DISABLED bit
 is not set.

Maybe we should introduce resource_disabled() for that.

Please check if attached patch would fix the problem.

Thanks

Yinghai
Subject: [PATCH] PCI: Introduce resource_disabled()

so we can cover !flags and IORESOURCE_DISABLED both.

Signed-off-by: Yinghai Lu ying...@kernel.org

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 82f738e..91a7153 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 ae838ed..67848f8 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;
@@ -993,7 +993,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)
@@ -1095,7 +1095,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
@@ -1226,7 +1227,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));
@@ -1286,7 +1287,7 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
 	res-start = (res-start + io_offset)  0xu;
 	res-end = (res-end + io_offset)  0xu;
 
-	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);
@@ -1306,7 +1307,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 b5b036f..a249821 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 ||
 

Re: [PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-08 Thread Wei Yang
Hi, Yinghai

This patch may introduce some problem.

On my P8 machine, after applying this patch, I see following error:

[0.589948] pnv_ioda_setup_pe_seg: trigger IO SEG 0
[0.589992] pnv_ioda_setup_pe_seg: res[io  0x1000-0x3fff] 100

The last 0x100 is the res-flags, which indicates the UNSET and DISABLED bit
is not set.

On P8, we don't have IO window, which means the IO BAR will not be assigned.
And those io_segmap is not allocated. The following trace is printed since the
io_segmap is accessed, while it is NULL.

[0.590050] Unable to handle kernel paging request for data at address 
0x
[0.590115] Faulting instruction address: 0xc00759b8
[0.590172] Oops: Kernel access of bad area, sig: 11 [#1]
[0.590216] SMP NR_CPUS=1024 NUMA PowerNV
[0.590262] Modules linked in:
[0.590309] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.2.0-rc1eeh_refactor+ 
#244
[0.590375] task: c02ff438 ti: c02ff6084000 task.ti: 
c02ff6084000
[0.590440] NIP: c00759b8 LR: c0075960 CTR: 3004a1bc
[0.590506] REGS: c02ff6087620 TRAP: 0300   Not tainted  
(4.2.0-rc1eeh_refactor+)
[0.590572] MSR: 90009032 SF,HV,EE,ME,IR,DR,RI  CR: 2228  XER: 
2000
[0.590727] CFAR: c0008468 DAR:  DSISR: 4200 
SOFTE: 1 
GPR00: c0075960 c02ff60878a0 c1534f00 0031 
GPR04: 0001 0003   
GPR08: 0006   03f2 
GPR12: 2222 cfda c0b82c88  
GPR16: 3fff  1000 c0b82cc8 
GPR20: c0b82c50 c0b82c70 c1452148 c02fffb2d900 
GPR24: c0923c40 c02fffb4c810 c02fffb4c300 00102000 
GPR28: c02fffb40720 c01ff42aa500 c02fffb4c580  
[0.591603] NIP [c00759b8] .pnv_pci_ioda_fixup+0xaa8/0xb20
[0.591658] LR [c0075960] .pnv_pci_ioda_fixup+0xa50/0xb20
[0.591713] Call Trace:
[0.591736] [c02ff60878a0] [c0075960] 
.pnv_pci_ioda_fixup+0xa50/0xb20 (unreliable)
[0.591824] [c02ff6087a40] [c0caf0a8] 
.pcibios_resource_survey+0x3a8/0x404
[0.591901] [c02ff6087b60] [c0cae7f0] .pcibios_init+0xa0/0xd4
[0.591968] [c02ff6087bf0] [c000ad30] 
.do_one_initcall+0x110/0x280
[0.592045] [c02ff6087ce0] [c0ca45c4] 
.kernel_init_freeable+0x274/0x35c
[0.592122] [c02ff6087db0] [c000b5e4] .kernel_init+0x24/0x140
[0.592188] [c02ff6087e30] [c00094e8] 
.ret_from_kernel_thread+0x58/0x70
[0.592265] Instruction dump:
[0.592298] 7d3107b4 7f084840 7e525214 7fb09040 4099f7b8 419cf7b4 e93e0180 
811c0024 
[0.592408] 7a2a1764 38a3 7a270420 38c0 7d09512e a09c0026 e87e0018 
4bff1c59 
[0.592524] ---[ end trace 856c9d223a60380c ]---
[0.593584] 
[2.593742] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x000b
[2.593742] 
[2.605223] Rebooting in 10 seconds..


On Mon, Jul 06, 2015 at 04:39:26PM -0700, Yinghai Lu wrote:
make flags take IORESOURCE_UNSET | IORESOURCE_DISABLED instead.

Signed-off-by: Yinghai Lu ying...@kernel.org
---
 drivers/pci/setup-bus.c | 52 +
 drivers/pci/setup-res.c | 11 +++
 2 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 9b27e15..e82655b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -255,7 +255,8 @@ static void pdev_check_resources(struct pci_dev *dev,
   if (r-flags  IORESOURCE_PCI_FIXED)
   continue;

-  if (!(r-flags) || r-parent)
+  if (!r-flags || r-parent ||
+  (r-flags  IORESOURCE_DISABLED))
   continue;

   r_align = __pci_resource_alignment(dev, r, realloc_head);
@@ -296,13 +297,6 @@ static void __dev_check_resources(struct pci_dev *dev,
   pdev_check_resources(dev, realloc_head, head);
 }

-static inline void reset_resource(struct resource *res)
-{
-  res-start = 0;
-  res-end = 0;
-  res-flags = 0;
-}
-
 static void __sort_resources(struct list_head *head)
 {
   struct pci_dev_resource *res1, *tmp_res, *res2;
@@ -387,7 +381,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 (res-flags  IORESOURCE_DISABLED)
   goto out;

   /* skip this resource if not found in head list */
@@ -405,7 +399,7 @@ static void reassign_resources_sorted(struct list_head 
*realloc_head,
   res-start = align;
 

[PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-06 Thread Yinghai Lu
make flags take IORESOURCE_UNSET | IORESOURCE_DISABLED instead.

Signed-off-by: Yinghai Lu 
---
 drivers/pci/setup-bus.c | 52 +
 drivers/pci/setup-res.c | 11 +++
 2 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 9b27e15..e82655b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -255,7 +255,8 @@ static void pdev_check_resources(struct pci_dev *dev,
if (r->flags & IORESOURCE_PCI_FIXED)
continue;
 
-   if (!(r->flags) || r->parent)
+   if (!r->flags || r->parent ||
+   (r->flags & IORESOURCE_DISABLED))
continue;
 
r_align = __pci_resource_alignment(dev, r, realloc_head);
@@ -296,13 +297,6 @@ static void __dev_check_resources(struct pci_dev *dev,
pdev_check_resources(dev, realloc_head, head);
 }
 
-static inline void reset_resource(struct resource *res)
-{
-   res->start = 0;
-   res->end = 0;
-   res->flags = 0;
-}
-
 static void __sort_resources(struct list_head *head)
 {
struct pci_dev_resource *res1, *tmp_res, *res2;
@@ -387,7 +381,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 (res->flags & IORESOURCE_DISABLED)
goto out;
 
/* skip this resource if not found in head list */
@@ -405,7 +399,7 @@ static void reassign_resources_sorted(struct list_head 
*realloc_head,
res->start = align;
res->end = res->start + add_size - 1;
if (pci_assign_resource(add_res->dev, idx))
-   reset_resource(res);
+   res->flags |= IORESOURCE_DISABLED;
} else {
/* could just assigned with alt, add difference ? */
if (r_size < add_res->must_size)
@@ -454,7 +448,7 @@ static void assign_requested_resources_sorted(struct 
list_head *head,
pci_assign_resource(dev_res->dev, idx)) {
if (fail_head)
add_to_list(fail_head, dev_res->dev, res);
-   reset_resource(res);
+   res->flags |= IORESOURCE_DISABLED;
}
}
 }
@@ -672,7 +666,7 @@ static void __assign_resources_alt_sorted(struct list_head 
*head,
release_resource(dev_res->res);
/* put into fail list */
add_to_list(local_fail_head, dev_res->dev, res);
-   reset_resource(res);
+   res->flags |= IORESOURCE_DISABLED;
}
 
alt_res = res_to_dev_res(realloc_head, res);
@@ -716,7 +710,7 @@ static void __assign_resources_alt_sorted(struct list_head 
*head,
res->end = res->start + dev_res->must_size - 1;
 
add_to_list(local_fail_head, fail_res->dev, res);
-   reset_resource(res);
+   res->flags |= IORESOURCE_DISABLED;
}
free_list(_alt_fail_head);
 }
@@ -872,7 +866,7 @@ static void pci_setup_bridge_io(struct pci_dev *bridge)
/* Set up the top and bottom of the PCI I/O segment for this bus. */
res = >resource[PCI_BRIDGE_RESOURCES + 0];
pcibios_resource_to_bus(bridge->bus, , res);
-   if (res->flags & IORESOURCE_IO) {
+   if ((res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_UNSET)) {
pci_read_config_word(bridge, PCI_IO_BASE, );
io_base_lo = (region.start >> 8) & io_mask;
io_limit_lo = (region.end >> 8) & io_mask;
@@ -902,7 +896,8 @@ static void pci_setup_bridge_mmio(struct pci_dev *bridge)
/* Set up the top and bottom of the PCI Memory segment for this bus. */
res = >resource[PCI_BRIDGE_RESOURCES + 1];
pcibios_resource_to_bus(bridge->bus, , res);
-   if (res->flags & IORESOURCE_MEM) {
+   if ((res->flags & IORESOURCE_MEM) &&
+   !(res->flags & IORESOURCE_UNSET)) {
l = (region.start >> 16) & 0xfff0;
l |= region.end & 0xfff0;
dev_info(>dev, "  bridge window %pR\n", res);
@@ -927,7 +922,8 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev 
*bridge)
bu = lu = 0;
res = >resource[PCI_BRIDGE_RESOURCES + 2];
pcibios_resource_to_bus(bridge->bus, , res);
-   if (res->flags & IORESOURCE_PREFETCH) {
+   if ((res->flags & IORESOURCE_PREFETCH) &&
+   !(res->flags & IORESOURCE_UNSET)) {
l = (region.start >> 16) & 0xfff0;
l |= region.end & 0xfff0;
   

[PATCH 36/36] PCI: Don't set flags to 0 when assign resource fail

2015-07-06 Thread Yinghai Lu
make flags take IORESOURCE_UNSET | IORESOURCE_DISABLED instead.

Signed-off-by: Yinghai Lu ying...@kernel.org
---
 drivers/pci/setup-bus.c | 52 +
 drivers/pci/setup-res.c | 11 +++
 2 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 9b27e15..e82655b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -255,7 +255,8 @@ static void pdev_check_resources(struct pci_dev *dev,
if (r-flags  IORESOURCE_PCI_FIXED)
continue;
 
-   if (!(r-flags) || r-parent)
+   if (!r-flags || r-parent ||
+   (r-flags  IORESOURCE_DISABLED))
continue;
 
r_align = __pci_resource_alignment(dev, r, realloc_head);
@@ -296,13 +297,6 @@ static void __dev_check_resources(struct pci_dev *dev,
pdev_check_resources(dev, realloc_head, head);
 }
 
-static inline void reset_resource(struct resource *res)
-{
-   res-start = 0;
-   res-end = 0;
-   res-flags = 0;
-}
-
 static void __sort_resources(struct list_head *head)
 {
struct pci_dev_resource *res1, *tmp_res, *res2;
@@ -387,7 +381,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 (res-flags  IORESOURCE_DISABLED)
goto out;
 
/* skip this resource if not found in head list */
@@ -405,7 +399,7 @@ static void reassign_resources_sorted(struct list_head 
*realloc_head,
res-start = align;
res-end = res-start + add_size - 1;
if (pci_assign_resource(add_res-dev, idx))
-   reset_resource(res);
+   res-flags |= IORESOURCE_DISABLED;
} else {
/* could just assigned with alt, add difference ? */
if (r_size  add_res-must_size)
@@ -454,7 +448,7 @@ static void assign_requested_resources_sorted(struct 
list_head *head,
pci_assign_resource(dev_res-dev, idx)) {
if (fail_head)
add_to_list(fail_head, dev_res-dev, res);
-   reset_resource(res);
+   res-flags |= IORESOURCE_DISABLED;
}
}
 }
@@ -672,7 +666,7 @@ static void __assign_resources_alt_sorted(struct list_head 
*head,
release_resource(dev_res-res);
/* put into fail list */
add_to_list(local_fail_head, dev_res-dev, res);
-   reset_resource(res);
+   res-flags |= IORESOURCE_DISABLED;
}
 
alt_res = res_to_dev_res(realloc_head, res);
@@ -716,7 +710,7 @@ static void __assign_resources_alt_sorted(struct list_head 
*head,
res-end = res-start + dev_res-must_size - 1;
 
add_to_list(local_fail_head, fail_res-dev, res);
-   reset_resource(res);
+   res-flags |= IORESOURCE_DISABLED;
}
free_list(local_alt_fail_head);
 }
@@ -872,7 +866,7 @@ static void pci_setup_bridge_io(struct pci_dev *bridge)
/* Set up the top and bottom of the PCI I/O segment for this bus. */
res = bridge-resource[PCI_BRIDGE_RESOURCES + 0];
pcibios_resource_to_bus(bridge-bus, region, res);
-   if (res-flags  IORESOURCE_IO) {
+   if ((res-flags  IORESOURCE_IO)  !(res-flags  IORESOURCE_UNSET)) {
pci_read_config_word(bridge, PCI_IO_BASE, l);
io_base_lo = (region.start  8)  io_mask;
io_limit_lo = (region.end  8)  io_mask;
@@ -902,7 +896,8 @@ static void pci_setup_bridge_mmio(struct pci_dev *bridge)
/* Set up the top and bottom of the PCI Memory segment for this bus. */
res = bridge-resource[PCI_BRIDGE_RESOURCES + 1];
pcibios_resource_to_bus(bridge-bus, region, res);
-   if (res-flags  IORESOURCE_MEM) {
+   if ((res-flags  IORESOURCE_MEM) 
+   !(res-flags  IORESOURCE_UNSET)) {
l = (region.start  16)  0xfff0;
l |= region.end  0xfff0;
dev_info(bridge-dev,   bridge window %pR\n, res);
@@ -927,7 +922,8 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev 
*bridge)
bu = lu = 0;
res = bridge-resource[PCI_BRIDGE_RESOURCES + 2];
pcibios_resource_to_bus(bridge-bus, region, res);
-   if (res-flags  IORESOURCE_PREFETCH) {
+   if ((res-flags  IORESOURCE_PREFETCH) 
+   !(res-flags  IORESOURCE_UNSET)) {
l = (region.start  16)  0xfff0;
l |= region.end  0xfff0;
if