linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] PCI, acpiphp: Add module parameter "complete_add" used to determine whether to hot add all devices regardless of be assigned resources fail
@ 2012-08-16 12:12 Yijing Wang
  2012-08-16 12:12 ` [PATCH 2/3] PCI, acpiphp: Use list_for_each_entry_safe instead of list_for_each_entry Yijing Wang
  2012-08-16 12:12 ` [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid Yijing Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Yijing Wang @ 2012-08-16 12:12 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci; +Cc: Hanjun Guo, Jiang Liu, Yinghai Lu, Yijing Wang

Default, when we hot add pci devices, if system allocate resources fail, this devices will be removed
again. Module parameter complete_add = 1 will forces to hot add all pci devices regardless of be assigned
resources fail.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/acpiphp.h      |    2 +-
 drivers/pci/hotplug/acpiphp_core.c |    4 +++-
 drivers/pci/hotplug/acpiphp_glue.c |    6 ++++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index a1afb5b..b228dad 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -206,5 +206,5 @@ extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
 
 /* variables */
 extern bool acpiphp_debug;
-
+extern bool acpiphp_complete_add;
 #endif /* _ACPIPHP_H */
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 96316b7..6d31608 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -48,7 +48,7 @@
 #define SLOT_NAME_SIZE  21              /* {_SUN} */
 
 bool acpiphp_debug;
-
+bool acpiphp_complete_add;
 /* local variables */
 static int num_slots;
 static struct acpiphp_attention_info *attention_info;
@@ -61,7 +61,9 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
+MODULE_PARM_DESC(complete_add, "Hot add all pci devices regardless of be assign resources fail");
 module_param_named(debug, acpiphp_debug, bool, 0644);
+module_param_named(complete_add, acpiphp_complete_add, bool, 0644);
 
 /* export the attention callback registration methods */
 EXPORT_SYMBOL_GPL(acpiphp_register_attention);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index ad6fd66..a372ade 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -827,7 +827,8 @@ static int __ref enable_device(struct acpiphp_slot *slot)
 		acpiphp_bus_add(func);
 
 	pci_bus_assign_resources(bus);
-	acpiphp_sanitize_bus(bus);
+	if (!acpiphp_complete_add)
+		acpiphp_sanitize_bus(bus);
 	acpiphp_set_hpp_values(bus);
 	acpiphp_set_acpi_region(slot);
 	pci_enable_bridges(bus);
@@ -1115,7 +1116,8 @@ static int acpiphp_configure_bridge (acpi_handle handle)
 
 	pci_bus_size_bridges(bus);
 	pci_bus_assign_resources(bus);
-	acpiphp_sanitize_bus(bus);
+	if (!acpiphp_complete_add)
+		acpiphp_sanitize_bus(bus);
 	acpiphp_set_hpp_values(bus);
 	pci_enable_bridges(bus);
 	return 0;
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] PCI, acpiphp: Use list_for_each_entry_safe instead of list_for_each_entry
  2012-08-16 12:12 [PATCH 1/3] PCI, acpiphp: Add module parameter "complete_add" used to determine whether to hot add all devices regardless of be assigned resources fail Yijing Wang
@ 2012-08-16 12:12 ` Yijing Wang
  2012-08-16 12:12 ` [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid Yijing Wang
  1 sibling, 0 replies; 6+ messages in thread
From: Yijing Wang @ 2012-08-16 12:12 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci; +Cc: Hanjun Guo, Jiang Liu, Yinghai Lu, Yijing Wang

list_for_each_entry is not safe, use list_for_each_entry_safe fix this.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index a372ade..7bbd6bf 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1082,11 +1082,11 @@ static void acpiphp_set_hpp_values(struct pci_bus *bus)
  */
 static void acpiphp_sanitize_bus(struct pci_bus *bus)
 {
-	struct pci_dev *dev;
+	struct pci_dev *dev, *tmp;
 	int i;
 	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
 
-	list_for_each_entry(dev, &bus->devices, bus_list) {
+	list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
 		for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
 			struct resource *res = &dev->resource[i];
 			if ((res->flags & type_mask) && !res->start &&
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid
  2012-08-16 12:12 [PATCH 1/3] PCI, acpiphp: Add module parameter "complete_add" used to determine whether to hot add all devices regardless of be assigned resources fail Yijing Wang
  2012-08-16 12:12 ` [PATCH 2/3] PCI, acpiphp: Use list_for_each_entry_safe instead of list_for_each_entry Yijing Wang
@ 2012-08-16 12:12 ` Yijing Wang
  2012-08-17  0:58   ` Yijing Wang
  1 sibling, 1 reply; 6+ messages in thread
From: Yijing Wang @ 2012-08-16 12:12 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci; +Cc: Hanjun Guo, Jiang Liu, Yinghai Lu, Yijing Wang

When we hot plug pci devices, system will allocate resources to these new add
devices, pci_bus_assign_resources() will be called.If the pci devices was assigned
resource fail, the resource struct will reset to zero.So I think use res->flags here
to determine whether the resource is valid is reliable.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 7bbd6bf..2161902 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1084,13 +1084,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
 {
 	struct pci_dev *dev, *tmp;
 	int i;
-	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
 
 	list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
 		for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
 			struct resource *res = &dev->resource[i];
-			if ((res->flags & type_mask) && !res->start &&
-					res->end) {
+			if (!res->flags) {
 				/* Could not assign a required resources
 				 * for this device, remove it */
 				pci_stop_and_remove_bus_device(dev);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid
  2012-08-16 12:12 ` [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid Yijing Wang
@ 2012-08-17  0:58   ` Yijing Wang
  2012-08-17  2:34     ` Bjorn Helgaas
  0 siblings, 1 reply; 6+ messages in thread
From: Yijing Wang @ 2012-08-17  0:58 UTC (permalink / raw)
  To: Yijing Wang; +Cc: Bjorn Helgaas, linux-pci, Hanjun Guo, Jiang Liu, Yinghai Lu

Hi Bjorn,
   Please ignore these three patches, I'm very sorry I still have some confusion about allocating resources
to pci devices.So this patch is not appropriate. I will provide new version patches when I find a better
solution for this problem.

> When we hot plug pci devices, system will allocate resources to these new add
> devices, pci_bus_assign_resources() will be called.If the pci devices was assigned
> resource fail, the resource struct will reset to zero.So I think use res->flags here
> to determine whether the resource is valid is reliable.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/hotplug/acpiphp_glue.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index 7bbd6bf..2161902 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -1084,13 +1084,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
>  {
>  	struct pci_dev *dev, *tmp;
>  	int i;
> -	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
>  
>  	list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
>  		for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
>  			struct resource *res = &dev->resource[i];
> -			if ((res->flags & type_mask) && !res->start &&
> -					res->end) {
> +			if (!res->flags) {
>  				/* Could not assign a required resources
>  				 * for this device, remove it */
>  				pci_stop_and_remove_bus_device(dev);
> 


-- 
Thanks!
Yijing


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid
  2012-08-17  0:58   ` Yijing Wang
@ 2012-08-17  2:34     ` Bjorn Helgaas
  2012-08-17  4:59       ` Yijing Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2012-08-17  2:34 UTC (permalink / raw)
  To: Yijing Wang; +Cc: linux-pci, Hanjun Guo, Jiang Liu, Yinghai Lu

On Thu, Aug 16, 2012 at 6:58 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> Hi Bjorn,
>    Please ignore these three patches, I'm very sorry I still have some confusion about allocating resources
> to pci devices.So this patch is not appropriate. I will provide new version patches when I find a better
> solution for this problem.

We don't have a uniform way of detecting unassigned BARs and handling
resource allocation failures yet.  When we make that all consistent, I
think it will make it more obvious how to do these patches.

I think patch 2/3 (the list_for_each_safe() one) is probably still a
good bug fix, so with your permission, I'll keep that one.

>> When we hot plug pci devices, system will allocate resources to these new add
>> devices, pci_bus_assign_resources() will be called.If the pci devices was assigned
>> resource fail, the resource struct will reset to zero.So I think use res->flags here
>> to determine whether the resource is valid is reliable.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> ---
>>  drivers/pci/hotplug/acpiphp_glue.c |    4 +---
>>  1 files changed, 1 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
>> index 7bbd6bf..2161902 100644
>> --- a/drivers/pci/hotplug/acpiphp_glue.c
>> +++ b/drivers/pci/hotplug/acpiphp_glue.c
>> @@ -1084,13 +1084,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
>>  {
>>       struct pci_dev *dev, *tmp;
>>       int i;
>> -     unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
>>
>>       list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
>>               for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
>>                       struct resource *res = &dev->resource[i];
>> -                     if ((res->flags & type_mask) && !res->start &&
>> -                                     res->end) {
>> +                     if (!res->flags) {
>>                               /* Could not assign a required resources
>>                                * for this device, remove it */
>>                               pci_stop_and_remove_bus_device(dev);
>>
>
>
> --
> Thanks!
> Yijing
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid
  2012-08-17  2:34     ` Bjorn Helgaas
@ 2012-08-17  4:59       ` Yijing Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Yijing Wang @ 2012-08-17  4:59 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Hanjun Guo, Jiang Liu, Yinghai Lu

On 2012/8/17 10:34, Bjorn Helgaas wrote:
> On Thu, Aug 16, 2012 at 6:58 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> Hi Bjorn,
>>    Please ignore these three patches, I'm very sorry I still have some confusion about allocating resources
>> to pci devices.So this patch is not appropriate. I will provide new version patches when I find a better
>> solution for this problem.
> 
> We don't have a uniform way of detecting unassigned BARs and handling
> resource allocation failures yet.  When we make that all consistent, I
> think it will make it more obvious how to do these patches.
Yes, I also think maybe we need one uniform way to detecting unassigned BARs and resources
that be assigned failure.Then if necessary, some codes which want to correct or re-assign resoruces
for pci dev could do that more clearly. I will try to analyse that, and propose some patches as soon.
Thanks!
> I think patch 2/3 (the list_for_each_safe() one) is probably still a
> good bug fix, so with your permission, I'll keep that one.
Sure,that's ok.
>>> When we hot plug pci devices, system will allocate resources to these new add
>>> devices, pci_bus_assign_resources() will be called.If the pci devices was assigned
>>> resource fail, the resource struct will reset to zero.So I think use res->flags here
>>> to determine whether the resource is valid is reliable.


-- 
Thanks!
Yijing


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-17  5:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 12:12 [PATCH 1/3] PCI, acpiphp: Add module parameter "complete_add" used to determine whether to hot add all devices regardless of be assigned resources fail Yijing Wang
2012-08-16 12:12 ` [PATCH 2/3] PCI, acpiphp: Use list_for_each_entry_safe instead of list_for_each_entry Yijing Wang
2012-08-16 12:12 ` [PATCH 3/3] PCI, acpiphp: Use res->flags to determine whether the resouce is valid Yijing Wang
2012-08-17  0:58   ` Yijing Wang
2012-08-17  2:34     ` Bjorn Helgaas
2012-08-17  4:59       ` Yijing Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).