diff mbox

[v6,21/30] PCI: Introduce pci_bus_child_max_busnr()

Message ID 1425868467-9667-22-git-send-email-wangyijing@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yijing Wang March 9, 2015, 2:34 a.m. UTC
Sometimes, we need to know the highest reserved
busnr for children bus. Because parent's
bus->busn_res could have padding in it.
This function return the max child busnr as
pci_scan_child_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |   29 +----------------------------
 drivers/pci/pci.c                  |   27 +++++++++++++++++++++++++--
 include/linux/pci.h                |    2 +-
 3 files changed, 27 insertions(+), 31 deletions(-)

Comments

Bjorn Helgaas March 12, 2015, 3:33 a.m. UTC | #1
On Mon, Mar 09, 2015 at 10:34:18AM +0800, Yijing Wang wrote:
> Sometimes, we need to know the highest reserved
> busnr for children bus. Because parent's
> bus->busn_res could have padding in it.
> This function return the max child busnr as
> pci_scan_child_bus().

I'm not convinced about this one.  The fact that it's only used by parisc
lba_pci.c and acpiphp makes me suspicious that either they're doing
something funny, or other drivers *should* be using it, too.

> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> ---
>  drivers/pci/hotplug/acpiphp_glue.c |   29 +----------------------------
>  drivers/pci/pci.c                  |   27 +++++++++++++++++++++++++--
>  include/linux/pci.h                |    2 +-
>  3 files changed, 27 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index bcb90e4..84f2584 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
>  	acpi_unlock_hp_context();
>  }
>  
> -/**
> - * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
> - * @bus: bus to start search with
> - */
> -static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
> -{
> -	struct pci_bus *tmp;
> -	unsigned char max, n;
> -
> -	/*
> -	 * pci_bus_max_busnr will return the highest
> -	 * reserved busnr for all these children.
> -	 * that is equivalent to the bus->subordinate
> -	 * value.  We don't want to use the parent's
> -	 * bus->subordinate value because it could have
> -	 * padding in it.
> -	 */
> -	max = bus->busn_res.start;
> -
> -	list_for_each_entry(tmp, &bus->children, node) {
> -		n = pci_bus_max_busnr(tmp);
> -		if (n > max)
> -			max = n;
> -	}
> -	return max;
> -}
> -
>  static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
>  {
>  	struct acpiphp_func *func;
> @@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot)
>  	LIST_HEAD(add_list);
>  
>  	acpiphp_rescan_slot(slot);
> -	max = acpiphp_max_busnr(bus);
> +	max = pci_bus_child_max_busnr(bus);
>  	for (pass = 0; pass < 2; pass++) {
>  		list_for_each_entry(dev, &bus->devices, bus_list) {
>  			if (PCI_SLOT(dev->devfn) != slot->device)
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index c49eec1..0001896 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -108,7 +108,7 @@ static bool pcie_ari_disabled;
>   * Given a PCI bus, returns the highest PCI bus number present in the set
>   * including the given PCI bus and its list of child PCI buses.
>   */
> -unsigned char pci_bus_max_busnr(struct pci_bus *bus)
> +static unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>  {
>  	struct pci_bus *tmp;
>  	unsigned char max, n;
> @@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>  	}
>  	return max;
>  }
> -EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
> +
> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus)
> +{
> +	struct pci_bus *tmp;
> +	unsigned char max, n;
> +
> +	/*
> +	 * pci_bus_max_busnr will return the highest
> +	 * reserved busnr for all these children.
> +	 * that is equivalent to the bus->subordinate
> +	 * value.  We don't want to use the parent's
> +	 * bus->subordinate value because it could have
> +	 * padding in it.
> +	 */
> +	max = bus->busn_res.start;
> +
> +	list_for_each_entry(tmp, &bus->children, node) {
> +		n = pci_bus_max_busnr(tmp);
> +		if (n > max)
> +			max = n;
> +	}
> +	return max;
> +}
> +EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr);
>  
>  #ifdef CONFIG_HAS_IOMEM
>  void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index cfaf217..261b8de 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1181,7 +1181,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
>  void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
>  		  void *userdata);
>  int pci_cfg_space_size(struct pci_dev *dev);
> -unsigned char pci_bus_max_busnr(struct pci_bus *bus);
> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus);
>  void pci_setup_bridge(struct pci_bus *bus);
>  resource_size_t pcibios_window_alignment(struct pci_bus *bus,
>  					 unsigned long type);
> -- 
> 1.7.1
>
Bjorn Helgaas March 12, 2015, 3:36 a.m. UTC | #2
On Mon, Mar 09, 2015 at 10:34:18AM +0800, Yijing Wang wrote:
> Sometimes, we need to know the highest reserved
> busnr for children bus. Because parent's
> bus->busn_res could have padding in it.
> This function return the max child busnr as
> pci_scan_child_bus().
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>

I must have screwed this up.  I don't know where the Signed-off-by from
Fengguang came from, but it shouldn't be there.  And I also screwed up by
adding my own Signed-off-by to the branch while we're still iterating on
this series.  The patches you post should not have my Signed-off-by in
them; I should add that.  But that's my fault because put them in the
branch, and I asked you to pull that branch and modify and repost it.

> ---
>  drivers/pci/hotplug/acpiphp_glue.c |   29 +----------------------------
>  drivers/pci/pci.c                  |   27 +++++++++++++++++++++++++--
>  include/linux/pci.h                |    2 +-
>  3 files changed, 27 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index bcb90e4..84f2584 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
>  	acpi_unlock_hp_context();
>  }
>  
> -/**
> - * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
> - * @bus: bus to start search with
> - */
> -static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
> -{
> -	struct pci_bus *tmp;
> -	unsigned char max, n;
> -
> -	/*
> -	 * pci_bus_max_busnr will return the highest
> -	 * reserved busnr for all these children.
> -	 * that is equivalent to the bus->subordinate
> -	 * value.  We don't want to use the parent's
> -	 * bus->subordinate value because it could have
> -	 * padding in it.
> -	 */
> -	max = bus->busn_res.start;
> -
> -	list_for_each_entry(tmp, &bus->children, node) {
> -		n = pci_bus_max_busnr(tmp);
> -		if (n > max)
> -			max = n;
> -	}
> -	return max;
> -}
> -
>  static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
>  {
>  	struct acpiphp_func *func;
> @@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot)
>  	LIST_HEAD(add_list);
>  
>  	acpiphp_rescan_slot(slot);
> -	max = acpiphp_max_busnr(bus);
> +	max = pci_bus_child_max_busnr(bus);
>  	for (pass = 0; pass < 2; pass++) {
>  		list_for_each_entry(dev, &bus->devices, bus_list) {
>  			if (PCI_SLOT(dev->devfn) != slot->device)
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index c49eec1..0001896 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -108,7 +108,7 @@ static bool pcie_ari_disabled;
>   * Given a PCI bus, returns the highest PCI bus number present in the set
>   * including the given PCI bus and its list of child PCI buses.
>   */
> -unsigned char pci_bus_max_busnr(struct pci_bus *bus)
> +static unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>  {
>  	struct pci_bus *tmp;
>  	unsigned char max, n;
> @@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>  	}
>  	return max;
>  }
> -EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
> +
> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus)
> +{
> +	struct pci_bus *tmp;
> +	unsigned char max, n;
> +
> +	/*
> +	 * pci_bus_max_busnr will return the highest
> +	 * reserved busnr for all these children.
> +	 * that is equivalent to the bus->subordinate
> +	 * value.  We don't want to use the parent's
> +	 * bus->subordinate value because it could have
> +	 * padding in it.
> +	 */
> +	max = bus->busn_res.start;
> +
> +	list_for_each_entry(tmp, &bus->children, node) {
> +		n = pci_bus_max_busnr(tmp);
> +		if (n > max)
> +			max = n;
> +	}
> +	return max;
> +}
> +EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr);
>  
>  #ifdef CONFIG_HAS_IOMEM
>  void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index cfaf217..261b8de 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1181,7 +1181,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
>  void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
>  		  void *userdata);
>  int pci_cfg_space_size(struct pci_dev *dev);
> -unsigned char pci_bus_max_busnr(struct pci_bus *bus);
> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus);
>  void pci_setup_bridge(struct pci_bus *bus);
>  resource_size_t pcibios_window_alignment(struct pci_bus *bus,
>  					 unsigned long type);
> -- 
> 1.7.1
>
Yijing Wang March 12, 2015, 1:24 p.m. UTC | #3
On 2015/3/12 11:33, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:18AM +0800, Yijing Wang wrote:
>> Sometimes, we need to know the highest reserved
>> busnr for children bus. Because parent's
>> bus->busn_res could have padding in it.
>> This function return the max child busnr as
>> pci_scan_child_bus().
> 
> I'm not convinced about this one.  The fact that it's only used by parisc
> lba_pci.c and acpiphp makes me suspicious that either they're doing
> something funny, or other drivers *should* be using it, too.

Yes, what lba_pci.c do looks some strange, I did this patch just try to
keep the original logic, but it seems to make code more complex, I would
consider this again and try to find a better solution, thanks.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
>> ---
>>  drivers/pci/hotplug/acpiphp_glue.c |   29 +----------------------------
>>  drivers/pci/pci.c                  |   27 +++++++++++++++++++++++++--
>>  include/linux/pci.h                |    2 +-
>>  3 files changed, 27 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
>> index bcb90e4..84f2584 100644
>> --- a/drivers/pci/hotplug/acpiphp_glue.c
>> +++ b/drivers/pci/hotplug/acpiphp_glue.c
>> @@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
>>  	acpi_unlock_hp_context();
>>  }
>>  
>> -/**
>> - * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
>> - * @bus: bus to start search with
>> - */
>> -static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
>> -{
>> -	struct pci_bus *tmp;
>> -	unsigned char max, n;
>> -
>> -	/*
>> -	 * pci_bus_max_busnr will return the highest
>> -	 * reserved busnr for all these children.
>> -	 * that is equivalent to the bus->subordinate
>> -	 * value.  We don't want to use the parent's
>> -	 * bus->subordinate value because it could have
>> -	 * padding in it.
>> -	 */
>> -	max = bus->busn_res.start;
>> -
>> -	list_for_each_entry(tmp, &bus->children, node) {
>> -		n = pci_bus_max_busnr(tmp);
>> -		if (n > max)
>> -			max = n;
>> -	}
>> -	return max;
>> -}
>> -
>>  static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
>>  {
>>  	struct acpiphp_func *func;
>> @@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot)
>>  	LIST_HEAD(add_list);
>>  
>>  	acpiphp_rescan_slot(slot);
>> -	max = acpiphp_max_busnr(bus);
>> +	max = pci_bus_child_max_busnr(bus);
>>  	for (pass = 0; pass < 2; pass++) {
>>  		list_for_each_entry(dev, &bus->devices, bus_list) {
>>  			if (PCI_SLOT(dev->devfn) != slot->device)
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index c49eec1..0001896 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -108,7 +108,7 @@ static bool pcie_ari_disabled;
>>   * Given a PCI bus, returns the highest PCI bus number present in the set
>>   * including the given PCI bus and its list of child PCI buses.
>>   */
>> -unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>> +static unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>>  {
>>  	struct pci_bus *tmp;
>>  	unsigned char max, n;
>> @@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>>  	}
>>  	return max;
>>  }
>> -EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
>> +
>> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus)
>> +{
>> +	struct pci_bus *tmp;
>> +	unsigned char max, n;
>> +
>> +	/*
>> +	 * pci_bus_max_busnr will return the highest
>> +	 * reserved busnr for all these children.
>> +	 * that is equivalent to the bus->subordinate
>> +	 * value.  We don't want to use the parent's
>> +	 * bus->subordinate value because it could have
>> +	 * padding in it.
>> +	 */
>> +	max = bus->busn_res.start;
>> +
>> +	list_for_each_entry(tmp, &bus->children, node) {
>> +		n = pci_bus_max_busnr(tmp);
>> +		if (n > max)
>> +			max = n;
>> +	}
>> +	return max;
>> +}
>> +EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr);
>>  
>>  #ifdef CONFIG_HAS_IOMEM
>>  void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index cfaf217..261b8de 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1181,7 +1181,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
>>  void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
>>  		  void *userdata);
>>  int pci_cfg_space_size(struct pci_dev *dev);
>> -unsigned char pci_bus_max_busnr(struct pci_bus *bus);
>> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus);
>>  void pci_setup_bridge(struct pci_bus *bus);
>>  resource_size_t pcibios_window_alignment(struct pci_bus *bus,
>>  					 unsigned long type);
>> -- 
>> 1.7.1
>>
> 
> .
>
Yijing Wang March 12, 2015, 1:28 p.m. UTC | #4
On 2015/3/12 11:36, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:18AM +0800, Yijing Wang wrote:
>> Sometimes, we need to know the highest reserved
>> busnr for children bus. Because parent's
>> bus->busn_res could have padding in it.
>> This function return the max child busnr as
>> pci_scan_child_bus().
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> 
> I must have screwed this up.  I don't know where the Signed-off-by from
> Fengguang came from, but it shouldn't be there.  And I also screwed up by
> adding my own Signed-off-by to the branch while we're still iterating on
> this series.  The patches you post should not have my Signed-off-by in
> them; I should add that.  But that's my fault because put them in the
> branch, and I asked you to pull that branch and modify and repost it.
> 

-.-! I added the Fengguang Signed-off-by, because his kbuild test robot sent a patch to me to fix a building error.

Sorry, will remove Fengguang and your Signed-off-by.

>> ---
>>  drivers/pci/hotplug/acpiphp_glue.c |   29 +----------------------------
>>  drivers/pci/pci.c                  |   27 +++++++++++++++++++++++++--
>>  include/linux/pci.h                |    2 +-
>>  3 files changed, 27 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
>> index bcb90e4..84f2584 100644
>> --- a/drivers/pci/hotplug/acpiphp_glue.c
>> +++ b/drivers/pci/hotplug/acpiphp_glue.c
>> @@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
>>  	acpi_unlock_hp_context();
>>  }
>>  
>> -/**
>> - * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
>> - * @bus: bus to start search with
>> - */
>> -static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
>> -{
>> -	struct pci_bus *tmp;
>> -	unsigned char max, n;
>> -
>> -	/*
>> -	 * pci_bus_max_busnr will return the highest
>> -	 * reserved busnr for all these children.
>> -	 * that is equivalent to the bus->subordinate
>> -	 * value.  We don't want to use the parent's
>> -	 * bus->subordinate value because it could have
>> -	 * padding in it.
>> -	 */
>> -	max = bus->busn_res.start;
>> -
>> -	list_for_each_entry(tmp, &bus->children, node) {
>> -		n = pci_bus_max_busnr(tmp);
>> -		if (n > max)
>> -			max = n;
>> -	}
>> -	return max;
>> -}
>> -
>>  static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
>>  {
>>  	struct acpiphp_func *func;
>> @@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot)
>>  	LIST_HEAD(add_list);
>>  
>>  	acpiphp_rescan_slot(slot);
>> -	max = acpiphp_max_busnr(bus);
>> +	max = pci_bus_child_max_busnr(bus);
>>  	for (pass = 0; pass < 2; pass++) {
>>  		list_for_each_entry(dev, &bus->devices, bus_list) {
>>  			if (PCI_SLOT(dev->devfn) != slot->device)
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index c49eec1..0001896 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -108,7 +108,7 @@ static bool pcie_ari_disabled;
>>   * Given a PCI bus, returns the highest PCI bus number present in the set
>>   * including the given PCI bus and its list of child PCI buses.
>>   */
>> -unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>> +static unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>>  {
>>  	struct pci_bus *tmp;
>>  	unsigned char max, n;
>> @@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus)
>>  	}
>>  	return max;
>>  }
>> -EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
>> +
>> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus)
>> +{
>> +	struct pci_bus *tmp;
>> +	unsigned char max, n;
>> +
>> +	/*
>> +	 * pci_bus_max_busnr will return the highest
>> +	 * reserved busnr for all these children.
>> +	 * that is equivalent to the bus->subordinate
>> +	 * value.  We don't want to use the parent's
>> +	 * bus->subordinate value because it could have
>> +	 * padding in it.
>> +	 */
>> +	max = bus->busn_res.start;
>> +
>> +	list_for_each_entry(tmp, &bus->children, node) {
>> +		n = pci_bus_max_busnr(tmp);
>> +		if (n > max)
>> +			max = n;
>> +	}
>> +	return max;
>> +}
>> +EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr);
>>  
>>  #ifdef CONFIG_HAS_IOMEM
>>  void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index cfaf217..261b8de 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1181,7 +1181,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
>>  void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
>>  		  void *userdata);
>>  int pci_cfg_space_size(struct pci_dev *dev);
>> -unsigned char pci_bus_max_busnr(struct pci_bus *bus);
>> +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus);
>>  void pci_setup_bridge(struct pci_bus *bus);
>>  resource_size_t pcibios_window_alignment(struct pci_bus *bus,
>>  					 unsigned long type);
>> -- 
>> 1.7.1
>>
> 
> .
>
Bjorn Helgaas March 12, 2015, 8 p.m. UTC | #5
On Thu, Mar 12, 2015 at 09:28:30PM +0800, Yijing Wang wrote:
> On 2015/3/12 11:36, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:18AM +0800, Yijing Wang wrote:
> >> Sometimes, we need to know the highest reserved
> >> busnr for children bus. Because parent's
> >> bus->busn_res could have padding in it.
> >> This function return the max child busnr as
> >> pci_scan_child_bus().
> >>
> >> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> >> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> >> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> > 
> > I must have screwed this up.  I don't know where the Signed-off-by from
> > Fengguang came from, but it shouldn't be there.  And I also screwed up by
> > adding my own Signed-off-by to the branch while we're still iterating on
> > this series.  The patches you post should not have my Signed-off-by in
> > them; I should add that.  But that's my fault because put them in the
> > branch, and I asked you to pull that branch and modify and repost it.
> > 
> 
> -.-! I added the Fengguang Signed-off-by, because his kbuild test robot sent a patch to me to fix a building error.

Oh, OK.  I forgot about that.  I think it's OK to include Fengguang's
Signed-off-by for that, but it should come before yours.  Since you're the
one sending the patch, your Signed-off-by should be last in the list.
diff mbox

Patch

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index bcb90e4..84f2584 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -397,33 +397,6 @@  static void cleanup_bridge(struct acpiphp_bridge *bridge)
 	acpi_unlock_hp_context();
 }
 
-/**
- * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
- * @bus: bus to start search with
- */
-static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
-{
-	struct pci_bus *tmp;
-	unsigned char max, n;
-
-	/*
-	 * pci_bus_max_busnr will return the highest
-	 * reserved busnr for all these children.
-	 * that is equivalent to the bus->subordinate
-	 * value.  We don't want to use the parent's
-	 * bus->subordinate value because it could have
-	 * padding in it.
-	 */
-	max = bus->busn_res.start;
-
-	list_for_each_entry(tmp, &bus->children, node) {
-		n = pci_bus_max_busnr(tmp);
-		if (n > max)
-			max = n;
-	}
-	return max;
-}
-
 static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
 {
 	struct acpiphp_func *func;
@@ -489,7 +462,7 @@  static void enable_slot(struct acpiphp_slot *slot)
 	LIST_HEAD(add_list);
 
 	acpiphp_rescan_slot(slot);
-	max = acpiphp_max_busnr(bus);
+	max = pci_bus_child_max_busnr(bus);
 	for (pass = 0; pass < 2; pass++) {
 		list_for_each_entry(dev, &bus->devices, bus_list) {
 			if (PCI_SLOT(dev->devfn) != slot->device)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c49eec1..0001896 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -108,7 +108,7 @@  static bool pcie_ari_disabled;
  * Given a PCI bus, returns the highest PCI bus number present in the set
  * including the given PCI bus and its list of child PCI buses.
  */
-unsigned char pci_bus_max_busnr(struct pci_bus *bus)
+static unsigned char pci_bus_max_busnr(struct pci_bus *bus)
 {
 	struct pci_bus *tmp;
 	unsigned char max, n;
@@ -121,7 +121,30 @@  unsigned char pci_bus_max_busnr(struct pci_bus *bus)
 	}
 	return max;
 }
-EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
+
+unsigned char pci_bus_child_max_busnr(struct pci_bus *bus)
+{
+	struct pci_bus *tmp;
+	unsigned char max, n;
+
+	/*
+	 * pci_bus_max_busnr will return the highest
+	 * reserved busnr for all these children.
+	 * that is equivalent to the bus->subordinate
+	 * value.  We don't want to use the parent's
+	 * bus->subordinate value because it could have
+	 * padding in it.
+	 */
+	max = bus->busn_res.start;
+
+	list_for_each_entry(tmp, &bus->children, node) {
+		n = pci_bus_max_busnr(tmp);
+		if (n > max)
+			max = n;
+	}
+	return max;
+}
+EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr);
 
 #ifdef CONFIG_HAS_IOMEM
 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cfaf217..261b8de 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1181,7 +1181,7 @@  int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
 void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
 		  void *userdata);
 int pci_cfg_space_size(struct pci_dev *dev);
-unsigned char pci_bus_max_busnr(struct pci_bus *bus);
+unsigned char pci_bus_child_max_busnr(struct pci_bus *bus);
 void pci_setup_bridge(struct pci_bus *bus);
 resource_size_t pcibios_window_alignment(struct pci_bus *bus,
 					 unsigned long type);