diff mbox

[RFC,v1,19/22] PCI/x86: enable PCI bus lock mechanism for x86 platforms

Message ID 1344355862-2726-20-git-send-email-jiang.liu@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Jiang Liu Aug. 7, 2012, 4:10 p.m. UTC
This patch turns on PCI bus lock mechanism for x86 platforms. It also
enhances x86 specific PCI implementation to support PCI bus lock.

Signed-off-by: Jiang Liu <liuj97@gmail.com>
---
 arch/x86/pci/acpi.c   |    6 +++++-
 arch/x86/pci/common.c |   12 ++++++++++++
 drivers/pci/Kconfig   |    3 +--
 3 files changed, 18 insertions(+), 3 deletions(-)

Comments

Bjorn Helgaas Sept. 11, 2012, 11:22 p.m. UTC | #1
On Tue, Aug 7, 2012 at 10:10 AM, Jiang Liu <liuj97@gmail.com> wrote:
> This patch turns on PCI bus lock mechanism for x86 platforms. It also
> enhances x86 specific PCI implementation to support PCI bus lock.
>
> Signed-off-by: Jiang Liu <liuj97@gmail.com>
> ---
>  arch/x86/pci/acpi.c   |    6 +++++-
>  arch/x86/pci/common.c |   12 ++++++++++++
>  drivers/pci/Kconfig   |    3 +--
>  3 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 2bb885a..c68dbdf 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -414,7 +414,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>          * Maybe the desired pci bus has been already scanned. In such case
>          * it is unnecessary to scan the pci bus with the given domain,busnum.
>          */
> -       bus = pci_find_bus(domain, busnum);
> +       bus = __pci_get_and_lock_bus(domain, busnum,
> +                                    PCI_BUS_STATE_STOPPING - 1);
>         if (bus) {
>                 /*
>                  * If the desired bus exits, the content of bus->sysdata will
> @@ -449,6 +450,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>                         pci_free_resource_list(&resources);
>                         __release_pci_root_info(info);
>                 }
> +               pci_bus_get(bus);
>         }
>
>         /* After the PCI-E bus has been walked and all devices discovered,
> @@ -475,6 +477,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>  #endif
>         }
>
> +       pci_unlock_and_put_bus(bus);
> +
>         return bus;
>  }
>
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0ad990a..8b7ae63 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -667,6 +667,18 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
>         return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
>  }
>
> +static DEFINE_MUTEX(pci_root_bus_mutex);
> +
> +void arch_pci_lock_host_bridge_hotplug(void)
> +{
> +       mutex_lock(&pci_root_bus_mutex);
> +}
> +
> +void arch_pci_unlock_host_bridge_hotplug(void)
> +{
> +       mutex_unlock(&pci_root_bus_mutex);
> +}

Are these left over from previous work?  I don't see any reference to
them elsewhere in your patch series.

>  /*
>   * NUMA info for PCI busses
>   *
> diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
> index a6df8b1..1bbe924 100644
> --- a/drivers/pci/Kconfig
> +++ b/drivers/pci/Kconfig
> @@ -122,5 +122,4 @@ config PCI_LABEL
>         select NLS
>
>  config PCI_BUS_LOCK
> -       bool
> -       default n
> +       def_bool y if X86
> --
> 1.7.9.5
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiang Liu Sept. 12, 2012, 9:56 a.m. UTC | #2
On 2012-9-12 7:22, Bjorn Helgaas wrote:
> On Tue, Aug 7, 2012 at 10:10 AM, Jiang Liu <liuj97@gmail.com> wrote:
>> This patch turns on PCI bus lock mechanism for x86 platforms. It also
>> enhances x86 specific PCI implementation to support PCI bus lock.
>>
>> Signed-off-by: Jiang Liu <liuj97@gmail.com>
>> ---
>>  arch/x86/pci/acpi.c   |    6 +++++-
>>  arch/x86/pci/common.c |   12 ++++++++++++
>>  drivers/pci/Kconfig   |    3 +--
>>  3 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 2bb885a..c68dbdf 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -414,7 +414,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>          * Maybe the desired pci bus has been already scanned. In such case
>>          * it is unnecessary to scan the pci bus with the given domain,busnum.
>>          */
>> -       bus = pci_find_bus(domain, busnum);
>> +       bus = __pci_get_and_lock_bus(domain, busnum,
>> +                                    PCI_BUS_STATE_STOPPING - 1);
>>         if (bus) {
>>                 /*
>>                  * If the desired bus exits, the content of bus->sysdata will
>> @@ -449,6 +450,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>                         pci_free_resource_list(&resources);
>>                         __release_pci_root_info(info);
>>                 }
>> +               pci_bus_get(bus);
>>         }
>>
>>         /* After the PCI-E bus has been walked and all devices discovered,
>> @@ -475,6 +477,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>  #endif
>>         }
>>
>> +       pci_unlock_and_put_bus(bus);
>> +
>>         return bus;
>>  }
>>
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0ad990a..8b7ae63 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -667,6 +667,18 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
>>         return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
>>  }
>>
>> +static DEFINE_MUTEX(pci_root_bus_mutex);
>> +
>> +void arch_pci_lock_host_bridge_hotplug(void)
>> +{
>> +       mutex_lock(&pci_root_bus_mutex);
>> +}
>> +
>> +void arch_pci_unlock_host_bridge_hotplug(void)
>> +{
>> +       mutex_unlock(&pci_root_bus_mutex);
>> +}
> 
> Are these left over from previous work?  I don't see any reference to
> them elsewhere in your patch series.
Hi Bjorn
	Eagle eyes! Yes, it's left from previous work and I have changed to
other mechanism for root bus locks.
	--Gerry

> 
>>  /*
>>   * NUMA info for PCI busses
>>   *
>> diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
>> index a6df8b1..1bbe924 100644
>> --- a/drivers/pci/Kconfig
>> +++ b/drivers/pci/Kconfig
>> @@ -122,5 +122,4 @@ config PCI_LABEL
>>         select NLS
>>
>>  config PCI_BUS_LOCK
>> -       bool
>> -       default n
>> +       def_bool y if X86
>> --
>> 1.7.9.5
>>
> 
> .
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 2bb885a..c68dbdf 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -414,7 +414,8 @@  struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * Maybe the desired pci bus has been already scanned. In such case
 	 * it is unnecessary to scan the pci bus with the given domain,busnum.
 	 */
-	bus = pci_find_bus(domain, busnum);
+	bus = __pci_get_and_lock_bus(domain, busnum,
+				     PCI_BUS_STATE_STOPPING - 1);
 	if (bus) {
 		/*
 		 * If the desired bus exits, the content of bus->sysdata will
@@ -449,6 +450,7 @@  struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 			pci_free_resource_list(&resources);
 			__release_pci_root_info(info);
 		}
+		pci_bus_get(bus);
 	}
 
 	/* After the PCI-E bus has been walked and all devices discovered,
@@ -475,6 +477,8 @@  struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 #endif
 	}
 
+	pci_unlock_and_put_bus(bus);
+
 	return bus;
 }
 
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0ad990a..8b7ae63 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -667,6 +667,18 @@  struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
 	return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
 }
 
+static DEFINE_MUTEX(pci_root_bus_mutex);
+
+void arch_pci_lock_host_bridge_hotplug(void)
+{
+	mutex_lock(&pci_root_bus_mutex);
+}
+
+void arch_pci_unlock_host_bridge_hotplug(void)
+{
+	mutex_unlock(&pci_root_bus_mutex);
+}
+
 /*
  * NUMA info for PCI busses
  *
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index a6df8b1..1bbe924 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -122,5 +122,4 @@  config PCI_LABEL
 	select NLS
 
 config PCI_BUS_LOCK
-	bool
-	default n
+	def_bool y if X86