All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-09  2:33 ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

v5->v6:
	Fix cross building errors found by kbuild test.
	Export busn_resource to Xen pcifront driver.
v4->v5:
	Fix some code style issues and rename some functions suggested by Bjorn.
	Fix some code flaw(Eg. call pci_bus_add_devices() before resources claim
	or lack the return checking).
v3->v4:
	Fix the rebase issue.
v2->v3:
	Rebase this series on v4.0-rc1.
v1->v2:
	Split pci_host_bridge_list into a new patch, remove .phb_probe_mode
	and rework powerpc .phb_of_scan_bus() for simpilicty suggested by
	Arnd. Refresh some patch description log, and add a new patch to fix
	build warning in ia64.

This series is based on Bjorn's pci-next branch.

Patch 1-4 ripped out pci_bus_add_devices() from pci scan interfaces
for better pci scan flow.

Patch 5-11 make a generic pci_host_bridge to hold pci_host_bridge
related informations, and introduce a pci_host_bridge_ops to 
support platform host drivers provide its own pci_host_bridge 
related operations to setup pci_host_bridge during pci enumeration.

Patch 12-28 apply the new pci scan interfaces to platform pci host
bridge drivers.

Now in kernel, we scan pci bus use the following ways:
1. pci_scan_bus. 
	parent = NULL, default io/mem/bus resources
	call pci_bus_add_devices()

2. pci_scan_bus_parented() + pci_bus_add_devices()
	default io/mem/bus resources, only used by xen

3. pci_scan_root_bus() + pci_bus_add_devices()

4. pci_create_root_bus() + pci_scan_child_bus() + pci_bus_add_devices()

5. pci_create_root_bus() + xx_of_scan_bus()  +  pci_bus_add_devices()

And we have a lot of arch specific pci_domain_nr() and other platform
specific weak function like pcibios_root_bridge_prepare().

After applied this series, we have following scan interfaces:

1. pci_scan_bus() 
	parent = NULL, default io/mem/bus resources.
	for legacy pci scan

2. pci_scan_root_bus()
	for callers provide its own parent and io/mem/bus resources
	but no platform specific pci_host_bridge operations

3. pci_scan_root_bridge()
	for callers provide its own parent and io/mem/bus resources


Arnd Bergmann (1):
  xen/PCI: Don't use deprecated function pci_scan_bus_parented()

Yijing Wang (29):
  PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  PCI: Export busn_resource to drivers/pci
  PCI: Remove deprecated pci_scan_bus_parented()
  PCI: Combine PCI domain and bus number in u32 arg
  PCI: Pass PCI domain number combined with root bus number
  PCI: Introduce pci_host_assign_domain_nr() to assign domain
  PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  PCI: Introduce pci_host_bridge_list to manage host bridges
  PCI: Save sysdata in pci_host_bridge drvdata
  PCI: Introduce pci_host_bridge_ops to support host specific
    operations
  PCI: Introduce new scan function pci_scan_host_bridge()
  x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  powerpc/pci: Rename pcibios_root_bridge_prepare()
  powerpc/pci: Use pci_scan_host_bridge() for simplicity
  PCI: Remove weak pcibios_root_bridge_prepare()
  sparc/PCI: Claim bus resources before pci_bus_add_devices()
  sparc/PCI: Use pci_scan_host_bridge() for simplicity
  PCI: Introduce pci_bus_child_max_busnr()
  parisc/PCI: Use pci_scan_root_bus() for simplicity
  PCI/mvebu: Use pci_common_init_dev() to simplify code
  PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  PCI/designware: Use pci_scan_root_bus() for simplicity
  PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  PCI: Export find_pci_host_bridge() and rename to
    pci_find_host_bridge()
  PCI: Remove platform specific pci_domain_nr()
  PCI: Remove pci_bus_assign_domain_nr()

 arch/alpha/include/asm/pci.h             |    2 -
 arch/alpha/kernel/pci.c                  |   14 ++-
 arch/alpha/kernel/sys_nautilus.c         |    6 +-
 arch/frv/mb93090-mb00/pci-vdk.c          |    6 +-
 arch/ia64/include/asm/pci.h              |    1 -
 arch/ia64/pci/pci.c                      |   34 +++---
 arch/ia64/sn/kernel/io_init.c            |    7 +-
 arch/m68k/coldfire/pci.c                 |    1 +
 arch/microblaze/pci/pci-common.c         |   19 +--
 arch/mips/include/asm/pci.h              |    2 -
 arch/mips/pci/pci.c                      |    5 +-
 arch/mn10300/unit-asb2305/pci.c          |    7 +-
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   77 ++++++------
 arch/powerpc/platforms/pseries/pci.c     |    8 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 arch/s390/pci/pci.c                      |   13 +--
 arch/sh/drivers/pci/pci.c                |    6 +-
 arch/sh/include/asm/pci.h                |    2 -
 arch/sparc/kernel/leon_pci.c             |    1 +
 arch/sparc/kernel/pci.c                  |   51 ++++-----
 arch/sparc/kernel/pcic.c                 |    3 +
 arch/tile/include/asm/pci.h              |    2 -
 arch/tile/kernel/pci.c                   |    7 +-
 arch/tile/kernel/pci_gx.c                |    7 +-
 arch/unicore32/kernel/pci.c              |   11 +--
 arch/x86/include/asm/pci.h               |    6 -
 arch/x86/pci/acpi.c                      |   37 +++---
 arch/x86/pci/common.c                    |    4 +-
 arch/xtensa/kernel/pci.c                 |   11 ++-
 drivers/parisc/dino.c                    |    8 +-
 drivers/parisc/lba_pci.c                 |    7 +-
 drivers/pci/host-bridge.c                |   93 ++++++++++++++-
 drivers/pci/host/pci-mvebu.c             |   18 +---
 drivers/pci/host/pci-tegra.c             |   16 ---
 drivers/pci/host/pci-xgene.c             |    3 +-
 drivers/pci/host/pcie-designware.c       |    4 +-
 drivers/pci/hotplug/acpiphp_glue.c       |   29 +-----
 drivers/pci/hotplug/ibmphp_core.c        |    8 +-
 drivers/pci/pci.c                        |   50 +++++++-
 drivers/pci/pci.h                        |    9 ++
 drivers/pci/probe.c                      |  196 ++++++++++++------------------
 drivers/pci/xen-pcifront.c               |   13 ++-
 include/linux/pci.h                      |   42 ++++---
 include/uapi/linux/pci.h                 |    3 +
 46 files changed, 458 insertions(+), 397 deletions(-)


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-09  2:33 ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

v5->v6:
	Fix cross building errors found by kbuild test.
	Export busn_resource to Xen pcifront driver.
v4->v5:
	Fix some code style issues and rename some functions suggested by Bjorn.
	Fix some code flaw(Eg. call pci_bus_add_devices() before resources claim
	or lack the return checking).
v3->v4:
	Fix the rebase issue.
v2->v3:
	Rebase this series on v4.0-rc1.
v1->v2:
	Split pci_host_bridge_list into a new patch, remove .phb_probe_mode
	and rework powerpc .phb_of_scan_bus() for simpilicty suggested by
	Arnd. Refresh some patch description log, and add a new patch to fix
	build warning in ia64.

This series is based on Bjorn's pci-next branch.

Patch 1-4 ripped out pci_bus_add_devices() from pci scan interfaces
for better pci scan flow.

Patch 5-11 make a generic pci_host_bridge to hold pci_host_bridge
related informations, and introduce a pci_host_bridge_ops to 
support platform host drivers provide its own pci_host_bridge 
related operations to setup pci_host_bridge during pci enumeration.

Patch 12-28 apply the new pci scan interfaces to platform pci host
bridge drivers.

Now in kernel, we scan pci bus use the following ways:
1. pci_scan_bus. 
	parent = NULL, default io/mem/bus resources
	call pci_bus_add_devices()

2. pci_scan_bus_parented() + pci_bus_add_devices()
	default io/mem/bus resources, only used by xen

3. pci_scan_root_bus() + pci_bus_add_devices()

4. pci_create_root_bus() + pci_scan_child_bus() + pci_bus_add_devices()

5. pci_create_root_bus() + xx_of_scan_bus()  +  pci_bus_add_devices()

And we have a lot of arch specific pci_domain_nr() and other platform
specific weak function like pcibios_root_bridge_prepare().

After applied this series, we have following scan interfaces:

1. pci_scan_bus() 
	parent = NULL, default io/mem/bus resources.
	for legacy pci scan

2. pci_scan_root_bus()
	for callers provide its own parent and io/mem/bus resources
	but no platform specific pci_host_bridge operations

3. pci_scan_root_bridge()
	for callers provide its own parent and io/mem/bus resources


Arnd Bergmann (1):
  xen/PCI: Don't use deprecated function pci_scan_bus_parented()

Yijing Wang (29):
  PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  PCI: Export busn_resource to drivers/pci
  PCI: Remove deprecated pci_scan_bus_parented()
  PCI: Combine PCI domain and bus number in u32 arg
  PCI: Pass PCI domain number combined with root bus number
  PCI: Introduce pci_host_assign_domain_nr() to assign domain
  PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  PCI: Introduce pci_host_bridge_list to manage host bridges
  PCI: Save sysdata in pci_host_bridge drvdata
  PCI: Introduce pci_host_bridge_ops to support host specific
    operations
  PCI: Introduce new scan function pci_scan_host_bridge()
  x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  powerpc/pci: Rename pcibios_root_bridge_prepare()
  powerpc/pci: Use pci_scan_host_bridge() for simplicity
  PCI: Remove weak pcibios_root_bridge_prepare()
  sparc/PCI: Claim bus resources before pci_bus_add_devices()
  sparc/PCI: Use pci_scan_host_bridge() for simplicity
  PCI: Introduce pci_bus_child_max_busnr()
  parisc/PCI: Use pci_scan_root_bus() for simplicity
  PCI/mvebu: Use pci_common_init_dev() to simplify code
  PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  PCI/designware: Use pci_scan_root_bus() for simplicity
  PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  PCI: Export find_pci_host_bridge() and rename to
    pci_find_host_bridge()
  PCI: Remove platform specific pci_domain_nr()
  PCI: Remove pci_bus_assign_domain_nr()

 arch/alpha/include/asm/pci.h             |    2 -
 arch/alpha/kernel/pci.c                  |   14 ++-
 arch/alpha/kernel/sys_nautilus.c         |    6 +-
 arch/frv/mb93090-mb00/pci-vdk.c          |    6 +-
 arch/ia64/include/asm/pci.h              |    1 -
 arch/ia64/pci/pci.c                      |   34 +++---
 arch/ia64/sn/kernel/io_init.c            |    7 +-
 arch/m68k/coldfire/pci.c                 |    1 +
 arch/microblaze/pci/pci-common.c         |   19 +--
 arch/mips/include/asm/pci.h              |    2 -
 arch/mips/pci/pci.c                      |    5 +-
 arch/mn10300/unit-asb2305/pci.c          |    7 +-
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   77 ++++++------
 arch/powerpc/platforms/pseries/pci.c     |    8 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 arch/s390/pci/pci.c                      |   13 +--
 arch/sh/drivers/pci/pci.c                |    6 +-
 arch/sh/include/asm/pci.h                |    2 -
 arch/sparc/kernel/leon_pci.c             |    1 +
 arch/sparc/kernel/pci.c                  |   51 ++++-----
 arch/sparc/kernel/pcic.c                 |    3 +
 arch/tile/include/asm/pci.h              |    2 -
 arch/tile/kernel/pci.c                   |    7 +-
 arch/tile/kernel/pci_gx.c                |    7 +-
 arch/unicore32/kernel/pci.c              |   11 +--
 arch/x86/include/asm/pci.h               |    6 -
 arch/x86/pci/acpi.c                      |   37 +++---
 arch/x86/pci/common.c                    |    4 +-
 arch/xtensa/kernel/pci.c                 |   11 ++-
 drivers/parisc/dino.c                    |    8 +-
 drivers/parisc/lba_pci.c                 |    7 +-
 drivers/pci/host-bridge.c                |   93 ++++++++++++++-
 drivers/pci/host/pci-mvebu.c             |   18 +---
 drivers/pci/host/pci-tegra.c             |   16 ---
 drivers/pci/host/pci-xgene.c             |    3 +-
 drivers/pci/host/pcie-designware.c       |    4 +-
 drivers/pci/hotplug/acpiphp_glue.c       |   29 +-----
 drivers/pci/hotplug/ibmphp_core.c        |    8 +-
 drivers/pci/pci.c                        |   50 +++++++-
 drivers/pci/pci.h                        |    9 ++
 drivers/pci/probe.c                      |  196 ++++++++++++------------------
 drivers/pci/xen-pcifront.c               |   13 ++-
 include/linux/pci.h                      |   42 ++++---
 include/uapi/linux/pci.h                 |    3 +
 46 files changed, 458 insertions(+), 397 deletions(-)


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-09  2:33 ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: linux-arm-kernel

v5->v6:
	Fix cross building errors found by kbuild test.
	Export busn_resource to Xen pcifront driver.
v4->v5:
	Fix some code style issues and rename some functions suggested by Bjorn.
	Fix some code flaw(Eg. call pci_bus_add_devices() before resources claim
	or lack the return checking).
v3->v4:
	Fix the rebase issue.
v2->v3:
	Rebase this series on v4.0-rc1.
v1->v2:
	Split pci_host_bridge_list into a new patch, remove .phb_probe_mode
	and rework powerpc .phb_of_scan_bus() for simpilicty suggested by
	Arnd. Refresh some patch description log, and add a new patch to fix
	build warning in ia64.

This series is based on Bjorn's pci-next branch.

Patch 1-4 ripped out pci_bus_add_devices() from pci scan interfaces
for better pci scan flow.

Patch 5-11 make a generic pci_host_bridge to hold pci_host_bridge
related informations, and introduce a pci_host_bridge_ops to 
support platform host drivers provide its own pci_host_bridge 
related operations to setup pci_host_bridge during pci enumeration.

Patch 12-28 apply the new pci scan interfaces to platform pci host
bridge drivers.

Now in kernel, we scan pci bus use the following ways:
1. pci_scan_bus. 
	parent = NULL, default io/mem/bus resources
	call pci_bus_add_devices()

2. pci_scan_bus_parented() + pci_bus_add_devices()
	default io/mem/bus resources, only used by xen

3. pci_scan_root_bus() + pci_bus_add_devices()

4. pci_create_root_bus() + pci_scan_child_bus() + pci_bus_add_devices()

5. pci_create_root_bus() + xx_of_scan_bus()  +  pci_bus_add_devices()

And we have a lot of arch specific pci_domain_nr() and other platform
specific weak function like pcibios_root_bridge_prepare().

After applied this series, we have following scan interfaces:

1. pci_scan_bus() 
	parent = NULL, default io/mem/bus resources.
	for legacy pci scan

2. pci_scan_root_bus()
	for callers provide its own parent and io/mem/bus resources
	but no platform specific pci_host_bridge operations

3. pci_scan_root_bridge()
	for callers provide its own parent and io/mem/bus resources


Arnd Bergmann (1):
  xen/PCI: Don't use deprecated function pci_scan_bus_parented()

Yijing Wang (29):
  PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  PCI: Export busn_resource to drivers/pci
  PCI: Remove deprecated pci_scan_bus_parented()
  PCI: Combine PCI domain and bus number in u32 arg
  PCI: Pass PCI domain number combined with root bus number
  PCI: Introduce pci_host_assign_domain_nr() to assign domain
  PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  PCI: Introduce pci_host_bridge_list to manage host bridges
  PCI: Save sysdata in pci_host_bridge drvdata
  PCI: Introduce pci_host_bridge_ops to support host specific
    operations
  PCI: Introduce new scan function pci_scan_host_bridge()
  x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  powerpc/pci: Rename pcibios_root_bridge_prepare()
  powerpc/pci: Use pci_scan_host_bridge() for simplicity
  PCI: Remove weak pcibios_root_bridge_prepare()
  sparc/PCI: Claim bus resources before pci_bus_add_devices()
  sparc/PCI: Use pci_scan_host_bridge() for simplicity
  PCI: Introduce pci_bus_child_max_busnr()
  parisc/PCI: Use pci_scan_root_bus() for simplicity
  PCI/mvebu: Use pci_common_init_dev() to simplify code
  PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  PCI/designware: Use pci_scan_root_bus() for simplicity
  PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  PCI: Export find_pci_host_bridge() and rename to
    pci_find_host_bridge()
  PCI: Remove platform specific pci_domain_nr()
  PCI: Remove pci_bus_assign_domain_nr()

 arch/alpha/include/asm/pci.h             |    2 -
 arch/alpha/kernel/pci.c                  |   14 ++-
 arch/alpha/kernel/sys_nautilus.c         |    6 +-
 arch/frv/mb93090-mb00/pci-vdk.c          |    6 +-
 arch/ia64/include/asm/pci.h              |    1 -
 arch/ia64/pci/pci.c                      |   34 +++---
 arch/ia64/sn/kernel/io_init.c            |    7 +-
 arch/m68k/coldfire/pci.c                 |    1 +
 arch/microblaze/pci/pci-common.c         |   19 +--
 arch/mips/include/asm/pci.h              |    2 -
 arch/mips/pci/pci.c                      |    5 +-
 arch/mn10300/unit-asb2305/pci.c          |    7 +-
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   77 ++++++------
 arch/powerpc/platforms/pseries/pci.c     |    8 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 arch/s390/pci/pci.c                      |   13 +--
 arch/sh/drivers/pci/pci.c                |    6 +-
 arch/sh/include/asm/pci.h                |    2 -
 arch/sparc/kernel/leon_pci.c             |    1 +
 arch/sparc/kernel/pci.c                  |   51 ++++-----
 arch/sparc/kernel/pcic.c                 |    3 +
 arch/tile/include/asm/pci.h              |    2 -
 arch/tile/kernel/pci.c                   |    7 +-
 arch/tile/kernel/pci_gx.c                |    7 +-
 arch/unicore32/kernel/pci.c              |   11 +--
 arch/x86/include/asm/pci.h               |    6 -
 arch/x86/pci/acpi.c                      |   37 +++---
 arch/x86/pci/common.c                    |    4 +-
 arch/xtensa/kernel/pci.c                 |   11 ++-
 drivers/parisc/dino.c                    |    8 +-
 drivers/parisc/lba_pci.c                 |    7 +-
 drivers/pci/host-bridge.c                |   93 ++++++++++++++-
 drivers/pci/host/pci-mvebu.c             |   18 +---
 drivers/pci/host/pci-tegra.c             |   16 ---
 drivers/pci/host/pci-xgene.c             |    3 +-
 drivers/pci/host/pcie-designware.c       |    4 +-
 drivers/pci/hotplug/acpiphp_glue.c       |   29 +-----
 drivers/pci/hotplug/ibmphp_core.c        |    8 +-
 drivers/pci/pci.c                        |   50 +++++++-
 drivers/pci/pci.h                        |    9 ++
 drivers/pci/probe.c                      |  196 ++++++++++++------------------
 drivers/pci/xen-pcifront.c               |   13 ++-
 include/linux/pci.h                      |   42 ++++---
 include/uapi/linux/pci.h                 |    3 +
 46 files changed, 458 insertions(+), 397 deletions(-)

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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-09  2:33 ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

v5->v6:
	Fix cross building errors found by kbuild test.
	Export busn_resource to Xen pcifront driver.
v4->v5:
	Fix some code style issues and rename some functions suggested by Bjorn.
	Fix some code flaw(Eg. call pci_bus_add_devices() before resources claim
	or lack the return checking).
v3->v4:
	Fix the rebase issue.
v2->v3:
	Rebase this series on v4.0-rc1.
v1->v2:
	Split pci_host_bridge_list into a new patch, remove .phb_probe_mode
	and rework powerpc .phb_of_scan_bus() for simpilicty suggested by
	Arnd. Refresh some patch description log, and add a new patch to fix
	build warning in ia64.

This series is based on Bjorn's pci-next branch.

Patch 1-4 ripped out pci_bus_add_devices() from pci scan interfaces
for better pci scan flow.

Patch 5-11 make a generic pci_host_bridge to hold pci_host_bridge
related informations, and introduce a pci_host_bridge_ops to 
support platform host drivers provide its own pci_host_bridge 
related operations to setup pci_host_bridge during pci enumeration.

Patch 12-28 apply the new pci scan interfaces to platform pci host
bridge drivers.

Now in kernel, we scan pci bus use the following ways:
1. pci_scan_bus. 
	parent = NULL, default io/mem/bus resources
	call pci_bus_add_devices()

2. pci_scan_bus_parented() + pci_bus_add_devices()
	default io/mem/bus resources, only used by xen

3. pci_scan_root_bus() + pci_bus_add_devices()

4. pci_create_root_bus() + pci_scan_child_bus() + pci_bus_add_devices()

5. pci_create_root_bus() + xx_of_scan_bus()  +  pci_bus_add_devices()

And we have a lot of arch specific pci_domain_nr() and other platform
specific weak function like pcibios_root_bridge_prepare().

After applied this series, we have following scan interfaces:

1. pci_scan_bus() 
	parent = NULL, default io/mem/bus resources.
	for legacy pci scan

2. pci_scan_root_bus()
	for callers provide its own parent and io/mem/bus resources
	but no platform specific pci_host_bridge operations

3. pci_scan_root_bridge()
	for callers provide its own parent and io/mem/bus resources


Arnd Bergmann (1):
  xen/PCI: Don't use deprecated function pci_scan_bus_parented()

Yijing Wang (29):
  PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  PCI: Export busn_resource to drivers/pci
  PCI: Remove deprecated pci_scan_bus_parented()
  PCI: Combine PCI domain and bus number in u32 arg
  PCI: Pass PCI domain number combined with root bus number
  PCI: Introduce pci_host_assign_domain_nr() to assign domain
  PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  PCI: Introduce pci_host_bridge_list to manage host bridges
  PCI: Save sysdata in pci_host_bridge drvdata
  PCI: Introduce pci_host_bridge_ops to support host specific
    operations
  PCI: Introduce new scan function pci_scan_host_bridge()
  x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  powerpc/pci: Rename pcibios_root_bridge_prepare()
  powerpc/pci: Use pci_scan_host_bridge() for simplicity
  PCI: Remove weak pcibios_root_bridge_prepare()
  sparc/PCI: Claim bus resources before pci_bus_add_devices()
  sparc/PCI: Use pci_scan_host_bridge() for simplicity
  PCI: Introduce pci_bus_child_max_busnr()
  parisc/PCI: Use pci_scan_root_bus() for simplicity
  PCI/mvebu: Use pci_common_init_dev() to simplify code
  PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  PCI/designware: Use pci_scan_root_bus() for simplicity
  PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  PCI: Export find_pci_host_bridge() and rename to
    pci_find_host_bridge()
  PCI: Remove platform specific pci_domain_nr()
  PCI: Remove pci_bus_assign_domain_nr()

 arch/alpha/include/asm/pci.h             |    2 -
 arch/alpha/kernel/pci.c                  |   14 ++-
 arch/alpha/kernel/sys_nautilus.c         |    6 +-
 arch/frv/mb93090-mb00/pci-vdk.c          |    6 +-
 arch/ia64/include/asm/pci.h              |    1 -
 arch/ia64/pci/pci.c                      |   34 +++---
 arch/ia64/sn/kernel/io_init.c            |    7 +-
 arch/m68k/coldfire/pci.c                 |    1 +
 arch/microblaze/pci/pci-common.c         |   19 +--
 arch/mips/include/asm/pci.h              |    2 -
 arch/mips/pci/pci.c                      |    5 +-
 arch/mn10300/unit-asb2305/pci.c          |    7 +-
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   77 ++++++------
 arch/powerpc/platforms/pseries/pci.c     |    8 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 arch/s390/pci/pci.c                      |   13 +--
 arch/sh/drivers/pci/pci.c                |    6 +-
 arch/sh/include/asm/pci.h                |    2 -
 arch/sparc/kernel/leon_pci.c             |    1 +
 arch/sparc/kernel/pci.c                  |   51 ++++-----
 arch/sparc/kernel/pcic.c                 |    3 +
 arch/tile/include/asm/pci.h              |    2 -
 arch/tile/kernel/pci.c                   |    7 +-
 arch/tile/kernel/pci_gx.c                |    7 +-
 arch/unicore32/kernel/pci.c              |   11 +--
 arch/x86/include/asm/pci.h               |    6 -
 arch/x86/pci/acpi.c                      |   37 +++---
 arch/x86/pci/common.c                    |    4 +-
 arch/xtensa/kernel/pci.c                 |   11 ++-
 drivers/parisc/dino.c                    |    8 +-
 drivers/parisc/lba_pci.c                 |    7 +-
 drivers/pci/host-bridge.c                |   93 ++++++++++++++-
 drivers/pci/host/pci-mvebu.c             |   18 +---
 drivers/pci/host/pci-tegra.c             |   16 ---
 drivers/pci/host/pci-xgene.c             |    3 +-
 drivers/pci/host/pcie-designware.c       |    4 +-
 drivers/pci/hotplug/acpiphp_glue.c       |   29 +-----
 drivers/pci/hotplug/ibmphp_core.c        |    8 +-
 drivers/pci/pci.c                        |   50 +++++++-
 drivers/pci/pci.h                        |    9 ++
 drivers/pci/probe.c                      |  196 ++++++++++++------------------
 drivers/pci/xen-pcifront.c               |   13 ++-
 include/linux/pci.h                      |   42 ++++---
 include/uapi/linux/pci.h                 |    3 +
 46 files changed, 458 insertions(+), 397 deletions(-)


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-09  2:33 ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

v5->v6:
	Fix cross building errors found by kbuild test.
	Export busn_resource to Xen pcifront driver.
v4->v5:
	Fix some code style issues and rename some functions suggested by Bjorn.
	Fix some code flaw(Eg. call pci_bus_add_devices() before resources claim
	or lack the return checking).
v3->v4:
	Fix the rebase issue.
v2->v3:
	Rebase this series on v4.0-rc1.
v1->v2:
	Split pci_host_bridge_list into a new patch, remove .phb_probe_mode
	and rework powerpc .phb_of_scan_bus() for simpilicty suggested by
	Arnd. Refresh some patch description log, and add a new patch to fix
	build warning in ia64.

This series is based on Bjorn's pci-next branch.

Patch 1-4 ripped out pci_bus_add_devices() from pci scan interfaces
for better pci scan flow.

Patch 5-11 make a generic pci_host_bridge to hold pci_host_bridge
related informations, and introduce a pci_host_bridge_ops to 
support platform host drivers provide its own pci_host_bridge 
related operations to setup pci_host_bridge during pci enumeration.

Patch 12-28 apply the new pci scan interfaces to platform pci host
bridge drivers.

Now in kernel, we scan pci bus use the following ways:
1. pci_scan_bus. 
	parent = NULL, default io/mem/bus resources
	call pci_bus_add_devices()

2. pci_scan_bus_parented() + pci_bus_add_devices()
	default io/mem/bus resources, only used by xen

3. pci_scan_root_bus() + pci_bus_add_devices()

4. pci_create_root_bus() + pci_scan_child_bus() + pci_bus_add_devices()

5. pci_create_root_bus() + xx_of_scan_bus()  +  pci_bus_add_devices()

And we have a lot of arch specific pci_domain_nr() and other platform
specific weak function like pcibios_root_bridge_prepare().

After applied this series, we have following scan interfaces:

1. pci_scan_bus() 
	parent = NULL, default io/mem/bus resources.
	for legacy pci scan

2. pci_scan_root_bus()
	for callers provide its own parent and io/mem/bus resources
	but no platform specific pci_host_bridge operations

3. pci_scan_root_bridge()
	for callers provide its own parent and io/mem/bus resources


Arnd Bergmann (1):
  xen/PCI: Don't use deprecated function pci_scan_bus_parented()

Yijing Wang (29):
  PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  PCI: Export busn_resource to drivers/pci
  PCI: Remove deprecated pci_scan_bus_parented()
  PCI: Combine PCI domain and bus number in u32 arg
  PCI: Pass PCI domain number combined with root bus number
  PCI: Introduce pci_host_assign_domain_nr() to assign domain
  PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  PCI: Introduce pci_host_bridge_list to manage host bridges
  PCI: Save sysdata in pci_host_bridge drvdata
  PCI: Introduce pci_host_bridge_ops to support host specific
    operations
  PCI: Introduce new scan function pci_scan_host_bridge()
  x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  powerpc/pci: Rename pcibios_root_bridge_prepare()
  powerpc/pci: Use pci_scan_host_bridge() for simplicity
  PCI: Remove weak pcibios_root_bridge_prepare()
  sparc/PCI: Claim bus resources before pci_bus_add_devices()
  sparc/PCI: Use pci_scan_host_bridge() for simplicity
  PCI: Introduce pci_bus_child_max_busnr()
  parisc/PCI: Use pci_scan_root_bus() for simplicity
  PCI/mvebu: Use pci_common_init_dev() to simplify code
  PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  PCI/designware: Use pci_scan_root_bus() for simplicity
  PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  PCI: Export find_pci_host_bridge() and rename to
    pci_find_host_bridge()
  PCI: Remove platform specific pci_domain_nr()
  PCI: Remove pci_bus_assign_domain_nr()

 arch/alpha/include/asm/pci.h             |    2 -
 arch/alpha/kernel/pci.c                  |   14 ++-
 arch/alpha/kernel/sys_nautilus.c         |    6 +-
 arch/frv/mb93090-mb00/pci-vdk.c          |    6 +-
 arch/ia64/include/asm/pci.h              |    1 -
 arch/ia64/pci/pci.c                      |   34 +++---
 arch/ia64/sn/kernel/io_init.c            |    7 +-
 arch/m68k/coldfire/pci.c                 |    1 +
 arch/microblaze/pci/pci-common.c         |   19 +--
 arch/mips/include/asm/pci.h              |    2 -
 arch/mips/pci/pci.c                      |    5 +-
 arch/mn10300/unit-asb2305/pci.c          |    7 +-
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   77 ++++++------
 arch/powerpc/platforms/pseries/pci.c     |    8 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 arch/s390/pci/pci.c                      |   13 +--
 arch/sh/drivers/pci/pci.c                |    6 +-
 arch/sh/include/asm/pci.h                |    2 -
 arch/sparc/kernel/leon_pci.c             |    1 +
 arch/sparc/kernel/pci.c                  |   51 ++++-----
 arch/sparc/kernel/pcic.c                 |    3 +
 arch/tile/include/asm/pci.h              |    2 -
 arch/tile/kernel/pci.c                   |    7 +-
 arch/tile/kernel/pci_gx.c                |    7 +-
 arch/unicore32/kernel/pci.c              |   11 +--
 arch/x86/include/asm/pci.h               |    6 -
 arch/x86/pci/acpi.c                      |   37 +++---
 arch/x86/pci/common.c                    |    4 +-
 arch/xtensa/kernel/pci.c                 |   11 ++-
 drivers/parisc/dino.c                    |    8 +-
 drivers/parisc/lba_pci.c                 |    7 +-
 drivers/pci/host-bridge.c                |   93 ++++++++++++++-
 drivers/pci/host/pci-mvebu.c             |   18 +---
 drivers/pci/host/pci-tegra.c             |   16 ---
 drivers/pci/host/pci-xgene.c             |    3 +-
 drivers/pci/host/pcie-designware.c       |    4 +-
 drivers/pci/hotplug/acpiphp_glue.c       |   29 +-----
 drivers/pci/hotplug/ibmphp_core.c        |    8 +-
 drivers/pci/pci.c                        |   50 +++++++-
 drivers/pci/pci.h                        |    9 ++
 drivers/pci/probe.c                      |  196 ++++++++++++------------------
 drivers/pci/xen-pcifront.c               |   13 ++-
 include/linux/pci.h                      |   42 ++++---
 include/uapi/linux/pci.h                 |    3 +
 46 files changed, 458 insertions(+), 397 deletions(-)


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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:33   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, sparclinux,
	Bjorn Helgaas

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha@vger.kernel.org
CC: linux-m68k@lists.linux-m68k.org
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1


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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
  2015-03-09  2:33 ` Yijing Wang
                   ` (4 preceding siblings ...)
  (?)
@ 2015-03-09  2:33 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, sparclinux

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha@vger.kernel.org
CC: linux-m68k@lists.linux-m68k.org
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1

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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, sparclinux,
	Bjorn Helgaas

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha@vger.kernel.org
CC: linux-m68k@lists.linux-m68k.org
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1


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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: linux-arm-kernel

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha@vger.kernel.org
CC: linux-m68k@lists.linux-m68k.org
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1


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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: linux-arm-kernel

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha at vger.kernel.org
CC: linux-m68k at lists.linux-m68k.org
CC: sparclinux at vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1

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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, sparclinux,
	Bjorn Helgaas

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha@vger.kernel.org
CC: linux-m68k@lists.linux-m68k.org
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1


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

* [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, sparclinux

Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
	pci_scan_bus()
		...
		pci_bus_add_devices() --- try to attach driver
	pci_fixup_irqs()
	pci_bus_size_bridges()
	pci_bus_assign_resources()

Above code flow make pci scan logic obscure, resources should
be assigned correctly before attaching driver. Because
pci_scan_bus() mostly be called in system boot path, when
before drivers are loaded(in module_init), so no pci scan
issues will occur. Most pci_scan_bus() callers additionally
call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus(), we could rip out pci_bus_add_devices()
for better code readability. After applied this patch,
pci_scan_bus() should be used like:

pci_scan_bus() (mandatory)
pci_fixup_irqs() (optional)
pci_bus_size_bridges() (optional)
pci_pci_bus_assign_resources() (optional)
pci_bus_add_devices() (mandatory)

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Geert Uytterhoeven <geert@linux-m68k.org>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: linux-alpha@vger.kernel.org
CC: linux-m68k@lists.linux-m68k.org
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/sys_nautilus.c  |    4 ++++
 arch/m68k/coldfire/pci.c          |    1 +
 arch/sparc/kernel/pcic.c          |    3 +++
 arch/unicore32/kernel/pci.c       |   11 +++--------
 drivers/pci/hotplug/ibmphp_core.c |    8 ++++++--
 drivers/pci/probe.c               |    1 -
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 837c0fa..700686d 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -207,6 +207,9 @@ nautilus_init_pci(void)
 
 	/* Scan our single hose.  */
 	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	if (!bus)
+		return;
+
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
@@ -253,6 +256,7 @@ nautilus_init_pci(void)
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index df96792..d45f087 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)
 	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
+	pci_bus_add_devices(rootbus);
 	return 0;
 }
 
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6cc78c2..0f4dc6b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -391,12 +391,15 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
 	struct linux_pbm_info *pbm = &pcic->pbm;
 
 	pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
+	if (!pbm->pci_bus)
+		return;
 #if 0 /* deadwood transplanted from sparc64 */
 	pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
 	pci_record_assignments(pbm, pbm->pci_bus);
 	pci_assign_unassigned(pbm, pbm->pci_bus);
 	pci_fixup_irq(pbm, pbm->pci_bus);
 #endif
+	pci_bus_add_devices(pbm->pci_bus);
 }
 
 /*
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 374a055..3d82024 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)
 	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
 
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		/*
-		 * Size the bridge windows.
-		 */
+		/* Size the bridge windows. */
 		pci_bus_size_bridges(puv3_bus);
-
-		/*
-		 * Assign resources.
-		 */
+		/* Assign resources. */
 		pci_bus_assign_resources(puv3_bus);
 	}
-
+	pci_bus_add_devices(puv3_bus);
 	return 0;
 }
 subsys_initcall(pci_common_init);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 96c5c72..1530247 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
  */
 static u8 bus_structure_fixup(u8 busno)
 {
-	struct pci_bus *bus;
+	struct pci_bus *bus, *b;
 	struct pci_dev *dev;
 	u16 l;
 
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno)
 					(l != 0x0000) && (l != 0xffff)) {
 			debug("%s - Inside bus_structure_fixup()\n",
 							__func__);
-			pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
+			if (!b)
+				continue;
+
+			pci_bus_add_devices(b);
 			break;
 		}
 	}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8d2f400..88604f2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
-		pci_bus_add_devices(b);
 	} else {
 		pci_free_resource_list(&resources);
 	}
-- 
1.7.1


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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:33   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: linux-arm-kernel

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-am33-list@redhat.com
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linux-xtensa@linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus = NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1


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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, David Howells,
	Michal Simek, Ralf Baechle, Koichi Yasutake, Sebastian Ott,
	Chris Metcalf, Chris Zankel, Max Filippov, linux-mips,
	linux-am33-list, linux-s390, linux-sh, sparclinux, linux-xtensa,
	Bjorn Helgaas

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-am33-list@redhat.com
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linux-xtensa@linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1


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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                   ` (5 preceding siblings ...)
  (?)
@ 2015-03-09  2:33 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-am33-list@redhat.com
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linux-xtensa@linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1

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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, David Howells,
	Michal Simek, Ralf Baechle, Koichi Yasutake, Sebastian Ott,
	Chris Metcalf, Chris Zankel, Max Filippov, linux-mips,
	linux-am33-list, linux-s390, linux-sh, sparclinux, linux-xtensa,
	Bjorn Helgaas

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-am33-list@redhat.com
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linux-xtensa@linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1


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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, David Howells,
	Michal Simek, Ralf Baechle, Koichi Yasutake, Sebastian Ott,
	Chris Metcalf, Chris Zankel, Max Filippov, linux-mips,
	linux-am33-list, linux-s390, linux-sh, sparclinux, linux-xtensa

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-am33-list@redhat.com
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linux-xtensa@linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1

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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: linux-arm-kernel

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha at vger.kernel.org
CC: linux-kernel at vger.kernel.org
CC: linux-mips at linux-mips.org
CC: linux-am33-list at redhat.com
CC: linux-s390 at vger.kernel.org
CC: linux-sh at vger.kernel.org
CC: sparclinux at vger.kernel.org
CC: linux-xtensa at linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1

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

* [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
@ 2015-03-09  2:33   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard

Just like pci_scan_bus(), we also should rip out
pci_bus_add_devices() from pci_scan_root_bus().
Lots platforms first call pci_scan_root_bus(), but
after that, they call pci_bus_size_bridges() and
pci_bus_assign_resources(). Place pci_bus_add_devices()
in pci_scan_root_bus() hurts PCI scan logic.
For arm hw_pci->scan() functions which call
pci_scan_root_bus(), it's no need to change anything,
because pci_bus_add_devices() will be called later
in pci_common_init_dev().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: David Howells <dhowells@redhat.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Chris Zankel <chris@zankel.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-am33-list@redhat.com
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: linux-xtensa@linux-xtensa.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    9 ++++++++-
 arch/frv/mb93090-mb00/pci-vdk.c  |    6 +++++-
 arch/ia64/sn/kernel/io_init.c    |    2 ++
 arch/microblaze/pci/pci-common.c |    3 +++
 arch/mips/pci/pci.c              |    1 +
 arch/mn10300/unit-asb2305/pci.c  |    7 ++++++-
 arch/s390/pci/pci.c              |    2 +-
 arch/sh/drivers/pci/pci.c        |    1 +
 arch/sparc/kernel/leon_pci.c     |    1 +
 arch/tile/kernel/pci.c           |    2 ++
 arch/tile/kernel/pci_gx.c        |    2 ++
 arch/x86/pci/common.c            |    1 +
 arch/xtensa/kernel/pci.c         |   11 +++++++++--
 drivers/pci/probe.c              |    1 -
 14 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 98a1525..5c845ad 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,7 +312,7 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
-	struct pci_bus *bus;
+	struct pci_bus *bus, *root_bus;
 	int next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
@@ -338,6 +338,8 @@ common_init_pci(void)
 
 		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
 					hose, &resources);
+		if (!bus)
+			continue;
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
@@ -353,6 +355,11 @@ common_init_pci(void)
 
 	pci_assign_unassigned_resources();
 	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
+	for (hose = hose_head; hose; hose = hose->next) {
+		root_bus = hose->bus;
+		if (root_bus)
+			pci_bus_add_devices(root_bus);
+	}
 }
 
 
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index b073f4d..f211839 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 
 int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	struct pci_ops *dir = NULL;
 	LIST_HEAD(resources);
 
@@ -383,12 +384,15 @@ int __init pcibios_init(void)
 	printk("PCI: Probing PCI hardware\n");
 	pci_add_resource(&resources, &pci_ioport_resource);
 	pci_add_resource(&resources, &pci_iomem_resource);
-	pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
 
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0b5ce82..1be65eb 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
+		return;
 	}
+	pci_bus_add_devices(bus);
 }
 
 /*
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 48528fb..6d8d173 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1382,6 +1382,9 @@ static int __init pcibios_init(void)
 
 	/* Call common code to handle resource allocation */
 	pcibios_resource_survey();
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		if (hose->bus)
+			pci_bus_add_devices(hose->bus);
 
 	return 0;
 }
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 1bf60b1..9eb54b5 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_size_bridges(bus);
 			pci_bus_assign_resources(bus);
 		}
+		pci_bus_add_devices(bus);
 	}
 }
 
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 613ca1e..cde5e05 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct pci_bus *bus;
 	resource_size_t io_offset, mem_offset;
 	LIST_HEAD(resources);
 
@@ -371,11 +372,15 @@ static int __init pcibios_init(void)
 
 	pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
 	pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
-	pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
+	bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();
 	pcibios_resource_survey();
+	if (!bus)
+		return 0;
+
+	pci_bus_add_devices(bus);
 	return 0;
 }
 
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 753a567..a2a7391 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -776,8 +776,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
 	}
-
 	zdev->bus->max_bus_speed = zdev->max_bus_speed;
+	pci_bus_add_devices(zdev->bus);
 	return 0;
 }
 
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1bc09ee..efc1051 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
+		pci_bus_add_devices(bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 899b720..2971076 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+		pci_bus_add_devices(root_bus);
 	} else {
 		pci_free_resource_list(&resources);
 	}
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 325df47..9475a74 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -339,6 +339,8 @@ int __init pcibios_init(void)
 			struct pci_bus *next_bus;
 			struct pci_dev *dev;
 
+			pci_bus_add_devices(root_bus);
+
 			list_for_each_entry(dev, &root_bus->devices, bus_list) {
 				/*
 				 * Find the PCI host controller, ie. the 1st
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 2c95f37..b1df847 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void)
 alloc_mem_map_failed:
 			break;
 		}
+
+		pci_bus_add_devices(root_bus);
 	}
 
 	return 0;
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 3d2612b..0cbc723 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)
 		pci_free_resource_list(&resources);
 		kfree(sd);
 	}
+	pci_bus_add_devices(bus);
 }
 
 void __init pcibios_set_cache_line_size(void)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 5b34033..140e2fd 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -174,7 +174,7 @@ static int __init pcibios_init(void)
 	struct pci_controller *pci_ctrl;
 	struct list_head resources;
 	struct pci_bus *bus;
-	int next_busno = 0;
+	int ret, next_busno = 0;
 
 	printk("PCI: Probing PCI hardware\n");
 
@@ -185,14 +185,21 @@ static int __init pcibios_init(void)
 		pci_controller_apertures(pci_ctrl, &resources);
 		bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
 					pci_ctrl->ops, pci_ctrl, &resources);
+		if (!bus)
+			continue;
+
 		pci_ctrl->bus = bus;
 		pci_ctrl->last_busno = bus->busn_res.end;
 		if (next_busno <= pci_ctrl->last_busno)
 			next_busno = pci_ctrl->last_busno+1;
 	}
 	pci_bus_count = next_busno;
+	ret = platform_pcibios_fixup();
+	for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next)
+		if (pci_ctrl->bus)
+			pci_bus_add_devices(pci_ctrl->bus);
 
-	return platform_pcibios_fixup();
+	return ret;
 }
 
 subsys_initcall(pcibios_init);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 88604f2..8ef0375 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 	if (!found)
 		pci_bus_update_busn_res_end(b, max);
 
-	pci_bus_add_devices(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
-- 
1.7.1



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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Export out busn_resource. Xen pcifront module need it.

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

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4091f82..eeacab9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
 /* Functions internal to the PCI core code */
 
+extern struct resource busn_resource;
+
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
 #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8ef0375..b97ea81 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -17,12 +17,13 @@
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR	3
 
-static struct resource busn_resource = {
+struct resource busn_resource = {
 	.name	= "PCI busn",
 	.start	= 0,
 	.end	= 255,
 	.flags	= IORESOURCE_BUS,
 };
+EXPORT_SYMBOL(busn_resource);
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
-- 
1.7.1


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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-09  2:33 ` Yijing Wang
                   ` (8 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Export out busn_resource. Xen pcifront module need it.

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

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4091f82..eeacab9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
 /* Functions internal to the PCI core code */
 
+extern struct resource busn_resource;
+
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
 #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8ef0375..b97ea81 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -17,12 +17,13 @@
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR	3
 
-static struct resource busn_resource = {
+struct resource busn_resource = {
 	.name	= "PCI busn",
 	.start	= 0,
 	.end	= 255,
 	.flags	= IORESOURCE_BUS,
 };
+EXPORT_SYMBOL(busn_resource);
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
-- 
1.7.1

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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Export out busn_resource. Xen pcifront module need it.

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

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4091f82..eeacab9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
 /* Functions internal to the PCI core code */
 
+extern struct resource busn_resource;
+
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
 #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8ef0375..b97ea81 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -17,12 +17,13 @@
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR	3
 
-static struct resource busn_resource = {
+struct resource busn_resource = {
 	.name	= "PCI busn",
 	.start	= 0,
 	.end	= 255,
 	.flags	= IORESOURCE_BUS,
 };
+EXPORT_SYMBOL(busn_resource);
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
-- 
1.7.1


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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Export out busn_resource. Xen pcifront module need it.

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

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4091f82..eeacab9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
 /* Functions internal to the PCI core code */
 
+extern struct resource busn_resource;
+
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
 #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8ef0375..b97ea81 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -17,12 +17,13 @@
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR	3
 
-static struct resource busn_resource = {
+struct resource busn_resource = {
 	.name	= "PCI busn",
 	.start	= 0,
 	.end	= 255,
 	.flags	= IORESOURCE_BUS,
 };
+EXPORT_SYMBOL(busn_resource);
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
-- 
1.7.1

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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Export out busn_resource. Xen pcifront module need it.

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

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4091f82..eeacab9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
 /* Functions internal to the PCI core code */
 
+extern struct resource busn_resource;
+
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
 #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8ef0375..b97ea81 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -17,12 +17,13 @@
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR	3
 
-static struct resource busn_resource = {
+struct resource busn_resource = {
 	.name	= "PCI busn",
 	.start	= 0,
 	.end	= 255,
 	.flags	= IORESOURCE_BUS,
 };
+EXPORT_SYMBOL(busn_resource);
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
-- 
1.7.1


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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Liviu Dudau, Rusty Russell, Russell King, Arnd Bergmann,
	Marc Zyngier, linux-pci, x86, linux-m68k, linux-kernel,
	David S. Miller, linux-alpha, Tony Luck, Geert Uytterhoeven,
	Benjamin Herrenschmidt, Yijing Wang, linux-ia64, Thomas Gleixner,
	Guan Xuetao, Yinghai Lu, Jiang Liu, linux-arm-kernel

Export out busn_resource. Xen pcifront module need it.

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

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4091f82..eeacab9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
 /* Functions internal to the PCI core code */
 
+extern struct resource busn_resource;
+
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
 #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8ef0375..b97ea81 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -17,12 +17,13 @@
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
 #define CARDBUS_RESERVE_BUSNR	3
 
-static struct resource busn_resource = {
+struct resource busn_resource = {
 	.name	= "PCI busn",
 	.start	= 0,
 	.end	= 255,
 	.flags	= IORESOURCE_BUS,
 };
+EXPORT_SYMBOL(busn_resource);
 
 /* Ugh.  Need to stop exporting this to modules. */
 LIST_HEAD(pci_root_buses);
-- 
1.7.1

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Konrad Rzeszutek Wilk, xen-devel, Bjorn Helgaas

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1


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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-09  2:33 ` Yijing Wang
                   ` (10 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Konrad Rzeszutek Wilk, xen-devel, Bjorn Helgaas

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Konrad Rzeszutek Wilk, xen-devel, Bjorn Helgaas

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1


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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel at lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-09  2:33 ` Yijing Wang
                   ` (11 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, Geert Uytterhoeven, Benjamin Herrenschmidt, xen-devel,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Bjorn Helgaas, Thomas Gleixner, Yinghai Lu, linux-arm-kernel,
	Liviu Dudau, Tony Luck, linux-kernel, Jiang Liu, linux-alpha,
	David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Konrad Rzeszutek Wilk, xen-devel, Bjorn Helgaas

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn=0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1


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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Konrad Rzeszutek Wilk, xen-devel, Bjorn Helgaas

From: Arnd Bergmann <arnd@arndb.de>

Use pci_scan_root_bus() instead of deprecated function
pci_scan_bus_parented().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..9e7c28b 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -21,6 +21,7 @@
 #include <linux/bitops.h>
 #include <linux/time.h>
 #include <xen/platform_pci.h>
+#include "pci.h"
 
 #include <asm/xen/swiotlb-xen.h>
 #define INVALID_GRANT_REF (0)
@@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 				 unsigned int domain, unsigned int bus)
 {
 	struct pci_bus *b;
+	LIST_HEAD(resources);
 	struct pcifront_sd *sd = NULL;
 	struct pci_bus_entry *bus_entry = NULL;
 	int err = 0;
@@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 		err = -ENOMEM;
 		goto err_out;
 	}
+	pci_add_resource(&resources, &ioport_resource);
+	pci_add_resource(&resources, &iomem_resource);
+	pci_add_resource(&resources, &busn_resource);
 	pcifront_init_sd(sd, domain, bus, pdev);
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+				  &pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
 		err = -ENOMEM;
 		pci_unlock_rescan_remove();
+		pci_free_resource_list(&resources);
 		goto err_out;
 	}
 
@@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_root_bus skips devices which do not have a
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 
-- 
1.7.1

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

* [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

No one uses pci_scan_bus_parented() any more,
remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   19 -------------------
 include/linux/pci.h |    2 --
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b97ea81..187fa54 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2092,25 +2092,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-/* Deprecated; use pci_scan_root_bus() instead */
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
-{
-	LIST_HEAD(resources);
-	struct pci_bus *b;
-
-	pci_add_resource(&resources, &ioport_resource);
-	pci_add_resource(&resources, &iomem_resource);
-	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
-	if (b)
-		pci_scan_child_bus(b);
-	else
-		pci_free_resource_list(&resources);
-	return b;
-}
-EXPORT_SYMBOL(pci_scan_bus_parented);
-
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 					void *sysdata)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..36effb8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
-- 
1.7.1


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

* [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

No one uses pci_scan_bus_parented() any more,
remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   19 -------------------
 include/linux/pci.h |    2 --
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b97ea81..187fa54 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2092,25 +2092,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-/* Deprecated; use pci_scan_root_bus() instead */
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
-{
-	LIST_HEAD(resources);
-	struct pci_bus *b;
-
-	pci_add_resource(&resources, &ioport_resource);
-	pci_add_resource(&resources, &iomem_resource);
-	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
-	if (b)
-		pci_scan_child_bus(b);
-	else
-		pci_free_resource_list(&resources);
-	return b;
-}
-EXPORT_SYMBOL(pci_scan_bus_parented);
-
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 					void *sysdata)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..36effb8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
-- 
1.7.1

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

* [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

No one uses pci_scan_bus_parented() any more,
remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   19 -------------------
 include/linux/pci.h |    2 --
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b97ea81..187fa54 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2092,25 +2092,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-/* Deprecated; use pci_scan_root_bus() instead */
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
-{
-	LIST_HEAD(resources);
-	struct pci_bus *b;
-
-	pci_add_resource(&resources, &ioport_resource);
-	pci_add_resource(&resources, &iomem_resource);
-	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
-	if (b)
-		pci_scan_child_bus(b);
-	else
-		pci_free_resource_list(&resources);
-	return b;
-}
-EXPORT_SYMBOL(pci_scan_bus_parented);
-
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 					void *sysdata)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..36effb8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
-- 
1.7.1


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

* [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

No one uses pci_scan_bus_parented() any more,
remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   19 -------------------
 include/linux/pci.h |    2 --
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b97ea81..187fa54 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2092,25 +2092,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-/* Deprecated; use pci_scan_root_bus() instead */
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
-{
-	LIST_HEAD(resources);
-	struct pci_bus *b;
-
-	pci_add_resource(&resources, &ioport_resource);
-	pci_add_resource(&resources, &iomem_resource);
-	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
-	if (b)
-		pci_scan_child_bus(b);
-	else
-		pci_free_resource_list(&resources);
-	return b;
-}
-EXPORT_SYMBOL(pci_scan_bus_parented);
-
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 					void *sysdata)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..36effb8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
-- 
1.7.1

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

* [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

No one uses pci_scan_bus_parented() any more,
remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   19 -------------------
 include/linux/pci.h |    2 --
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b97ea81..187fa54 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2092,25 +2092,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-/* Deprecated; use pci_scan_root_bus() instead */
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
-{
-	LIST_HEAD(resources);
-	struct pci_bus *b;
-
-	pci_add_resource(&resources, &ioport_resource);
-	pci_add_resource(&resources, &iomem_resource);
-	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
-	if (b)
-		pci_scan_child_bus(b);
-	else
-		pci_free_resource_list(&resources);
-	return b;
-}
-EXPORT_SYMBOL(pci_scan_bus_parented);
-
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 					void *sysdata)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..36effb8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
-- 
1.7.1


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

* [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

No one uses pci_scan_bus_parented() any more,
remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   19 -------------------
 include/linux/pci.h |    2 --
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b97ea81..187fa54 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2092,25 +2092,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-/* Deprecated; use pci_scan_root_bus() instead */
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
-{
-	LIST_HEAD(resources);
-	struct pci_bus *b;
-
-	pci_add_resource(&resources, &ioport_resource);
-	pci_add_resource(&resources, &iomem_resource);
-	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(parent, bus, ops, sysdata, &resources);
-	if (b)
-		pci_scan_child_bus(b);
-	else
-		pci_free_resource_list(&resources);
-	return b;
-}
-EXPORT_SYMBOL(pci_scan_bus_parented);
-
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 					void *sysdata)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..36effb8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
-- 
1.7.1

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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Currently, we use int type for bus number in
pci_create_root_bus(), pci_scan_root_bus() and
pci_scan_bus_legacy. Because PCI bus number
always <= 255, so we could change the bus number
argument type to u32, and combine PCI domain and
bus number in one. Also add a domain member in
pci_host_bridge to save domain number. Finally,
we could eliminate lots of the platform specific
pci_domain_nr() in the last of the series.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c      |   16 +++++++++-------
 include/linux/pci.h      |    7 ++++---
 include/uapi/linux/pci.h |    3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 187fa54..3d6befd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
@@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
+	u8	bus = PCI_BUSNUM(db);
 
 	b = pci_alloc_bus(NULL);
 	if (!b)
@@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	if (!bridge)
 		goto err_out;
 
+	bridge->domain = PCI_DOMAIN(db);
 	bridge->dev.parent = parent;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
@@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	struct resource_entry *window;
@@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 			break;
 		}
 
-	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
 	if (!b)
 		return NULL;
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			bus);
-		pci_bus_insert_busn_res(b, bus, 255);
+			PCI_BUSNUM(db));
+		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
@@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
 	} else {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 36effb8..8b3d245 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 }
 
 struct pci_host_bridge {
+	u16	domain;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
index 3c292bc..89c6f15 100644
--- a/include/uapi/linux/pci.h
+++ b/include/uapi/linux/pci.h
@@ -30,6 +30,9 @@
 #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)		((devfn) & 0x07)
+#define PCI_DOMAIN(db)		((db) >> 16)
+#define PCI_BUSNUM(db)		((db) & 0xffff)
+#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
 
 /* Ioctls for /proc/bus/pci/X/Y nodes. */
 #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-- 
1.7.1


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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-09  2:33 ` Yijing Wang
                   ` (14 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Currently, we use int type for bus number in
pci_create_root_bus(), pci_scan_root_bus() and
pci_scan_bus_legacy. Because PCI bus number
always <= 255, so we could change the bus number
argument type to u32, and combine PCI domain and
bus number in one. Also add a domain member in
pci_host_bridge to save domain number. Finally,
we could eliminate lots of the platform specific
pci_domain_nr() in the last of the series.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c      |   16 +++++++++-------
 include/linux/pci.h      |    7 ++++---
 include/uapi/linux/pci.h |    3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 187fa54..3d6befd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
@@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
+	u8	bus = PCI_BUSNUM(db);
 
 	b = pci_alloc_bus(NULL);
 	if (!b)
@@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	if (!bridge)
 		goto err_out;
 
+	bridge->domain = PCI_DOMAIN(db);
 	bridge->dev.parent = parent;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
@@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	struct resource_entry *window;
@@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 			break;
 		}
 
-	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
 	if (!b)
 		return NULL;
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			bus);
-		pci_bus_insert_busn_res(b, bus, 255);
+			PCI_BUSNUM(db));
+		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
@@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
 	} else {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 36effb8..8b3d245 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 }
 
 struct pci_host_bridge {
+	u16	domain;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
index 3c292bc..89c6f15 100644
--- a/include/uapi/linux/pci.h
+++ b/include/uapi/linux/pci.h
@@ -30,6 +30,9 @@
 #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)		((devfn) & 0x07)
+#define PCI_DOMAIN(db)		((db) >> 16)
+#define PCI_BUSNUM(db)		((db) & 0xffff)
+#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
 
 /* Ioctls for /proc/bus/pci/X/Y nodes. */
 #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-- 
1.7.1

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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Currently, we use int type for bus number in
pci_create_root_bus(), pci_scan_root_bus() and
pci_scan_bus_legacy. Because PCI bus number
always <= 255, so we could change the bus number
argument type to u32, and combine PCI domain and
bus number in one. Also add a domain member in
pci_host_bridge to save domain number. Finally,
we could eliminate lots of the platform specific
pci_domain_nr() in the last of the series.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c      |   16 +++++++++-------
 include/linux/pci.h      |    7 ++++---
 include/uapi/linux/pci.h |    3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 187fa54..3d6befd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
@@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
+	u8	bus = PCI_BUSNUM(db);
 
 	b = pci_alloc_bus(NULL);
 	if (!b)
@@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	if (!bridge)
 		goto err_out;
 
+	bridge->domain = PCI_DOMAIN(db);
 	bridge->dev.parent = parent;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
@@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	struct resource_entry *window;
@@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 			break;
 		}
 
-	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
 	if (!b)
 		return NULL;
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			bus);
-		pci_bus_insert_busn_res(b, bus, 255);
+			PCI_BUSNUM(db));
+		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
@@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
 	} else {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 36effb8..8b3d245 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 }
 
 struct pci_host_bridge {
+	u16	domain;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
index 3c292bc..89c6f15 100644
--- a/include/uapi/linux/pci.h
+++ b/include/uapi/linux/pci.h
@@ -30,6 +30,9 @@
 #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)		((devfn) & 0x07)
+#define PCI_DOMAIN(db)		((db) >> 16)
+#define PCI_BUSNUM(db)		((db) & 0xffff)
+#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
 
 /* Ioctls for /proc/bus/pci/X/Y nodes. */
 #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-- 
1.7.1


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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Currently, we use int type for bus number in
pci_create_root_bus(), pci_scan_root_bus() and
pci_scan_bus_legacy. Because PCI bus number
always <= 255, so we could change the bus number
argument type to u32, and combine PCI domain and
bus number in one. Also add a domain member in
pci_host_bridge to save domain number. Finally,
we could eliminate lots of the platform specific
pci_domain_nr() in the last of the series.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c      |   16 +++++++++-------
 include/linux/pci.h      |    7 ++++---
 include/uapi/linux/pci.h |    3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 187fa54..3d6befd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
@@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
+	u8	bus = PCI_BUSNUM(db);
 
 	b = pci_alloc_bus(NULL);
 	if (!b)
@@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	if (!bridge)
 		goto err_out;
 
+	bridge->domain = PCI_DOMAIN(db);
 	bridge->dev.parent = parent;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
@@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	struct resource_entry *window;
@@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 			break;
 		}
 
-	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
 	if (!b)
 		return NULL;
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			bus);
-		pci_bus_insert_busn_res(b, bus, 255);
+			PCI_BUSNUM(db));
+		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
@@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
 	} else {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 36effb8..8b3d245 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 }
 
 struct pci_host_bridge {
+	u16	domain;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
index 3c292bc..89c6f15 100644
--- a/include/uapi/linux/pci.h
+++ b/include/uapi/linux/pci.h
@@ -30,6 +30,9 @@
 #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)		((devfn) & 0x07)
+#define PCI_DOMAIN(db)		((db) >> 16)
+#define PCI_BUSNUM(db)		((db) & 0xffff)
+#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
 
 /* Ioctls for /proc/bus/pci/X/Y nodes. */
 #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-- 
1.7.1

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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Currently, we use int type for bus number in
pci_create_root_bus(), pci_scan_root_bus() and
pci_scan_bus_legacy. Because PCI bus number
always <= 255, so we could change the bus number
argument type to u32, and combine PCI domain and
bus number in one. Also add a domain member in
pci_host_bridge to save domain number. Finally,
we could eliminate lots of the platform specific
pci_domain_nr() in the last of the series.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c      |   16 +++++++++-------
 include/linux/pci.h      |    7 ++++---
 include/uapi/linux/pci.h |    3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 187fa54..3d6befd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
@@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
+	u8	bus = PCI_BUSNUM(db);
 
 	b = pci_alloc_bus(NULL);
 	if (!b)
@@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	if (!bridge)
 		goto err_out;
 
+	bridge->domain = PCI_DOMAIN(db);
 	bridge->dev.parent = parent;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
@@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	struct resource_entry *window;
@@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 			break;
 		}
 
-	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
 	if (!b)
 		return NULL;
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			bus);
-		pci_bus_insert_busn_res(b, bus, 255);
+			PCI_BUSNUM(db));
+		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
@@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
 	} else {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 36effb8..8b3d245 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 }
 
 struct pci_host_bridge {
+	u16	domain;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
index 3c292bc..89c6f15 100644
--- a/include/uapi/linux/pci.h
+++ b/include/uapi/linux/pci.h
@@ -30,6 +30,9 @@
 #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)		((devfn) & 0x07)
+#define PCI_DOMAIN(db)		((db) >> 16)
+#define PCI_BUSNUM(db)		((db) & 0xffff)
+#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
 
 /* Ioctls for /proc/bus/pci/X/Y nodes. */
 #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-- 
1.7.1


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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Currently, we use int type for bus number in
pci_create_root_bus(), pci_scan_root_bus() and
pci_scan_bus_legacy. Because PCI bus number
always <= 255, so we could change the bus number
argument type to u32, and combine PCI domain and
bus number in one. Also add a domain member in
pci_host_bridge to save domain number. Finally,
we could eliminate lots of the platform specific
pci_domain_nr() in the last of the series.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c      |   16 +++++++++-------
 include/linux/pci.h      |    7 ++++---
 include/uapi/linux/pci.h |    3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 187fa54..3d6befd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	int error;
@@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
+	u8	bus = PCI_BUSNUM(db);
 
 	b = pci_alloc_bus(NULL);
 	if (!b)
@@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	if (!bridge)
 		goto err_out;
 
+	bridge->domain = PCI_DOMAIN(db);
 	bridge->dev.parent = parent;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
@@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
 	struct resource_entry *window;
@@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 			break;
 		}
 
-	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
+	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
 	if (!b)
 		return NULL;
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			bus);
-		pci_bus_insert_busn_res(b, bus, 255);
+			PCI_BUSNUM(db));
+		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
+struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
@@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
+	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
 	if (b) {
 		pci_scan_child_bus(b);
 	} else {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 36effb8..8b3d245 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 }
 
 struct pci_host_bridge {
+	u16	domain;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
index 3c292bc..89c6f15 100644
--- a/include/uapi/linux/pci.h
+++ b/include/uapi/linux/pci.h
@@ -30,6 +30,9 @@
 #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)		((devfn) & 0x07)
+#define PCI_DOMAIN(db)		((db) >> 16)
+#define PCI_BUSNUM(db)		((db) & 0xffff)
+#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
 
 /* Ioctls for /proc/bus/pci/X/Y nodes. */
 #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-- 
1.7.1


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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:33 ` Yijing Wang
                     ` (4 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus = NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus = NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus = NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1


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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel, Bjorn Helgaas

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1


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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:33 ` Yijing Wang
                   ` (17 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel, Bjorn Helgaas

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1


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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Yijing Wang, Guan Xuetao,
	linux-s390, Russell King, x86, Sebastian Ott, Geert Uytterhoeven,
	Gerald Schaefer, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Konrad Rzeszutek Wilk, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Bjorn Helgaas,
	Thomas Gleixner, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Liviu Dudau, Michal Simek, Tony Luck, linux-kernel, Ralf Baechle,
	Jiang Liu, linux-alpha, linuxppc-dev, David S. Miller

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha at vger.kernel.org
CC: linux-kernel at vger.kernel.org
CC: linux-ia64 at vger.kernel.org
CC: linux-mips at linux-mips.org
CC: linuxppc-dev at lists.ozlabs.org
CC: linux-s390 at vger.kernel.org
CC: linux-sh at vger.kernel.org
CC: sparclinux at vger.kernel.org
CC: xen-devel at lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:33 ` Yijing Wang
                   ` (16 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Yijing Wang, Guan Xuetao,
	linux-s390, Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Bjorn

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Richard

Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: Matt Turner <mattst88@gmail.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Michal Simek <monstr@monstr.eu>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Chris Metcalf <cmetcalf@ezchip.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: linux-alpha@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-sh@vger.kernel.org
CC: sparclinux@vger.kernel.org
CC: xen-devel@lists.xenproject.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c          |    5 +++--
 arch/alpha/kernel/sys_nautilus.c |    4 ++--
 arch/ia64/pci/pci.c              |    4 ++--
 arch/ia64/sn/kernel/io_init.c    |    5 +++--
 arch/microblaze/pci/pci-common.c |    5 +++--
 arch/mips/pci/pci.c              |    4 ++--
 arch/powerpc/kernel/pci-common.c |    5 +++--
 arch/s390/pci/pci.c              |    5 +++--
 arch/sh/drivers/pci/pci.c        |    5 +++--
 arch/sparc/kernel/pci.c          |    5 +++--
 arch/tile/kernel/pci.c           |    5 +++--
 arch/tile/kernel/pci_gx.c        |    5 +++--
 arch/x86/pci/acpi.c              |    7 ++++---
 arch/x86/pci/common.c            |    3 ++-
 drivers/pci/xen-pcifront.c       |    5 +++--
 15 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5c845ad..deb0a36 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(hose->index, next_busno),
+				alpha_mv.pci_ops, hose, &resources);
 		if (!bus)
 			continue;
 		hose->bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 700686d..be0bbeb 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,10 +206,10 @@ nautilus_init_pci(void)
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
+	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
+			alpha_mv.pci_ops, hose);
 	if (!bus)
 		return;
-
 	hose->bus = bus;
 	pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..675749f 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
-				   &info->resources);
+	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources);
 	if (!pbus) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 1be65eb..7e0b7f9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 	pci_add_resource_offset(&resources,	&res[1],
 			prom_bussoft_ptr->bs_legacy_mem);
 
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(controller->segment, busnum),
+			&pci_root_ops, controller, &resources);
  	if (bus == NULL) {
 		kfree(res);
 		kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 6d8d173..34a32ec 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
 
 	pcibios_setup_phb_resources(hose, &resources);
 
-	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
-				hose->ops, hose, &resources);
+	bus = pci_scan_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9eb54b5..86f8d2b 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->mem_resource, hose->mem_offset);
 	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	if (!bus)
 		pci_free_resource_list(&resources);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2a525c9..a467aca 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno,
-				  hose->ops, hose, &resources);
+	bus = pci_create_root_bus(hose->parent,
+			PCI_DOMBUS(hose->global_number, hose->first_busno),
+			hose->ops, hose, &resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index a2a7391..20e662f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
 	if (ret)
 		return ret;
 
-	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-				      zdev, &resources);
+	zdev->bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
+			zdev, &resources);
 	if (!zdev->bus) {
 		zpci_cleanup_bus_resources(zdev);
 		return -EIO;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index efc1051..116f80f 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
+	bus = pci_scan_root_bus(NULL,
+			PCI_DOMBUS(hose->index, next_busno),
+			hose->pci_ops, hose, &resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe..838fe1e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
-				  pbm, &resources);
+	bus = pci_create_root_bus(parent,
+			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
+			pbm->pci_ops, pbm, &resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9475a74..25b0d9b 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -306,8 +306,9 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+			bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, 0),
+				controller->ops, controller, &resources);
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b1df847..f6f41f3 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -881,8 +881,9 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+		bus = pci_scan_root_bus(NULL,
+				PCI_DOMBUS(controller->index, next_busno),
+				controller->ops, controller, &resources);
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 6ac2738..ad0e926 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		}
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
-				    (u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
-						  sd, &resources);
+				(u8)root->secondary.end, root->mcfg_addr))
+			bus = pci_create_root_bus(NULL,
+				PCI_DOMBUS(domain, busnum), &pci_root_ops,
+				sd, &resources);
 
 		if (bus) {
 			pci_scan_child_bus(bus);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0cbc723..0160280 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
 	sd->node = x86_pci_root_bus_node(busnum);
 	x86_pci_root_bus_resources(busnum, &resources);
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
+			&pci_root_ops, sd, &resources);
 	if (!bus) {
 		pci_free_resource_list(&resources);
 		kfree(sd);
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 9e7c28b..af6144a 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
 	pci_lock_rescan_remove();
 
-	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd, &resources);
+	b = pci_scan_root_bus(&pdev->xdev->dev,
+			PCI_DOMBUS(sd->domain, bus),
+			&pcifront_bus_ops, sd, &resources);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
-- 
1.7.1



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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_assign_domain_nr() to assign domain
number for pci_host_bridge. Later we will remove
pci_bus_assign_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |   20 +++++++++++++++-----
 include/linux/pci.h |    4 ++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 81f06e8..c49eec1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+static int pci_assign_domain_nr(struct device *dev)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = of_get_pci_domain_nr(dev->of_node);
 
 	/*
 	 * Check DT domain and use_dt_domains values.
@@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node->full_name);
+		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+			dev->of_node->full_name);
 		domain = -1;
 	}
 
-	bus->domain_nr = domain;
+	return domain;
+}
+
+void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+	host->domain = pci_assign_domain_nr(host->dev.parent);
+}
+
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+	bus->domain_nr = pci_assign_domain_nr(parent);
 }
 #endif
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8b3d245..2b1b998 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 	return bus->domain_nr;
 }
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
+void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
 					struct device *parent)
 {
 }
+static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+}
 #endif
 
 /* some architectures require additional setup to direct VGA traffic */
-- 
1.7.1


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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
  2015-03-09  2:33 ` Yijing Wang
                   ` (19 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_assign_domain_nr() to assign domain
number for pci_host_bridge. Later we will remove
pci_bus_assign_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |   20 +++++++++++++++-----
 include/linux/pci.h |    4 ++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 81f06e8..c49eec1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+static int pci_assign_domain_nr(struct device *dev)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = of_get_pci_domain_nr(dev->of_node);
 
 	/*
 	 * Check DT domain and use_dt_domains values.
@@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node->full_name);
+		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+			dev->of_node->full_name);
 		domain = -1;
 	}
 
-	bus->domain_nr = domain;
+	return domain;
+}
+
+void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+	host->domain = pci_assign_domain_nr(host->dev.parent);
+}
+
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+	bus->domain_nr = pci_assign_domain_nr(parent);
 }
 #endif
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8b3d245..2b1b998 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 	return bus->domain_nr;
 }
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
+void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
 					struct device *parent)
 {
 }
+static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+}
 #endif
 
 /* some architectures require additional setup to direct VGA traffic */
-- 
1.7.1

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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_assign_domain_nr() to assign domain
number for pci_host_bridge. Later we will remove
pci_bus_assign_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |   20 +++++++++++++++-----
 include/linux/pci.h |    4 ++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 81f06e8..c49eec1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+static int pci_assign_domain_nr(struct device *dev)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = of_get_pci_domain_nr(dev->of_node);
 
 	/*
 	 * Check DT domain and use_dt_domains values.
@@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node->full_name);
+		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+			dev->of_node->full_name);
 		domain = -1;
 	}
 
-	bus->domain_nr = domain;
+	return domain;
+}
+
+void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+	host->domain = pci_assign_domain_nr(host->dev.parent);
+}
+
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+	bus->domain_nr = pci_assign_domain_nr(parent);
 }
 #endif
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8b3d245..2b1b998 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 	return bus->domain_nr;
 }
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
+void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
 					struct device *parent)
 {
 }
+static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+}
 #endif
 
 /* some architectures require additional setup to direct VGA traffic */
-- 
1.7.1


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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Introduce pci_host_assign_domain_nr() to assign domain
number for pci_host_bridge. Later we will remove
pci_bus_assign_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |   20 +++++++++++++++-----
 include/linux/pci.h |    4 ++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 81f06e8..c49eec1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+static int pci_assign_domain_nr(struct device *dev)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = of_get_pci_domain_nr(dev->of_node);
 
 	/*
 	 * Check DT domain and use_dt_domains values.
@@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node->full_name);
+		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+			dev->of_node->full_name);
 		domain = -1;
 	}
 
-	bus->domain_nr = domain;
+	return domain;
+}
+
+void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+	host->domain = pci_assign_domain_nr(host->dev.parent);
+}
+
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+	bus->domain_nr = pci_assign_domain_nr(parent);
 }
 #endif
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8b3d245..2b1b998 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 	return bus->domain_nr;
 }
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
+void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
 					struct device *parent)
 {
 }
+static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+}
 #endif
 
 /* some architectures require additional setup to direct VGA traffic */
-- 
1.7.1

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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_assign_domain_nr() to assign domain
number for pci_host_bridge. Later we will remove
pci_bus_assign_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |   20 +++++++++++++++-----
 include/linux/pci.h |    4 ++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 81f06e8..c49eec1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+static int pci_assign_domain_nr(struct device *dev)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = of_get_pci_domain_nr(dev->of_node);
 
 	/*
 	 * Check DT domain and use_dt_domains values.
@@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node->full_name);
+		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+			dev->of_node->full_name);
 		domain = -1;
 	}
 
-	bus->domain_nr = domain;
+	return domain;
+}
+
+void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+	host->domain = pci_assign_domain_nr(host->dev.parent);
+}
+
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+	bus->domain_nr = pci_assign_domain_nr(parent);
 }
 #endif
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8b3d245..2b1b998 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 	return bus->domain_nr;
 }
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
+void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
 					struct device *parent)
 {
 }
+static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+}
 #endif
 
 /* some architectures require additional setup to direct VGA traffic */
-- 
1.7.1


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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_assign_domain_nr() to assign domain
number for pci_host_bridge. Later we will remove
pci_bus_assign_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |   20 +++++++++++++++-----
 include/linux/pci.h |    4 ++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 81f06e8..c49eec1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+static int pci_assign_domain_nr(struct device *dev)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = of_get_pci_domain_nr(dev->of_node);
 
 	/*
 	 * Check DT domain and use_dt_domains values.
@@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node->full_name);
+		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+			dev->of_node->full_name);
 		domain = -1;
 	}
 
-	bus->domain_nr = domain;
+	return domain;
+}
+
+void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+	host->domain = pci_assign_domain_nr(host->dev.parent);
+}
+
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+	bus->domain_nr = pci_assign_domain_nr(parent);
 }
 #endif
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8b3d245..2b1b998 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 	return bus->domain_nr;
 }
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
+void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
 					struct device *parent)
 {
 }
+static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
+{
+}
 #endif
 
 /* some architectures require additional setup to direct VGA traffic */
-- 
1.7.1

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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

This patch separate pci_host_bridge creation out
of pci_create_root_bus(), and try to make a generic
pci_host_bridge, then we could place generic PCI
infos like domain number in it. Also Ripping out
pci_host_bridge creation from pci_create_root_bus()
make code more better readability. Further more,
we could use the generic pci_host_bridge to hold
host bridge specific operations like
pcibios_root_bridge_prepare(). The changes are
transparent to platform host bridge drivers.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
 drivers/pci/pci.h         |    3 +
 drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
 include/linux/pci.h       |    1 +
 4 files changed, 109 insertions(+), 64 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 39b2dbe..3bd45e7 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,61 @@
 
 #include "pci.h"
 
+static void pci_release_host_bridge_dev(struct device *dev)
+{
+	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
+
+	if (bridge->release_fn)
+		bridge->release_fn(bridge);
+
+	pci_free_resource_list(&bridge->windows);
+	kfree(bridge);
+}
+
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 db, struct list_head *resources)
+{
+	int error;
+	int bus = PCI_BUSNUM(db);
+	int domain = PCI_DOMAIN(db);
+	struct pci_host_bridge *host;
+	struct resource_entry *window, *n;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->busnum = bus;
+	host->domain = domain;
+	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
+	 * pci_host_assign_domain_nr() to assign domain
+	 * number instead PCI_DOMAIN(db).
+	 */
+	pci_host_assign_domain_nr(host);
+
+	host->dev.parent = parent;
+	INIT_LIST_HEAD(&host->windows);
+	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
+			host->busnum);
+
+	error = device_register(&host->dev);
+	if (error) {
+		put_device(&host->dev);
+		return NULL;
+	}
+
+	resource_list_for_each_entry_safe(window, n, resources)
+		list_move_tail(&window->node, &host->windows);
+
+	return host;
+}
+
+void pci_free_host_bridge(struct pci_host_bridge *host)
+{
+	device_unregister(&host->dev);
+}
+
 static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
 	while (bus->parent)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index eeacab9..3de5e51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 dombus, struct list_head *resources);
+void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3d6befd..27ec612 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	return b;
 }
 
-static void pci_release_host_bridge_dev(struct device *dev)
-{
-	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
-
-	if (bridge->release_fn)
-		bridge->release_fn(bridge);
-
-	pci_free_resource_list(&bridge->windows);
-
-	kfree(bridge);
-}
-
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
-{
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
-	INIT_LIST_HEAD(&bridge->windows);
-	bridge->bus = b;
-	return bridge;
-}
-
 static const unsigned char pcix_bus_speed[] = {
 	PCI_SPEED_UNKNOWN,		/* 0 */
 	PCI_SPEED_66MHz_PCIX,		/* 1 */
@@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_create_root_bus(
+		struct pci_host_bridge *bridge, struct pci_ops *ops,
+		void *sysdata)
 {
 	int error;
-	struct pci_host_bridge *bridge;
 	struct pci_bus *b, *b2;
-	struct resource_entry *window, *n;
+	struct resource_entry *window;
+	struct device *parent;
 	struct resource *res;
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
-	u8	bus = PCI_BUSNUM(db);
 
+	parent = bridge->dev.parent;
 	b = pci_alloc_bus(NULL);
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
-	b->number = b->busn_res.start = bus;
+	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), bus);
+	b2 = pci_find_bus(pci_domain_nr(b), b->number);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		dev_dbg(&b2->dev, "bus already known\n");
 		goto err_out;
 	}
 
-	bridge = pci_alloc_host_bridge(b);
-	if (!bridge)
-		goto err_out;
-
-	bridge->domain = PCI_DOMAIN(db);
-	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_host_bridge_dev;
-	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+	bridge->bus = b;
+	b->bridge = get_device(&bridge->dev);
 	error = pcibios_root_bridge_prepare(bridge);
-	if (error) {
-		kfree(bridge);
+	if (error)
 		goto err_out;
-	}
 
-	error = device_register(&bridge->dev);
-	if (error) {
-		put_device(&bridge->dev);
-		goto err_out;
-	}
-	b->bridge = get_device(&bridge->dev);
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
 
@@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	b->dev.class = &pcibus_class;
 	b->dev.parent = b->bridge;
-	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
+	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
+			b->number);
 	error = device_register(&b->dev);
 	if (error)
-		goto class_dev_reg_err;
+		goto err_out;
 
 	pcibios_add_bus(b);
 
@@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
 
 	/* Add initial resources to the bus */
-	resource_list_for_each_entry_safe(window, n, resources) {
-		list_move_tail(&window->node, &bridge->windows);
+	resource_list_for_each_entry(window, &bridge->windows) {
 		res = window->res;
 		offset = window->offset;
 		if (res->flags & IORESOURCE_BUS)
-			pci_bus_insert_busn_res(b, bus, res->end);
+			pci_bus_insert_busn_res(b, b->number, res->end);
 		else
 			pci_bus_add_resource(b, res, 0);
 		if (offset) {
@@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	return b;
 
-class_dev_reg_err:
-	put_device(&bridge->dev);
-	device_unregister(&bridge->dev);
 err_out:
 	kfree(b);
 	return NULL;
 }
 
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_create_root_bus(host, ops, sysdata);
+}
+
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_scan_root_bus(
+		struct pci_host_bridge *host, struct pci_ops *ops,
+		void *sysdata)
 {
 	struct resource_entry *window;
 	bool found = false;
 	struct pci_bus *b;
 	int max;
 
-	resource_list_for_each_entry(window, resources)
+	resource_list_for_each_entry(window, &host->windows)
 		if (window->res->flags & IORESOURCE_BUS) {
 			found = true;
 			break;
 		}
 
-	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
-	if (!b)
+	b = __pci_create_root_bus(host, ops, sysdata);
+	if (!b) {
+		pci_free_host_bridge(host);
 		return NULL;
+	}
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			PCI_BUSNUM(db));
-		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
+			host->busnum);
+		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 
 	return b;
 }
+
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_scan_root_bus(host, ops, sysdata);
+}
 EXPORT_SYMBOL(pci_scan_root_bus);
 
 struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1b998..463eaa3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 
 struct pci_host_bridge {
 	u16	domain;
+	u16 busnum;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
-- 
1.7.1


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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                   ` (21 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

This patch separate pci_host_bridge creation out
of pci_create_root_bus(), and try to make a generic
pci_host_bridge, then we could place generic PCI
infos like domain number in it. Also Ripping out
pci_host_bridge creation from pci_create_root_bus()
make code more better readability. Further more,
we could use the generic pci_host_bridge to hold
host bridge specific operations like
pcibios_root_bridge_prepare(). The changes are
transparent to platform host bridge drivers.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
 drivers/pci/pci.h         |    3 +
 drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
 include/linux/pci.h       |    1 +
 4 files changed, 109 insertions(+), 64 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 39b2dbe..3bd45e7 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,61 @@
 
 #include "pci.h"
 
+static void pci_release_host_bridge_dev(struct device *dev)
+{
+	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
+
+	if (bridge->release_fn)
+		bridge->release_fn(bridge);
+
+	pci_free_resource_list(&bridge->windows);
+	kfree(bridge);
+}
+
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 db, struct list_head *resources)
+{
+	int error;
+	int bus = PCI_BUSNUM(db);
+	int domain = PCI_DOMAIN(db);
+	struct pci_host_bridge *host;
+	struct resource_entry *window, *n;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->busnum = bus;
+	host->domain = domain;
+	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
+	 * pci_host_assign_domain_nr() to assign domain
+	 * number instead PCI_DOMAIN(db).
+	 */
+	pci_host_assign_domain_nr(host);
+
+	host->dev.parent = parent;
+	INIT_LIST_HEAD(&host->windows);
+	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
+			host->busnum);
+
+	error = device_register(&host->dev);
+	if (error) {
+		put_device(&host->dev);
+		return NULL;
+	}
+
+	resource_list_for_each_entry_safe(window, n, resources)
+		list_move_tail(&window->node, &host->windows);
+
+	return host;
+}
+
+void pci_free_host_bridge(struct pci_host_bridge *host)
+{
+	device_unregister(&host->dev);
+}
+
 static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
 	while (bus->parent)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index eeacab9..3de5e51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 dombus, struct list_head *resources);
+void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3d6befd..27ec612 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	return b;
 }
 
-static void pci_release_host_bridge_dev(struct device *dev)
-{
-	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
-
-	if (bridge->release_fn)
-		bridge->release_fn(bridge);
-
-	pci_free_resource_list(&bridge->windows);
-
-	kfree(bridge);
-}
-
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
-{
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
-	INIT_LIST_HEAD(&bridge->windows);
-	bridge->bus = b;
-	return bridge;
-}
-
 static const unsigned char pcix_bus_speed[] = {
 	PCI_SPEED_UNKNOWN,		/* 0 */
 	PCI_SPEED_66MHz_PCIX,		/* 1 */
@@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_create_root_bus(
+		struct pci_host_bridge *bridge, struct pci_ops *ops,
+		void *sysdata)
 {
 	int error;
-	struct pci_host_bridge *bridge;
 	struct pci_bus *b, *b2;
-	struct resource_entry *window, *n;
+	struct resource_entry *window;
+	struct device *parent;
 	struct resource *res;
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
-	u8	bus = PCI_BUSNUM(db);
 
+	parent = bridge->dev.parent;
 	b = pci_alloc_bus(NULL);
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
-	b->number = b->busn_res.start = bus;
+	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), bus);
+	b2 = pci_find_bus(pci_domain_nr(b), b->number);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		dev_dbg(&b2->dev, "bus already known\n");
 		goto err_out;
 	}
 
-	bridge = pci_alloc_host_bridge(b);
-	if (!bridge)
-		goto err_out;
-
-	bridge->domain = PCI_DOMAIN(db);
-	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_host_bridge_dev;
-	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+	bridge->bus = b;
+	b->bridge = get_device(&bridge->dev);
 	error = pcibios_root_bridge_prepare(bridge);
-	if (error) {
-		kfree(bridge);
+	if (error)
 		goto err_out;
-	}
 
-	error = device_register(&bridge->dev);
-	if (error) {
-		put_device(&bridge->dev);
-		goto err_out;
-	}
-	b->bridge = get_device(&bridge->dev);
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
 
@@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	b->dev.class = &pcibus_class;
 	b->dev.parent = b->bridge;
-	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
+	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
+			b->number);
 	error = device_register(&b->dev);
 	if (error)
-		goto class_dev_reg_err;
+		goto err_out;
 
 	pcibios_add_bus(b);
 
@@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
 
 	/* Add initial resources to the bus */
-	resource_list_for_each_entry_safe(window, n, resources) {
-		list_move_tail(&window->node, &bridge->windows);
+	resource_list_for_each_entry(window, &bridge->windows) {
 		res = window->res;
 		offset = window->offset;
 		if (res->flags & IORESOURCE_BUS)
-			pci_bus_insert_busn_res(b, bus, res->end);
+			pci_bus_insert_busn_res(b, b->number, res->end);
 		else
 			pci_bus_add_resource(b, res, 0);
 		if (offset) {
@@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	return b;
 
-class_dev_reg_err:
-	put_device(&bridge->dev);
-	device_unregister(&bridge->dev);
 err_out:
 	kfree(b);
 	return NULL;
 }
 
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_create_root_bus(host, ops, sysdata);
+}
+
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_scan_root_bus(
+		struct pci_host_bridge *host, struct pci_ops *ops,
+		void *sysdata)
 {
 	struct resource_entry *window;
 	bool found = false;
 	struct pci_bus *b;
 	int max;
 
-	resource_list_for_each_entry(window, resources)
+	resource_list_for_each_entry(window, &host->windows)
 		if (window->res->flags & IORESOURCE_BUS) {
 			found = true;
 			break;
 		}
 
-	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
-	if (!b)
+	b = __pci_create_root_bus(host, ops, sysdata);
+	if (!b) {
+		pci_free_host_bridge(host);
 		return NULL;
+	}
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			PCI_BUSNUM(db));
-		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
+			host->busnum);
+		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 
 	return b;
 }
+
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_scan_root_bus(host, ops, sysdata);
+}
 EXPORT_SYMBOL(pci_scan_root_bus);
 
 struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1b998..463eaa3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 
 struct pci_host_bridge {
 	u16	domain;
+	u16 busnum;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
-- 
1.7.1

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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

This patch separate pci_host_bridge creation out
of pci_create_root_bus(), and try to make a generic
pci_host_bridge, then we could place generic PCI
infos like domain number in it. Also Ripping out
pci_host_bridge creation from pci_create_root_bus()
make code more better readability. Further more,
we could use the generic pci_host_bridge to hold
host bridge specific operations like
pcibios_root_bridge_prepare(). The changes are
transparent to platform host bridge drivers.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
 drivers/pci/pci.h         |    3 +
 drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
 include/linux/pci.h       |    1 +
 4 files changed, 109 insertions(+), 64 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 39b2dbe..3bd45e7 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,61 @@
 
 #include "pci.h"
 
+static void pci_release_host_bridge_dev(struct device *dev)
+{
+	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
+
+	if (bridge->release_fn)
+		bridge->release_fn(bridge);
+
+	pci_free_resource_list(&bridge->windows);
+	kfree(bridge);
+}
+
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 db, struct list_head *resources)
+{
+	int error;
+	int bus = PCI_BUSNUM(db);
+	int domain = PCI_DOMAIN(db);
+	struct pci_host_bridge *host;
+	struct resource_entry *window, *n;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->busnum = bus;
+	host->domain = domain;
+	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
+	 * pci_host_assign_domain_nr() to assign domain
+	 * number instead PCI_DOMAIN(db).
+	 */
+	pci_host_assign_domain_nr(host);
+
+	host->dev.parent = parent;
+	INIT_LIST_HEAD(&host->windows);
+	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
+			host->busnum);
+
+	error = device_register(&host->dev);
+	if (error) {
+		put_device(&host->dev);
+		return NULL;
+	}
+
+	resource_list_for_each_entry_safe(window, n, resources)
+		list_move_tail(&window->node, &host->windows);
+
+	return host;
+}
+
+void pci_free_host_bridge(struct pci_host_bridge *host)
+{
+	device_unregister(&host->dev);
+}
+
 static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
 	while (bus->parent)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index eeacab9..3de5e51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 dombus, struct list_head *resources);
+void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3d6befd..27ec612 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	return b;
 }
 
-static void pci_release_host_bridge_dev(struct device *dev)
-{
-	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
-
-	if (bridge->release_fn)
-		bridge->release_fn(bridge);
-
-	pci_free_resource_list(&bridge->windows);
-
-	kfree(bridge);
-}
-
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
-{
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
-	INIT_LIST_HEAD(&bridge->windows);
-	bridge->bus = b;
-	return bridge;
-}
-
 static const unsigned char pcix_bus_speed[] = {
 	PCI_SPEED_UNKNOWN,		/* 0 */
 	PCI_SPEED_66MHz_PCIX,		/* 1 */
@@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_create_root_bus(
+		struct pci_host_bridge *bridge, struct pci_ops *ops,
+		void *sysdata)
 {
 	int error;
-	struct pci_host_bridge *bridge;
 	struct pci_bus *b, *b2;
-	struct resource_entry *window, *n;
+	struct resource_entry *window;
+	struct device *parent;
 	struct resource *res;
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
-	u8	bus = PCI_BUSNUM(db);
 
+	parent = bridge->dev.parent;
 	b = pci_alloc_bus(NULL);
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
-	b->number = b->busn_res.start = bus;
+	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), bus);
+	b2 = pci_find_bus(pci_domain_nr(b), b->number);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		dev_dbg(&b2->dev, "bus already known\n");
 		goto err_out;
 	}
 
-	bridge = pci_alloc_host_bridge(b);
-	if (!bridge)
-		goto err_out;
-
-	bridge->domain = PCI_DOMAIN(db);
-	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_host_bridge_dev;
-	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+	bridge->bus = b;
+	b->bridge = get_device(&bridge->dev);
 	error = pcibios_root_bridge_prepare(bridge);
-	if (error) {
-		kfree(bridge);
+	if (error)
 		goto err_out;
-	}
 
-	error = device_register(&bridge->dev);
-	if (error) {
-		put_device(&bridge->dev);
-		goto err_out;
-	}
-	b->bridge = get_device(&bridge->dev);
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
 
@@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	b->dev.class = &pcibus_class;
 	b->dev.parent = b->bridge;
-	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
+	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
+			b->number);
 	error = device_register(&b->dev);
 	if (error)
-		goto class_dev_reg_err;
+		goto err_out;
 
 	pcibios_add_bus(b);
 
@@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
 
 	/* Add initial resources to the bus */
-	resource_list_for_each_entry_safe(window, n, resources) {
-		list_move_tail(&window->node, &bridge->windows);
+	resource_list_for_each_entry(window, &bridge->windows) {
 		res = window->res;
 		offset = window->offset;
 		if (res->flags & IORESOURCE_BUS)
-			pci_bus_insert_busn_res(b, bus, res->end);
+			pci_bus_insert_busn_res(b, b->number, res->end);
 		else
 			pci_bus_add_resource(b, res, 0);
 		if (offset) {
@@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	return b;
 
-class_dev_reg_err:
-	put_device(&bridge->dev);
-	device_unregister(&bridge->dev);
 err_out:
 	kfree(b);
 	return NULL;
 }
 
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_create_root_bus(host, ops, sysdata);
+}
+
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_scan_root_bus(
+		struct pci_host_bridge *host, struct pci_ops *ops,
+		void *sysdata)
 {
 	struct resource_entry *window;
 	bool found = false;
 	struct pci_bus *b;
 	int max;
 
-	resource_list_for_each_entry(window, resources)
+	resource_list_for_each_entry(window, &host->windows)
 		if (window->res->flags & IORESOURCE_BUS) {
 			found = true;
 			break;
 		}
 
-	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
-	if (!b)
+	b = __pci_create_root_bus(host, ops, sysdata);
+	if (!b) {
+		pci_free_host_bridge(host);
 		return NULL;
+	}
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			PCI_BUSNUM(db));
-		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
+			host->busnum);
+		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 
 	return b;
 }
+
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_scan_root_bus(host, ops, sysdata);
+}
 EXPORT_SYMBOL(pci_scan_root_bus);
 
 struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1b998..463eaa3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 
 struct pci_host_bridge {
 	u16	domain;
+	u16 busnum;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
-- 
1.7.1


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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

This patch separate pci_host_bridge creation out
of pci_create_root_bus(), and try to make a generic
pci_host_bridge, then we could place generic PCI
infos like domain number in it. Also Ripping out
pci_host_bridge creation from pci_create_root_bus()
make code more better readability. Further more,
we could use the generic pci_host_bridge to hold
host bridge specific operations like
pcibios_root_bridge_prepare(). The changes are
transparent to platform host bridge drivers.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
 drivers/pci/pci.h         |    3 +
 drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
 include/linux/pci.h       |    1 +
 4 files changed, 109 insertions(+), 64 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 39b2dbe..3bd45e7 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,61 @@
 
 #include "pci.h"
 
+static void pci_release_host_bridge_dev(struct device *dev)
+{
+	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
+
+	if (bridge->release_fn)
+		bridge->release_fn(bridge);
+
+	pci_free_resource_list(&bridge->windows);
+	kfree(bridge);
+}
+
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 db, struct list_head *resources)
+{
+	int error;
+	int bus = PCI_BUSNUM(db);
+	int domain = PCI_DOMAIN(db);
+	struct pci_host_bridge *host;
+	struct resource_entry *window, *n;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->busnum = bus;
+	host->domain = domain;
+	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
+	 * pci_host_assign_domain_nr() to assign domain
+	 * number instead PCI_DOMAIN(db).
+	 */
+	pci_host_assign_domain_nr(host);
+
+	host->dev.parent = parent;
+	INIT_LIST_HEAD(&host->windows);
+	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
+			host->busnum);
+
+	error = device_register(&host->dev);
+	if (error) {
+		put_device(&host->dev);
+		return NULL;
+	}
+
+	resource_list_for_each_entry_safe(window, n, resources)
+		list_move_tail(&window->node, &host->windows);
+
+	return host;
+}
+
+void pci_free_host_bridge(struct pci_host_bridge *host)
+{
+	device_unregister(&host->dev);
+}
+
 static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
 	while (bus->parent)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index eeacab9..3de5e51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 dombus, struct list_head *resources);
+void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3d6befd..27ec612 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	return b;
 }
 
-static void pci_release_host_bridge_dev(struct device *dev)
-{
-	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
-
-	if (bridge->release_fn)
-		bridge->release_fn(bridge);
-
-	pci_free_resource_list(&bridge->windows);
-
-	kfree(bridge);
-}
-
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
-{
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
-	INIT_LIST_HEAD(&bridge->windows);
-	bridge->bus = b;
-	return bridge;
-}
-
 static const unsigned char pcix_bus_speed[] = {
 	PCI_SPEED_UNKNOWN,		/* 0 */
 	PCI_SPEED_66MHz_PCIX,		/* 1 */
@@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_create_root_bus(
+		struct pci_host_bridge *bridge, struct pci_ops *ops,
+		void *sysdata)
 {
 	int error;
-	struct pci_host_bridge *bridge;
 	struct pci_bus *b, *b2;
-	struct resource_entry *window, *n;
+	struct resource_entry *window;
+	struct device *parent;
 	struct resource *res;
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
-	u8	bus = PCI_BUSNUM(db);
 
+	parent = bridge->dev.parent;
 	b = pci_alloc_bus(NULL);
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
-	b->number = b->busn_res.start = bus;
+	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), bus);
+	b2 = pci_find_bus(pci_domain_nr(b), b->number);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		dev_dbg(&b2->dev, "bus already known\n");
 		goto err_out;
 	}
 
-	bridge = pci_alloc_host_bridge(b);
-	if (!bridge)
-		goto err_out;
-
-	bridge->domain = PCI_DOMAIN(db);
-	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_host_bridge_dev;
-	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+	bridge->bus = b;
+	b->bridge = get_device(&bridge->dev);
 	error = pcibios_root_bridge_prepare(bridge);
-	if (error) {
-		kfree(bridge);
+	if (error)
 		goto err_out;
-	}
 
-	error = device_register(&bridge->dev);
-	if (error) {
-		put_device(&bridge->dev);
-		goto err_out;
-	}
-	b->bridge = get_device(&bridge->dev);
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
 
@@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	b->dev.class = &pcibus_class;
 	b->dev.parent = b->bridge;
-	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
+	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
+			b->number);
 	error = device_register(&b->dev);
 	if (error)
-		goto class_dev_reg_err;
+		goto err_out;
 
 	pcibios_add_bus(b);
 
@@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
 
 	/* Add initial resources to the bus */
-	resource_list_for_each_entry_safe(window, n, resources) {
-		list_move_tail(&window->node, &bridge->windows);
+	resource_list_for_each_entry(window, &bridge->windows) {
 		res = window->res;
 		offset = window->offset;
 		if (res->flags & IORESOURCE_BUS)
-			pci_bus_insert_busn_res(b, bus, res->end);
+			pci_bus_insert_busn_res(b, b->number, res->end);
 		else
 			pci_bus_add_resource(b, res, 0);
 		if (offset) {
@@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	return b;
 
-class_dev_reg_err:
-	put_device(&bridge->dev);
-	device_unregister(&bridge->dev);
 err_out:
 	kfree(b);
 	return NULL;
 }
 
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_create_root_bus(host, ops, sysdata);
+}
+
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_scan_root_bus(
+		struct pci_host_bridge *host, struct pci_ops *ops,
+		void *sysdata)
 {
 	struct resource_entry *window;
 	bool found = false;
 	struct pci_bus *b;
 	int max;
 
-	resource_list_for_each_entry(window, resources)
+	resource_list_for_each_entry(window, &host->windows)
 		if (window->res->flags & IORESOURCE_BUS) {
 			found = true;
 			break;
 		}
 
-	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
-	if (!b)
+	b = __pci_create_root_bus(host, ops, sysdata);
+	if (!b) {
+		pci_free_host_bridge(host);
 		return NULL;
+	}
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			PCI_BUSNUM(db));
-		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
+			host->busnum);
+		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 
 	return b;
 }
+
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_scan_root_bus(host, ops, sysdata);
+}
 EXPORT_SYMBOL(pci_scan_root_bus);
 
 struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1b998..463eaa3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 
 struct pci_host_bridge {
 	u16	domain;
+	u16 busnum;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
-- 
1.7.1

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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

This patch separate pci_host_bridge creation out
of pci_create_root_bus(), and try to make a generic
pci_host_bridge, then we could place generic PCI
infos like domain number in it. Also Ripping out
pci_host_bridge creation from pci_create_root_bus()
make code more better readability. Further more,
we could use the generic pci_host_bridge to hold
host bridge specific operations like
pcibios_root_bridge_prepare(). The changes are
transparent to platform host bridge drivers.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
 drivers/pci/pci.h         |    3 +
 drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
 include/linux/pci.h       |    1 +
 4 files changed, 109 insertions(+), 64 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 39b2dbe..3bd45e7 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,61 @@
 
 #include "pci.h"
 
+static void pci_release_host_bridge_dev(struct device *dev)
+{
+	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
+
+	if (bridge->release_fn)
+		bridge->release_fn(bridge);
+
+	pci_free_resource_list(&bridge->windows);
+	kfree(bridge);
+}
+
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 db, struct list_head *resources)
+{
+	int error;
+	int bus = PCI_BUSNUM(db);
+	int domain = PCI_DOMAIN(db);
+	struct pci_host_bridge *host;
+	struct resource_entry *window, *n;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->busnum = bus;
+	host->domain = domain;
+	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
+	 * pci_host_assign_domain_nr() to assign domain
+	 * number instead PCI_DOMAIN(db).
+	 */
+	pci_host_assign_domain_nr(host);
+
+	host->dev.parent = parent;
+	INIT_LIST_HEAD(&host->windows);
+	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
+			host->busnum);
+
+	error = device_register(&host->dev);
+	if (error) {
+		put_device(&host->dev);
+		return NULL;
+	}
+
+	resource_list_for_each_entry_safe(window, n, resources)
+		list_move_tail(&window->node, &host->windows);
+
+	return host;
+}
+
+void pci_free_host_bridge(struct pci_host_bridge *host)
+{
+	device_unregister(&host->dev);
+}
+
 static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
 	while (bus->parent)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index eeacab9..3de5e51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 dombus, struct list_head *resources);
+void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3d6befd..27ec612 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	return b;
 }
 
-static void pci_release_host_bridge_dev(struct device *dev)
-{
-	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
-
-	if (bridge->release_fn)
-		bridge->release_fn(bridge);
-
-	pci_free_resource_list(&bridge->windows);
-
-	kfree(bridge);
-}
-
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
-{
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
-	INIT_LIST_HEAD(&bridge->windows);
-	bridge->bus = b;
-	return bridge;
-}
-
 static const unsigned char pcix_bus_speed[] = {
 	PCI_SPEED_UNKNOWN,		/* 0 */
 	PCI_SPEED_66MHz_PCIX,		/* 1 */
@@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_create_root_bus(
+		struct pci_host_bridge *bridge, struct pci_ops *ops,
+		void *sysdata)
 {
 	int error;
-	struct pci_host_bridge *bridge;
 	struct pci_bus *b, *b2;
-	struct resource_entry *window, *n;
+	struct resource_entry *window;
+	struct device *parent;
 	struct resource *res;
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
-	u8	bus = PCI_BUSNUM(db);
 
+	parent = bridge->dev.parent;
 	b = pci_alloc_bus(NULL);
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
-	b->number = b->busn_res.start = bus;
+	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), bus);
+	b2 = pci_find_bus(pci_domain_nr(b), b->number);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		dev_dbg(&b2->dev, "bus already known\n");
 		goto err_out;
 	}
 
-	bridge = pci_alloc_host_bridge(b);
-	if (!bridge)
-		goto err_out;
-
-	bridge->domain = PCI_DOMAIN(db);
-	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_host_bridge_dev;
-	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+	bridge->bus = b;
+	b->bridge = get_device(&bridge->dev);
 	error = pcibios_root_bridge_prepare(bridge);
-	if (error) {
-		kfree(bridge);
+	if (error)
 		goto err_out;
-	}
 
-	error = device_register(&bridge->dev);
-	if (error) {
-		put_device(&bridge->dev);
-		goto err_out;
-	}
-	b->bridge = get_device(&bridge->dev);
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
 
@@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	b->dev.class = &pcibus_class;
 	b->dev.parent = b->bridge;
-	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
+	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
+			b->number);
 	error = device_register(&b->dev);
 	if (error)
-		goto class_dev_reg_err;
+		goto err_out;
 
 	pcibios_add_bus(b);
 
@@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
 
 	/* Add initial resources to the bus */
-	resource_list_for_each_entry_safe(window, n, resources) {
-		list_move_tail(&window->node, &bridge->windows);
+	resource_list_for_each_entry(window, &bridge->windows) {
 		res = window->res;
 		offset = window->offset;
 		if (res->flags & IORESOURCE_BUS)
-			pci_bus_insert_busn_res(b, bus, res->end);
+			pci_bus_insert_busn_res(b, b->number, res->end);
 		else
 			pci_bus_add_resource(b, res, 0);
 		if (offset) {
@@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	return b;
 
-class_dev_reg_err:
-	put_device(&bridge->dev);
-	device_unregister(&bridge->dev);
 err_out:
 	kfree(b);
 	return NULL;
 }
 
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_create_root_bus(host, ops, sysdata);
+}
+
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_scan_root_bus(
+		struct pci_host_bridge *host, struct pci_ops *ops,
+		void *sysdata)
 {
 	struct resource_entry *window;
 	bool found = false;
 	struct pci_bus *b;
 	int max;
 
-	resource_list_for_each_entry(window, resources)
+	resource_list_for_each_entry(window, &host->windows)
 		if (window->res->flags & IORESOURCE_BUS) {
 			found = true;
 			break;
 		}
 
-	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
-	if (!b)
+	b = __pci_create_root_bus(host, ops, sysdata);
+	if (!b) {
+		pci_free_host_bridge(host);
 		return NULL;
+	}
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			PCI_BUSNUM(db));
-		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
+			host->busnum);
+		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 
 	return b;
 }
+
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_scan_root_bus(host, ops, sysdata);
+}
 EXPORT_SYMBOL(pci_scan_root_bus);
 
 struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1b998..463eaa3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 
 struct pci_host_bridge {
 	u16	domain;
+	u16 busnum;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
-- 
1.7.1


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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

This patch separate pci_host_bridge creation out
of pci_create_root_bus(), and try to make a generic
pci_host_bridge, then we could place generic PCI
infos like domain number in it. Also Ripping out
pci_host_bridge creation from pci_create_root_bus()
make code more better readability. Further more,
we could use the generic pci_host_bridge to hold
host bridge specific operations like
pcibios_root_bridge_prepare(). The changes are
transparent to platform host bridge drivers.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
 drivers/pci/pci.h         |    3 +
 drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
 include/linux/pci.h       |    1 +
 4 files changed, 109 insertions(+), 64 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 39b2dbe..3bd45e7 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,61 @@
 
 #include "pci.h"
 
+static void pci_release_host_bridge_dev(struct device *dev)
+{
+	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
+
+	if (bridge->release_fn)
+		bridge->release_fn(bridge);
+
+	pci_free_resource_list(&bridge->windows);
+	kfree(bridge);
+}
+
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 db, struct list_head *resources)
+{
+	int error;
+	int bus = PCI_BUSNUM(db);
+	int domain = PCI_DOMAIN(db);
+	struct pci_host_bridge *host;
+	struct resource_entry *window, *n;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->busnum = bus;
+	host->domain = domain;
+	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
+	 * pci_host_assign_domain_nr() to assign domain
+	 * number instead PCI_DOMAIN(db).
+	 */
+	pci_host_assign_domain_nr(host);
+
+	host->dev.parent = parent;
+	INIT_LIST_HEAD(&host->windows);
+	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
+			host->busnum);
+
+	error = device_register(&host->dev);
+	if (error) {
+		put_device(&host->dev);
+		return NULL;
+	}
+
+	resource_list_for_each_entry_safe(window, n, resources)
+		list_move_tail(&window->node, &host->windows);
+
+	return host;
+}
+
+void pci_free_host_bridge(struct pci_host_bridge *host)
+{
+	device_unregister(&host->dev);
+}
+
 static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
 	while (bus->parent)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index eeacab9..3de5e51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 }
 #endif
 
+struct pci_host_bridge *pci_create_host_bridge(
+		struct device *parent, u32 dombus, struct list_head *resources);
+void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3d6befd..27ec612 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	return b;
 }
 
-static void pci_release_host_bridge_dev(struct device *dev)
-{
-	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
-
-	if (bridge->release_fn)
-		bridge->release_fn(bridge);
-
-	pci_free_resource_list(&bridge->windows);
-
-	kfree(bridge);
-}
-
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
-{
-	struct pci_host_bridge *bridge;
-
-	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-	if (!bridge)
-		return NULL;
-
-	INIT_LIST_HEAD(&bridge->windows);
-	bridge->bus = b;
-	return bridge;
-}
-
 static const unsigned char pcix_bus_speed[] = {
 	PCI_SPEED_UNKNOWN,		/* 0 */
 	PCI_SPEED_66MHz_PCIX,		/* 1 */
@@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_create_root_bus(
+		struct pci_host_bridge *bridge, struct pci_ops *ops,
+		void *sysdata)
 {
 	int error;
-	struct pci_host_bridge *bridge;
 	struct pci_bus *b, *b2;
-	struct resource_entry *window, *n;
+	struct resource_entry *window;
+	struct device *parent;
 	struct resource *res;
 	resource_size_t offset;
 	char bus_addr[64];
 	char *fmt;
-	u8	bus = PCI_BUSNUM(db);
 
+	parent = bridge->dev.parent;
 	b = pci_alloc_bus(NULL);
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
-	b->number = b->busn_res.start = bus;
+	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), bus);
+	b2 = pci_find_bus(pci_domain_nr(b), b->number);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		dev_dbg(&b2->dev, "bus already known\n");
 		goto err_out;
 	}
 
-	bridge = pci_alloc_host_bridge(b);
-	if (!bridge)
-		goto err_out;
-
-	bridge->domain = PCI_DOMAIN(db);
-	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_host_bridge_dev;
-	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+	bridge->bus = b;
+	b->bridge = get_device(&bridge->dev);
 	error = pcibios_root_bridge_prepare(bridge);
-	if (error) {
-		kfree(bridge);
+	if (error)
 		goto err_out;
-	}
 
-	error = device_register(&bridge->dev);
-	if (error) {
-		put_device(&bridge->dev);
-		goto err_out;
-	}
-	b->bridge = get_device(&bridge->dev);
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
 
@@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	b->dev.class = &pcibus_class;
 	b->dev.parent = b->bridge;
-	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
+	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
+			b->number);
 	error = device_register(&b->dev);
 	if (error)
-		goto class_dev_reg_err;
+		goto err_out;
 
 	pcibios_add_bus(b);
 
@@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
 
 	/* Add initial resources to the bus */
-	resource_list_for_each_entry_safe(window, n, resources) {
-		list_move_tail(&window->node, &bridge->windows);
+	resource_list_for_each_entry(window, &bridge->windows) {
 		res = window->res;
 		offset = window->offset;
 		if (res->flags & IORESOURCE_BUS)
-			pci_bus_insert_busn_res(b, bus, res->end);
+			pci_bus_insert_busn_res(b, b->number, res->end);
 		else
 			pci_bus_add_resource(b, res, 0);
 		if (offset) {
@@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 
 	return b;
 
-class_dev_reg_err:
-	put_device(&bridge->dev);
-	device_unregister(&bridge->dev);
 err_out:
 	kfree(b);
 	return NULL;
 }
 
+struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_create_root_bus(host, ops, sysdata);
+}
+
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 			res, ret ? "can not be" : "is");
 }
 
-struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+static struct pci_bus *__pci_scan_root_bus(
+		struct pci_host_bridge *host, struct pci_ops *ops,
+		void *sysdata)
 {
 	struct resource_entry *window;
 	bool found = false;
 	struct pci_bus *b;
 	int max;
 
-	resource_list_for_each_entry(window, resources)
+	resource_list_for_each_entry(window, &host->windows)
 		if (window->res->flags & IORESOURCE_BUS) {
 			found = true;
 			break;
 		}
 
-	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
-	if (!b)
+	b = __pci_create_root_bus(host, ops, sysdata);
+	if (!b) {
+		pci_free_host_bridge(host);
 		return NULL;
+	}
 
 	if (!found) {
 		dev_info(&b->dev,
 		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
-			PCI_BUSNUM(db));
-		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
+			host->busnum);
+		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
 	max = pci_scan_child_bus(b);
@@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 
 	return b;
 }
+
+struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_host_bridge *host;
+
+	host = pci_create_host_bridge(parent, db, resources);
+	if (!host)
+		return NULL;
+
+	return __pci_scan_root_bus(host, ops, sysdata);
+}
 EXPORT_SYMBOL(pci_scan_root_bus);
 
 struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1b998..463eaa3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 
 struct pci_host_bridge {
 	u16	domain;
+	u16 busnum;
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
-- 
1.7.1


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_bridge_list to manage pci host
bridges in system, so we could detect whether
the host in domain:bus is alreay registered.
Then we could remove bus alreay exist test in
__pci_create_root_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
 drivers/pci/probe.c       |    8 +-------
 include/linux/pci.h       |    1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3bd45e7..0bb08ef 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,9 @@
 
 #include "pci.h"
 
+static LIST_HEAD(pci_host_bridge_list);
+static DEFINE_MUTEX(phb_mutex);
+
 static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	int error;
 	int bus = PCI_BUSNUM(db);
 	int domain = PCI_DOMAIN(db);
-	struct pci_host_bridge *host;
+	struct pci_host_bridge *host, *temp;
 	struct resource_entry *window, *n;
 
 	host = kzalloc(sizeof(*host), GFP_KERNEL);
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	 */
 	pci_host_assign_domain_nr(host);
 
+	mutex_lock(&phb_mutex);
+	list_for_each_entry(temp, &pci_host_bridge_list, list)
+		if (temp->domain == host->domain
+				&& temp->busnum == host->busnum) {
+			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
+					host->domain, host->busnum);
+			mutex_unlock(&phb_mutex);
+			kfree(host);
+			return NULL;
+		}
+	mutex_unlock(&phb_mutex);
+
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	resource_list_for_each_entry_safe(window, n, resources)
 		list_move_tail(&window->node, &host->windows);
 
+	mutex_lock(&phb_mutex);
+	list_add_tail(&host->list, &pci_host_bridge_list);
+	mutex_unlock(&phb_mutex);
 	return host;
 }
 
 void pci_free_host_bridge(struct pci_host_bridge *host)
 {
+	mutex_lock(&phb_mutex);
+	list_del(&host->list);
+	mutex_unlock(&phb_mutex);
+
 	device_unregister(&host->dev);
 }
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27ec612..7238fa3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
 		void *sysdata)
 {
 	int error;
-	struct pci_bus *b, *b2;
+	struct pci_bus *b;
 	struct resource_entry *window;
 	struct device *parent;
 	struct resource *res;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), b->number);
-	if (b2) {
-		/* If we already got to this bus through a different bridge, ignore it */
-		dev_dbg(&b2->dev, "bus already known\n");
-		goto err_out;
-	}
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463eaa3..b621f5b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,6 +406,7 @@ struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
+	struct list_head list;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-09  2:33 ` Yijing Wang
                   ` (23 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_bridge_list to manage pci host
bridges in system, so we could detect whether
the host in domain:bus is alreay registered.
Then we could remove bus alreay exist test in
__pci_create_root_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
 drivers/pci/probe.c       |    8 +-------
 include/linux/pci.h       |    1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3bd45e7..0bb08ef 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,9 @@
 
 #include "pci.h"
 
+static LIST_HEAD(pci_host_bridge_list);
+static DEFINE_MUTEX(phb_mutex);
+
 static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	int error;
 	int bus = PCI_BUSNUM(db);
 	int domain = PCI_DOMAIN(db);
-	struct pci_host_bridge *host;
+	struct pci_host_bridge *host, *temp;
 	struct resource_entry *window, *n;
 
 	host = kzalloc(sizeof(*host), GFP_KERNEL);
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	 */
 	pci_host_assign_domain_nr(host);
 
+	mutex_lock(&phb_mutex);
+	list_for_each_entry(temp, &pci_host_bridge_list, list)
+		if (temp->domain == host->domain
+				&& temp->busnum == host->busnum) {
+			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
+					host->domain, host->busnum);
+			mutex_unlock(&phb_mutex);
+			kfree(host);
+			return NULL;
+		}
+	mutex_unlock(&phb_mutex);
+
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	resource_list_for_each_entry_safe(window, n, resources)
 		list_move_tail(&window->node, &host->windows);
 
+	mutex_lock(&phb_mutex);
+	list_add_tail(&host->list, &pci_host_bridge_list);
+	mutex_unlock(&phb_mutex);
 	return host;
 }
 
 void pci_free_host_bridge(struct pci_host_bridge *host)
 {
+	mutex_lock(&phb_mutex);
+	list_del(&host->list);
+	mutex_unlock(&phb_mutex);
+
 	device_unregister(&host->dev);
 }
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27ec612..7238fa3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
 		void *sysdata)
 {
 	int error;
-	struct pci_bus *b, *b2;
+	struct pci_bus *b;
 	struct resource_entry *window;
 	struct device *parent;
 	struct resource *res;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), b->number);
-	if (b2) {
-		/* If we already got to this bus through a different bridge, ignore it */
-		dev_dbg(&b2->dev, "bus already known\n");
-		goto err_out;
-	}
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463eaa3..b621f5b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,6 +406,7 @@ struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
+	struct list_head list;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1

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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_bridge_list to manage pci host
bridges in system, so we could detect whether
the host in domain:bus is alreay registered.
Then we could remove bus alreay exist test in
__pci_create_root_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
 drivers/pci/probe.c       |    8 +-------
 include/linux/pci.h       |    1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3bd45e7..0bb08ef 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,9 @@
 
 #include "pci.h"
 
+static LIST_HEAD(pci_host_bridge_list);
+static DEFINE_MUTEX(phb_mutex);
+
 static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	int error;
 	int bus = PCI_BUSNUM(db);
 	int domain = PCI_DOMAIN(db);
-	struct pci_host_bridge *host;
+	struct pci_host_bridge *host, *temp;
 	struct resource_entry *window, *n;
 
 	host = kzalloc(sizeof(*host), GFP_KERNEL);
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	 */
 	pci_host_assign_domain_nr(host);
 
+	mutex_lock(&phb_mutex);
+	list_for_each_entry(temp, &pci_host_bridge_list, list)
+		if (temp->domain == host->domain
+				&& temp->busnum == host->busnum) {
+			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
+					host->domain, host->busnum);
+			mutex_unlock(&phb_mutex);
+			kfree(host);
+			return NULL;
+		}
+	mutex_unlock(&phb_mutex);
+
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	resource_list_for_each_entry_safe(window, n, resources)
 		list_move_tail(&window->node, &host->windows);
 
+	mutex_lock(&phb_mutex);
+	list_add_tail(&host->list, &pci_host_bridge_list);
+	mutex_unlock(&phb_mutex);
 	return host;
 }
 
 void pci_free_host_bridge(struct pci_host_bridge *host)
 {
+	mutex_lock(&phb_mutex);
+	list_del(&host->list);
+	mutex_unlock(&phb_mutex);
+
 	device_unregister(&host->dev);
 }
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27ec612..7238fa3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
 		void *sysdata)
 {
 	int error;
-	struct pci_bus *b, *b2;
+	struct pci_bus *b;
 	struct resource_entry *window;
 	struct device *parent;
 	struct resource *res;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), b->number);
-	if (b2) {
-		/* If we already got to this bus through a different bridge, ignore it */
-		dev_dbg(&b2->dev, "bus already known\n");
-		goto err_out;
-	}
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463eaa3..b621f5b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,6 +406,7 @@ struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
+	struct list_head list;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Introduce pci_host_bridge_list to manage pci host
bridges in system, so we could detect whether
the host in domain:bus is alreay registered.
Then we could remove bus alreay exist test in
__pci_create_root_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
 drivers/pci/probe.c       |    8 +-------
 include/linux/pci.h       |    1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3bd45e7..0bb08ef 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,9 @@
 
 #include "pci.h"
 
+static LIST_HEAD(pci_host_bridge_list);
+static DEFINE_MUTEX(phb_mutex);
+
 static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	int error;
 	int bus = PCI_BUSNUM(db);
 	int domain = PCI_DOMAIN(db);
-	struct pci_host_bridge *host;
+	struct pci_host_bridge *host, *temp;
 	struct resource_entry *window, *n;
 
 	host = kzalloc(sizeof(*host), GFP_KERNEL);
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	 */
 	pci_host_assign_domain_nr(host);
 
+	mutex_lock(&phb_mutex);
+	list_for_each_entry(temp, &pci_host_bridge_list, list)
+		if (temp->domain == host->domain
+				&& temp->busnum == host->busnum) {
+			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
+					host->domain, host->busnum);
+			mutex_unlock(&phb_mutex);
+			kfree(host);
+			return NULL;
+		}
+	mutex_unlock(&phb_mutex);
+
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	resource_list_for_each_entry_safe(window, n, resources)
 		list_move_tail(&window->node, &host->windows);
 
+	mutex_lock(&phb_mutex);
+	list_add_tail(&host->list, &pci_host_bridge_list);
+	mutex_unlock(&phb_mutex);
 	return host;
 }
 
 void pci_free_host_bridge(struct pci_host_bridge *host)
 {
+	mutex_lock(&phb_mutex);
+	list_del(&host->list);
+	mutex_unlock(&phb_mutex);
+
 	device_unregister(&host->dev);
 }
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27ec612..7238fa3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
 		void *sysdata)
 {
 	int error;
-	struct pci_bus *b, *b2;
+	struct pci_bus *b;
 	struct resource_entry *window;
 	struct device *parent;
 	struct resource *res;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), b->number);
-	if (b2) {
-		/* If we already got to this bus through a different bridge, ignore it */
-		dev_dbg(&b2->dev, "bus already known\n");
-		goto err_out;
-	}
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463eaa3..b621f5b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,6 +406,7 @@ struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
+	struct list_head list;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1

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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_bridge_list to manage pci host
bridges in system, so we could detect whether
the host in domain:bus is alreay registered.
Then we could remove bus alreay exist test in
__pci_create_root_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
 drivers/pci/probe.c       |    8 +-------
 include/linux/pci.h       |    1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3bd45e7..0bb08ef 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,9 @@
 
 #include "pci.h"
 
+static LIST_HEAD(pci_host_bridge_list);
+static DEFINE_MUTEX(phb_mutex);
+
 static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	int error;
 	int bus = PCI_BUSNUM(db);
 	int domain = PCI_DOMAIN(db);
-	struct pci_host_bridge *host;
+	struct pci_host_bridge *host, *temp;
 	struct resource_entry *window, *n;
 
 	host = kzalloc(sizeof(*host), GFP_KERNEL);
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	 */
 	pci_host_assign_domain_nr(host);
 
+	mutex_lock(&phb_mutex);
+	list_for_each_entry(temp, &pci_host_bridge_list, list)
+		if (temp->domain = host->domain
+				&& temp->busnum = host->busnum) {
+			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
+					host->domain, host->busnum);
+			mutex_unlock(&phb_mutex);
+			kfree(host);
+			return NULL;
+		}
+	mutex_unlock(&phb_mutex);
+
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	resource_list_for_each_entry_safe(window, n, resources)
 		list_move_tail(&window->node, &host->windows);
 
+	mutex_lock(&phb_mutex);
+	list_add_tail(&host->list, &pci_host_bridge_list);
+	mutex_unlock(&phb_mutex);
 	return host;
 }
 
 void pci_free_host_bridge(struct pci_host_bridge *host)
 {
+	mutex_lock(&phb_mutex);
+	list_del(&host->list);
+	mutex_unlock(&phb_mutex);
+
 	device_unregister(&host->dev);
 }
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27ec612..7238fa3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
 		void *sysdata)
 {
 	int error;
-	struct pci_bus *b, *b2;
+	struct pci_bus *b;
 	struct resource_entry *window;
 	struct device *parent;
 	struct resource *res;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), b->number);
-	if (b2) {
-		/* If we already got to this bus through a different bridge, ignore it */
-		dev_dbg(&b2->dev, "bus already known\n");
-		goto err_out;
-	}
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463eaa3..b621f5b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,6 +406,7 @@ struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
+	struct list_head list;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce pci_host_bridge_list to manage pci host
bridges in system, so we could detect whether
the host in domain:bus is alreay registered.
Then we could remove bus alreay exist test in
__pci_create_root_bus().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
 drivers/pci/probe.c       |    8 +-------
 include/linux/pci.h       |    1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3bd45e7..0bb08ef 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -8,6 +8,9 @@
 
 #include "pci.h"
 
+static LIST_HEAD(pci_host_bridge_list);
+static DEFINE_MUTEX(phb_mutex);
+
 static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	int error;
 	int bus = PCI_BUSNUM(db);
 	int domain = PCI_DOMAIN(db);
-	struct pci_host_bridge *host;
+	struct pci_host_bridge *host, *temp;
 	struct resource_entry *window, *n;
 
 	host = kzalloc(sizeof(*host), GFP_KERNEL);
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	 */
 	pci_host_assign_domain_nr(host);
 
+	mutex_lock(&phb_mutex);
+	list_for_each_entry(temp, &pci_host_bridge_list, list)
+		if (temp->domain == host->domain
+				&& temp->busnum == host->busnum) {
+			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
+					host->domain, host->busnum);
+			mutex_unlock(&phb_mutex);
+			kfree(host);
+			return NULL;
+		}
+	mutex_unlock(&phb_mutex);
+
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
 	resource_list_for_each_entry_safe(window, n, resources)
 		list_move_tail(&window->node, &host->windows);
 
+	mutex_lock(&phb_mutex);
+	list_add_tail(&host->list, &pci_host_bridge_list);
+	mutex_unlock(&phb_mutex);
 	return host;
 }
 
 void pci_free_host_bridge(struct pci_host_bridge *host)
 {
+	mutex_lock(&phb_mutex);
+	list_del(&host->list);
+	mutex_unlock(&phb_mutex);
+
 	device_unregister(&host->dev);
 }
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27ec612..7238fa3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
 		void *sysdata)
 {
 	int error;
-	struct pci_bus *b, *b2;
+	struct pci_bus *b;
 	struct resource_entry *window;
 	struct device *parent;
 	struct resource *res;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
-	b2 = pci_find_bus(pci_domain_nr(b), b->number);
-	if (b2) {
-		/* If we already got to this bus through a different bridge, ignore it */
-		dev_dbg(&b2->dev, "bus already known\n");
-		goto err_out;
-	}
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463eaa3..b621f5b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,6 +406,7 @@ struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
+	struct list_head list;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Save platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    4 +++-
 drivers/pci/pci.h         |    4 +++-
 drivers/pci/probe.c       |   18 ++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 0bb08ef..3c34c49 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db, struct list_head *resources)
+		struct device *parent, u32 db,
+		struct list_head *resources, void *sysdata)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_drvdata(&host->dev, sysdata);
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3de5e51..79a8894 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,6 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus, struct list_head *resources);
+		struct device *parent, u32 dombus,
+		struct list_head *resources, void *sysdata);
+
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7238fa3..c8e074d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1866,8 +1866,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 }
 
 static struct pci_bus *__pci_create_root_bus(
-		struct pci_host_bridge *bridge, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
 	struct pci_bus *b;
@@ -1883,7 +1882,7 @@ static struct pci_bus *__pci_create_root_bus(
 	if (!b)
 		return NULL;
 
-	b->sysdata = sysdata;
+	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
@@ -1955,11 +1954,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_create_root_bus(host, ops, sysdata);
+	return __pci_create_root_bus(host, ops);
 }
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
@@ -2026,8 +2025,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 }
 
 static struct pci_bus *__pci_scan_root_bus(
-		struct pci_host_bridge *host, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *host, struct pci_ops *ops)
 {
 	struct resource_entry *window;
 	bool found = false;
@@ -2040,7 +2038,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops, sysdata);
+	b = __pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2066,11 +2064,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_scan_root_bus(host, ops, sysdata);
+	return __pci_scan_root_bus(host, ops);
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-- 
1.7.1


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

* [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata
  2015-03-09  2:33 ` Yijing Wang
                   ` (25 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Save platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    4 +++-
 drivers/pci/pci.h         |    4 +++-
 drivers/pci/probe.c       |   18 ++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 0bb08ef..3c34c49 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db, struct list_head *resources)
+		struct device *parent, u32 db,
+		struct list_head *resources, void *sysdata)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_drvdata(&host->dev, sysdata);
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3de5e51..79a8894 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,6 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus, struct list_head *resources);
+		struct device *parent, u32 dombus,
+		struct list_head *resources, void *sysdata);
+
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7238fa3..c8e074d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1866,8 +1866,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 }
 
 static struct pci_bus *__pci_create_root_bus(
-		struct pci_host_bridge *bridge, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
 	struct pci_bus *b;
@@ -1883,7 +1882,7 @@ static struct pci_bus *__pci_create_root_bus(
 	if (!b)
 		return NULL;
 
-	b->sysdata = sysdata;
+	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
@@ -1955,11 +1954,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_create_root_bus(host, ops, sysdata);
+	return __pci_create_root_bus(host, ops);
 }
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
@@ -2026,8 +2025,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 }
 
 static struct pci_bus *__pci_scan_root_bus(
-		struct pci_host_bridge *host, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *host, struct pci_ops *ops)
 {
 	struct resource_entry *window;
 	bool found = false;
@@ -2040,7 +2038,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops, sysdata);
+	b = __pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2066,11 +2064,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_scan_root_bus(host, ops, sysdata);
+	return __pci_scan_root_bus(host, ops);
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-- 
1.7.1

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

* [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Save platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    4 +++-
 drivers/pci/pci.h         |    4 +++-
 drivers/pci/probe.c       |   18 ++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 0bb08ef..3c34c49 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db, struct list_head *resources)
+		struct device *parent, u32 db,
+		struct list_head *resources, void *sysdata)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_drvdata(&host->dev, sysdata);
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3de5e51..79a8894 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,6 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus, struct list_head *resources);
+		struct device *parent, u32 dombus,
+		struct list_head *resources, void *sysdata);
+
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7238fa3..c8e074d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1866,8 +1866,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 }
 
 static struct pci_bus *__pci_create_root_bus(
-		struct pci_host_bridge *bridge, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
 	struct pci_bus *b;
@@ -1883,7 +1882,7 @@ static struct pci_bus *__pci_create_root_bus(
 	if (!b)
 		return NULL;
 
-	b->sysdata = sysdata;
+	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
@@ -1955,11 +1954,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_create_root_bus(host, ops, sysdata);
+	return __pci_create_root_bus(host, ops);
 }
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
@@ -2026,8 +2025,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 }
 
 static struct pci_bus *__pci_scan_root_bus(
-		struct pci_host_bridge *host, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *host, struct pci_ops *ops)
 {
 	struct resource_entry *window;
 	bool found = false;
@@ -2040,7 +2038,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops, sysdata);
+	b = __pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2066,11 +2064,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_scan_root_bus(host, ops, sysdata);
+	return __pci_scan_root_bus(host, ops);
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-- 
1.7.1


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

* [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Save platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    4 +++-
 drivers/pci/pci.h         |    4 +++-
 drivers/pci/probe.c       |   18 ++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 0bb08ef..3c34c49 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db, struct list_head *resources)
+		struct device *parent, u32 db,
+		struct list_head *resources, void *sysdata)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_drvdata(&host->dev, sysdata);
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3de5e51..79a8894 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,6 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus, struct list_head *resources);
+		struct device *parent, u32 dombus,
+		struct list_head *resources, void *sysdata);
+
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7238fa3..c8e074d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1866,8 +1866,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 }
 
 static struct pci_bus *__pci_create_root_bus(
-		struct pci_host_bridge *bridge, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
 	struct pci_bus *b;
@@ -1883,7 +1882,7 @@ static struct pci_bus *__pci_create_root_bus(
 	if (!b)
 		return NULL;
 
-	b->sysdata = sysdata;
+	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
@@ -1955,11 +1954,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_create_root_bus(host, ops, sysdata);
+	return __pci_create_root_bus(host, ops);
 }
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
@@ -2026,8 +2025,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 }
 
 static struct pci_bus *__pci_scan_root_bus(
-		struct pci_host_bridge *host, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *host, struct pci_ops *ops)
 {
 	struct resource_entry *window;
 	bool found = false;
@@ -2040,7 +2038,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops, sysdata);
+	b = __pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2066,11 +2064,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_scan_root_bus(host, ops, sysdata);
+	return __pci_scan_root_bus(host, ops);
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-- 
1.7.1

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

* [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Save platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    4 +++-
 drivers/pci/pci.h         |    4 +++-
 drivers/pci/probe.c       |   18 ++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 0bb08ef..3c34c49 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db, struct list_head *resources)
+		struct device *parent, u32 db,
+		struct list_head *resources, void *sysdata)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_drvdata(&host->dev, sysdata);
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3de5e51..79a8894 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,6 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus, struct list_head *resources);
+		struct device *parent, u32 dombus,
+		struct list_head *resources, void *sysdata);
+
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7238fa3..c8e074d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1866,8 +1866,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 }
 
 static struct pci_bus *__pci_create_root_bus(
-		struct pci_host_bridge *bridge, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
 	struct pci_bus *b;
@@ -1883,7 +1882,7 @@ static struct pci_bus *__pci_create_root_bus(
 	if (!b)
 		return NULL;
 
-	b->sysdata = sysdata;
+	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
@@ -1955,11 +1954,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_create_root_bus(host, ops, sysdata);
+	return __pci_create_root_bus(host, ops);
 }
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
@@ -2026,8 +2025,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 }
 
 static struct pci_bus *__pci_scan_root_bus(
-		struct pci_host_bridge *host, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *host, struct pci_ops *ops)
 {
 	struct resource_entry *window;
 	bool found = false;
@@ -2040,7 +2038,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops, sysdata);
+	b = __pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2066,11 +2064,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_scan_root_bus(host, ops, sysdata);
+	return __pci_scan_root_bus(host, ops);
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-- 
1.7.1


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

* [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Save platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    4 +++-
 drivers/pci/pci.h         |    4 +++-
 drivers/pci/probe.c       |   18 ++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 0bb08ef..3c34c49 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db, struct list_head *resources)
+		struct device *parent, u32 db,
+		struct list_head *resources, void *sysdata)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
+	dev_set_drvdata(&host->dev, sysdata);
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3de5e51..79a8894 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,6 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus, struct list_head *resources);
+		struct device *parent, u32 dombus,
+		struct list_head *resources, void *sysdata);
+
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7238fa3..c8e074d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1866,8 +1866,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 }
 
 static struct pci_bus *__pci_create_root_bus(
-		struct pci_host_bridge *bridge, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
 	struct pci_bus *b;
@@ -1883,7 +1882,7 @@ static struct pci_bus *__pci_create_root_bus(
 	if (!b)
 		return NULL;
 
-	b->sysdata = sysdata;
+	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
 	pci_bus_assign_domain_nr(b, parent);
@@ -1955,11 +1954,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_create_root_bus(host, ops, sysdata);
+	return __pci_create_root_bus(host, ops);
 }
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
@@ -2026,8 +2025,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
 }
 
 static struct pci_bus *__pci_scan_root_bus(
-		struct pci_host_bridge *host, struct pci_ops *ops,
-		void *sysdata)
+		struct pci_host_bridge *host, struct pci_ops *ops)
 {
 	struct resource_entry *window;
 	bool found = false;
@@ -2040,7 +2038,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops, sysdata);
+	b = __pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2066,11 +2064,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources);
+	host = pci_create_host_bridge(parent, db, resources, sysdata);
 	if (!host)
 		return NULL;
 
-	return __pci_scan_root_bus(host, ops, sysdata);
+	return __pci_scan_root_bus(host, ops);
 }
 EXPORT_SYMBOL(pci_scan_root_bus);
 
-- 
1.7.1


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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we have weak functions like pcibios_root_bridge_prepare()
to setup pci host bridge, We could introduce pci_host_bridge_ops
which contain host bridge specific ops to setup pci_host_bridge.
Then host bridge driver could add pci_host_bridge_ops hooks
intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:

pci_host_bridge_ops {
	/* set root bus speed, some platform need this like powerpc */
	void (*set_root_bus_speed)(struct pci_host_bridge *host);
	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
	int (*prepare)(struct pci_host_bridge *host);
	/* platform specific of scan hook to scan pci device */
	void (*scan_bus)(struct pci_host_bridge *);
}
We could easily extend it to support different host bridge
specific operations.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   12 ++++++++++--
 drivers/pci/pci.h         |    4 ++--
 drivers/pci/probe.c       |   17 +++++++++++------
 include/linux/pci.h       |    8 ++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3c34c49..bc1de59 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db,
-		struct list_head *resources, void *sysdata)
+		struct device *parent, u32 db, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 		}
 	mutex_unlock(&phb_mutex);
 
+	host->ops = ops;
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
+	if (host->ops && host->ops->prepare) {
+		error = host->ops->prepare(host);
+		if (error) {
+			kfree(host);
+			return NULL;
+		}
+	}
 	error = device_register(&host->dev);
 	if (error) {
 		put_device(&host->dev);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79a8894..a1dc9f2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus,
-		struct list_head *resources, void *sysdata);
+		struct device *parent, u32 dombus, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8e074d..59d9be3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+	if (bridge->ops && bridge->ops->set_root_bus_speed)
+		bridge->ops->set_root_bus_speed(bridge);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
 		goto err_out;
@@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
@@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
 		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
-	max = pci_scan_child_bus(b);
-
-	if (!found)
-		pci_bus_update_busn_res_end(b, max);
+	if (host->ops && host->ops->scan_bus) {
+		host->ops->scan_bus(host);
+	} else {
+		max = pci_scan_child_bus(b);
+		if (!found)
+			pci_bus_update_busn_res_end(b, max);
+	}
 
 	return b;
 }
@@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b621f5b..e9922b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 	return (pdev->error_state != pci_channel_io_normal);
 }
 
+struct pci_host_bridge;
+struct pci_host_bridge_ops {
+	void (*set_root_bus_speed)(struct pci_host_bridge *host);
+	int (*prepare)(struct pci_host_bridge *host);
+	void (*scan_bus)(struct pci_host_bridge *);
+};
+
 struct pci_host_bridge {
 	u16	domain;
 	u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
 	struct list_head list;
+	struct pci_host_bridge_ops *ops;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
  2015-03-09  2:33 ` Yijing Wang
                   ` (27 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we have weak functions like pcibios_root_bridge_prepare()
to setup pci host bridge, We could introduce pci_host_bridge_ops
which contain host bridge specific ops to setup pci_host_bridge.
Then host bridge driver could add pci_host_bridge_ops hooks
intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:

pci_host_bridge_ops {
	/* set root bus speed, some platform need this like powerpc */
	void (*set_root_bus_speed)(struct pci_host_bridge *host);
	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
	int (*prepare)(struct pci_host_bridge *host);
	/* platform specific of scan hook to scan pci device */
	void (*scan_bus)(struct pci_host_bridge *);
}
We could easily extend it to support different host bridge
specific operations.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   12 ++++++++++--
 drivers/pci/pci.h         |    4 ++--
 drivers/pci/probe.c       |   17 +++++++++++------
 include/linux/pci.h       |    8 ++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3c34c49..bc1de59 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db,
-		struct list_head *resources, void *sysdata)
+		struct device *parent, u32 db, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 		}
 	mutex_unlock(&phb_mutex);
 
+	host->ops = ops;
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
+	if (host->ops && host->ops->prepare) {
+		error = host->ops->prepare(host);
+		if (error) {
+			kfree(host);
+			return NULL;
+		}
+	}
 	error = device_register(&host->dev);
 	if (error) {
 		put_device(&host->dev);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79a8894..a1dc9f2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus,
-		struct list_head *resources, void *sysdata);
+		struct device *parent, u32 dombus, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8e074d..59d9be3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+	if (bridge->ops && bridge->ops->set_root_bus_speed)
+		bridge->ops->set_root_bus_speed(bridge);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
 		goto err_out;
@@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
@@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
 		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
-	max = pci_scan_child_bus(b);
-
-	if (!found)
-		pci_bus_update_busn_res_end(b, max);
+	if (host->ops && host->ops->scan_bus) {
+		host->ops->scan_bus(host);
+	} else {
+		max = pci_scan_child_bus(b);
+		if (!found)
+			pci_bus_update_busn_res_end(b, max);
+	}
 
 	return b;
 }
@@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b621f5b..e9922b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 	return (pdev->error_state != pci_channel_io_normal);
 }
 
+struct pci_host_bridge;
+struct pci_host_bridge_ops {
+	void (*set_root_bus_speed)(struct pci_host_bridge *host);
+	int (*prepare)(struct pci_host_bridge *host);
+	void (*scan_bus)(struct pci_host_bridge *);
+};
+
 struct pci_host_bridge {
 	u16	domain;
 	u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
 	struct list_head list;
+	struct pci_host_bridge_ops *ops;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1

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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we have weak functions like pcibios_root_bridge_prepare()
to setup pci host bridge, We could introduce pci_host_bridge_ops
which contain host bridge specific ops to setup pci_host_bridge.
Then host bridge driver could add pci_host_bridge_ops hooks
intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:

pci_host_bridge_ops {
	/* set root bus speed, some platform need this like powerpc */
	void (*set_root_bus_speed)(struct pci_host_bridge *host);
	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
	int (*prepare)(struct pci_host_bridge *host);
	/* platform specific of scan hook to scan pci device */
	void (*scan_bus)(struct pci_host_bridge *);
}
We could easily extend it to support different host bridge
specific operations.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   12 ++++++++++--
 drivers/pci/pci.h         |    4 ++--
 drivers/pci/probe.c       |   17 +++++++++++------
 include/linux/pci.h       |    8 ++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3c34c49..bc1de59 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db,
-		struct list_head *resources, void *sysdata)
+		struct device *parent, u32 db, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 		}
 	mutex_unlock(&phb_mutex);
 
+	host->ops = ops;
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
+	if (host->ops && host->ops->prepare) {
+		error = host->ops->prepare(host);
+		if (error) {
+			kfree(host);
+			return NULL;
+		}
+	}
 	error = device_register(&host->dev);
 	if (error) {
 		put_device(&host->dev);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79a8894..a1dc9f2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus,
-		struct list_head *resources, void *sysdata);
+		struct device *parent, u32 dombus, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8e074d..59d9be3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+	if (bridge->ops && bridge->ops->set_root_bus_speed)
+		bridge->ops->set_root_bus_speed(bridge);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
 		goto err_out;
@@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
@@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
 		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
-	max = pci_scan_child_bus(b);
-
-	if (!found)
-		pci_bus_update_busn_res_end(b, max);
+	if (host->ops && host->ops->scan_bus) {
+		host->ops->scan_bus(host);
+	} else {
+		max = pci_scan_child_bus(b);
+		if (!found)
+			pci_bus_update_busn_res_end(b, max);
+	}
 
 	return b;
 }
@@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b621f5b..e9922b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 	return (pdev->error_state != pci_channel_io_normal);
 }
 
+struct pci_host_bridge;
+struct pci_host_bridge_ops {
+	void (*set_root_bus_speed)(struct pci_host_bridge *host);
+	int (*prepare)(struct pci_host_bridge *host);
+	void (*scan_bus)(struct pci_host_bridge *);
+};
+
 struct pci_host_bridge {
 	u16	domain;
 	u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
 	struct list_head list;
+	struct pci_host_bridge_ops *ops;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we have weak functions like pcibios_root_bridge_prepare()
to setup pci host bridge, We could introduce pci_host_bridge_ops
which contain host bridge specific ops to setup pci_host_bridge.
Then host bridge driver could add pci_host_bridge_ops hooks
intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:

pci_host_bridge_ops {
	/* set root bus speed, some platform need this like powerpc */
	void (*set_root_bus_speed)(struct pci_host_bridge *host);
	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
	int (*prepare)(struct pci_host_bridge *host);
	/* platform specific of scan hook to scan pci device */
	void (*scan_bus)(struct pci_host_bridge *);
}
We could easily extend it to support different host bridge
specific operations.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   12 ++++++++++--
 drivers/pci/pci.h         |    4 ++--
 drivers/pci/probe.c       |   17 +++++++++++------
 include/linux/pci.h       |    8 ++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3c34c49..bc1de59 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db,
-		struct list_head *resources, void *sysdata)
+		struct device *parent, u32 db, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 		}
 	mutex_unlock(&phb_mutex);
 
+	host->ops = ops;
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
+	if (host->ops && host->ops->prepare) {
+		error = host->ops->prepare(host);
+		if (error) {
+			kfree(host);
+			return NULL;
+		}
+	}
 	error = device_register(&host->dev);
 	if (error) {
 		put_device(&host->dev);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79a8894..a1dc9f2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus,
-		struct list_head *resources, void *sysdata);
+		struct device *parent, u32 dombus, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8e074d..59d9be3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+	if (bridge->ops && bridge->ops->set_root_bus_speed)
+		bridge->ops->set_root_bus_speed(bridge);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
 		goto err_out;
@@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
@@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
 		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
-	max = pci_scan_child_bus(b);
-
-	if (!found)
-		pci_bus_update_busn_res_end(b, max);
+	if (host->ops && host->ops->scan_bus) {
+		host->ops->scan_bus(host);
+	} else {
+		max = pci_scan_child_bus(b);
+		if (!found)
+			pci_bus_update_busn_res_end(b, max);
+	}
 
 	return b;
 }
@@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b621f5b..e9922b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 	return (pdev->error_state != pci_channel_io_normal);
 }
 
+struct pci_host_bridge;
+struct pci_host_bridge_ops {
+	void (*set_root_bus_speed)(struct pci_host_bridge *host);
+	int (*prepare)(struct pci_host_bridge *host);
+	void (*scan_bus)(struct pci_host_bridge *);
+};
+
 struct pci_host_bridge {
 	u16	domain;
 	u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
 	struct list_head list;
+	struct pci_host_bridge_ops *ops;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1

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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we have weak functions like pcibios_root_bridge_prepare()
to setup pci host bridge, We could introduce pci_host_bridge_ops
which contain host bridge specific ops to setup pci_host_bridge.
Then host bridge driver could add pci_host_bridge_ops hooks
intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:

pci_host_bridge_ops {
	/* set root bus speed, some platform need this like powerpc */
	void (*set_root_bus_speed)(struct pci_host_bridge *host);
	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
	int (*prepare)(struct pci_host_bridge *host);
	/* platform specific of scan hook to scan pci device */
	void (*scan_bus)(struct pci_host_bridge *);
}
We could easily extend it to support different host bridge
specific operations.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   12 ++++++++++--
 drivers/pci/pci.h         |    4 ++--
 drivers/pci/probe.c       |   17 +++++++++++------
 include/linux/pci.h       |    8 ++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3c34c49..bc1de59 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db,
-		struct list_head *resources, void *sysdata)
+		struct device *parent, u32 db, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 		}
 	mutex_unlock(&phb_mutex);
 
+	host->ops = ops;
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
+	if (host->ops && host->ops->prepare) {
+		error = host->ops->prepare(host);
+		if (error) {
+			kfree(host);
+			return NULL;
+		}
+	}
 	error = device_register(&host->dev);
 	if (error) {
 		put_device(&host->dev);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79a8894..a1dc9f2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus,
-		struct list_head *resources, void *sysdata);
+		struct device *parent, u32 dombus, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8e074d..59d9be3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+	if (bridge->ops && bridge->ops->set_root_bus_speed)
+		bridge->ops->set_root_bus_speed(bridge);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
 		goto err_out;
@@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
@@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
 		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
-	max = pci_scan_child_bus(b);
-
-	if (!found)
-		pci_bus_update_busn_res_end(b, max);
+	if (host->ops && host->ops->scan_bus) {
+		host->ops->scan_bus(host);
+	} else {
+		max = pci_scan_child_bus(b);
+		if (!found)
+			pci_bus_update_busn_res_end(b, max);
+	}
 
 	return b;
 }
@@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b621f5b..e9922b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 	return (pdev->error_state != pci_channel_io_normal);
 }
 
+struct pci_host_bridge;
+struct pci_host_bridge_ops {
+	void (*set_root_bus_speed)(struct pci_host_bridge *host);
+	int (*prepare)(struct pci_host_bridge *host);
+	void (*scan_bus)(struct pci_host_bridge *);
+};
+
 struct pci_host_bridge {
 	u16	domain;
 	u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
 	struct list_head list;
+	struct pci_host_bridge_ops *ops;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we have weak functions like pcibios_root_bridge_prepare()
to setup pci host bridge, We could introduce pci_host_bridge_ops
which contain host bridge specific ops to setup pci_host_bridge.
Then host bridge driver could add pci_host_bridge_ops hooks
intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:

pci_host_bridge_ops {
	/* set root bus speed, some platform need this like powerpc */
	void (*set_root_bus_speed)(struct pci_host_bridge *host);
	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
	int (*prepare)(struct pci_host_bridge *host);
	/* platform specific of scan hook to scan pci device */
	void (*scan_bus)(struct pci_host_bridge *);
}
We could easily extend it to support different host bridge
specific operations.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |   12 ++++++++++--
 drivers/pci/pci.h         |    4 ++--
 drivers/pci/probe.c       |   17 +++++++++++------
 include/linux/pci.h       |    8 ++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3c34c49..bc1de59 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
 }
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 db,
-		struct list_head *resources, void *sysdata)
+		struct device *parent, u32 db, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops)
 {
 	int error;
 	int bus = PCI_BUSNUM(db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
 		}
 	mutex_unlock(&phb_mutex);
 
+	host->ops = ops;
 	host->dev.parent = parent;
 	INIT_LIST_HEAD(&host->windows);
 	host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
 	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
 			host->busnum);
 
+	if (host->ops && host->ops->prepare) {
+		error = host->ops->prepare(host);
+		if (error) {
+			kfree(host);
+			return NULL;
+		}
+	}
 	error = device_register(&host->dev);
 	if (error) {
 		put_device(&host->dev);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79a8894..a1dc9f2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
 #endif
 
 struct pci_host_bridge *pci_create_host_bridge(
-		struct device *parent, u32 dombus,
-		struct list_head *resources, void *sysdata);
+		struct device *parent, u32 dombus, struct list_head *resources,
+		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8e074d..59d9be3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+	if (bridge->ops && bridge->ops->set_root_bus_speed)
+		bridge->ops->set_root_bus_speed(bridge);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
 		goto err_out;
@@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
@@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
 		pci_bus_insert_busn_res(b, b->number, 255);
 	}
 
-	max = pci_scan_child_bus(b);
-
-	if (!found)
-		pci_bus_update_busn_res_end(b, max);
+	if (host->ops && host->ops->scan_bus) {
+		host->ops->scan_bus(host);
+	} else {
+		max = pci_scan_child_bus(b);
+		if (!found)
+			pci_bus_update_busn_res_end(b, max);
+	}
 
 	return b;
 }
@@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 {
 	struct pci_host_bridge *host;
 
-	host = pci_create_host_bridge(parent, db, resources, sysdata);
+	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
 	if (!host)
 		return NULL;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b621f5b..e9922b1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
 	return (pdev->error_state != pci_channel_io_normal);
 }
 
+struct pci_host_bridge;
+struct pci_host_bridge_ops {
+	void (*set_root_bus_speed)(struct pci_host_bridge *host);
+	int (*prepare)(struct pci_host_bridge *host);
+	void (*scan_bus)(struct pci_host_bridge *);
+};
+
 struct pci_host_bridge {
 	u16	domain;
 	u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {
 	struct pci_bus *bus;		/* root bus */
 	struct list_head windows;	/* resource_entry */
 	struct list_head list;
+	struct pci_host_bridge_ops *ops;
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
 };
-- 
1.7.1


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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce new scan function pci_scan_host_bridge() to
support host bridge drivers that need to provide platform
own pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   22 ++++++++++++++++++++++
 include/linux/pci.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59d9be3..99f17e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
 	return b;
 }
 
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 db, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops)
+{
+	struct pci_host_bridge *host;
+	struct pci_bus *bus;
+
+	host = pci_create_host_bridge(parent, db, resources,
+			sysdata, phb_ops);
+	if (!host)
+		return NULL;
+
+	bus = __pci_scan_root_bus(host, ops);
+	if (!bus)
+		pci_free_host_bridge(host);
+
+	return host;
+}
+EXPORT_SYMBOL(pci_scan_host_bridge);
+
+
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e9922b1..28eafb5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 dombus, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
-- 
1.7.1


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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce new scan function pci_scan_host_bridge() to
support host bridge drivers that need to provide platform
own pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   22 ++++++++++++++++++++++
 include/linux/pci.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59d9be3..99f17e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
 	return b;
 }
 
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 db, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops)
+{
+	struct pci_host_bridge *host;
+	struct pci_bus *bus;
+
+	host = pci_create_host_bridge(parent, db, resources,
+			sysdata, phb_ops);
+	if (!host)
+		return NULL;
+
+	bus = __pci_scan_root_bus(host, ops);
+	if (!bus)
+		pci_free_host_bridge(host);
+
+	return host;
+}
+EXPORT_SYMBOL(pci_scan_host_bridge);
+
+
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e9922b1..28eafb5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 dombus, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
-- 
1.7.1

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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce new scan function pci_scan_host_bridge() to
support host bridge drivers that need to provide platform
own pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   22 ++++++++++++++++++++++
 include/linux/pci.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59d9be3..99f17e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
 	return b;
 }
 
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 db, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops)
+{
+	struct pci_host_bridge *host;
+	struct pci_bus *bus;
+
+	host = pci_create_host_bridge(parent, db, resources,
+			sysdata, phb_ops);
+	if (!host)
+		return NULL;
+
+	bus = __pci_scan_root_bus(host, ops);
+	if (!bus)
+		pci_free_host_bridge(host);
+
+	return host;
+}
+EXPORT_SYMBOL(pci_scan_host_bridge);
+
+
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e9922b1..28eafb5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 dombus, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
-- 
1.7.1


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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Introduce new scan function pci_scan_host_bridge() to
support host bridge drivers that need to provide platform
own pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   22 ++++++++++++++++++++++
 include/linux/pci.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59d9be3..99f17e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
 	return b;
 }
 
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 db, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops)
+{
+	struct pci_host_bridge *host;
+	struct pci_bus *bus;
+
+	host = pci_create_host_bridge(parent, db, resources,
+			sysdata, phb_ops);
+	if (!host)
+		return NULL;
+
+	bus = __pci_scan_root_bus(host, ops);
+	if (!bus)
+		pci_free_host_bridge(host);
+
+	return host;
+}
+EXPORT_SYMBOL(pci_scan_host_bridge);
+
+
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e9922b1..28eafb5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 dombus, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
-- 
1.7.1

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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce new scan function pci_scan_host_bridge() to
support host bridge drivers that need to provide platform
own pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   22 ++++++++++++++++++++++
 include/linux/pci.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59d9be3..99f17e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
 	return b;
 }
 
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 db, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops)
+{
+	struct pci_host_bridge *host;
+	struct pci_bus *bus;
+
+	host = pci_create_host_bridge(parent, db, resources,
+			sysdata, phb_ops);
+	if (!host)
+		return NULL;
+
+	bus = __pci_scan_root_bus(host, ops);
+	if (!bus)
+		pci_free_host_bridge(host);
+
+	return host;
+}
+EXPORT_SYMBOL(pci_scan_host_bridge);
+
+
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e9922b1..28eafb5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 dombus, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
-- 
1.7.1


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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Introduce new scan function pci_scan_host_bridge() to
support host bridge drivers that need to provide platform
own pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   22 ++++++++++++++++++++++
 include/linux/pci.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 59d9be3..99f17e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
 	return b;
 }
 
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 db, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops)
+{
+	struct pci_host_bridge *host;
+	struct pci_bus *bus;
+
+	host = pci_create_host_bridge(parent, db, resources,
+			sysdata, phb_ops);
+	if (!host)
+		return NULL;
+
+	bus = __pci_scan_root_bus(host, ops);
+	if (!bus)
+		pci_free_host_bridge(host);
+
+	return host;
+}
+EXPORT_SYMBOL(pci_scan_host_bridge);
+
+
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e9922b1..28eafb5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
 struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
 					     struct pci_ops *ops, void *sysdata,
 					     struct list_head *resources);
+struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
+		u32 dombus, struct pci_ops *ops, void *sysdata,
+		struct list_head *resources,
+		struct pci_host_bridge_ops *phb_ops);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
-- 
1.7.1

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

* [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: x86@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index ad0e926..e730d31 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info,
 			entry->res->name = info->name;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev);
+
+	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	LIST_HEAD(crs_res);
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *host = NULL;
 	struct pci_sysdata *sd;
 	int node;
 
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
 				(u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL,
-				PCI_DOMBUS(domain, busnum), &pci_root_ops,
-				sd, &resources);
-
-		if (bus) {
-			pci_scan_child_bus(bus);
-			pci_set_host_bridge_release(
-				to_pci_host_bridge(bus->bridge),
+			host = pci_scan_host_bridge(NULL,
+				PCI_DOMBUS(domain, busnum),
+				&pci_root_ops, sd, &resources, &phb_ops);
+
+		if (host) {
+			bus = host->bus;
+			pci_set_host_bridge_release(host,
 				release_pci_root_info, info);
 		} else {
 			resource_list_free(&resources);
@@ -456,14 +468,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	return bus;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_sysdata *sd = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
-	return 0;
-}
-
 int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.1


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

* [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  2015-03-09  2:33 ` Yijing Wang
                   ` (30 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: x86@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index ad0e926..e730d31 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info,
 			entry->res->name = info->name;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev);
+
+	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	LIST_HEAD(crs_res);
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *host = NULL;
 	struct pci_sysdata *sd;
 	int node;
 
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
 				(u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL,
-				PCI_DOMBUS(domain, busnum), &pci_root_ops,
-				sd, &resources);
-
-		if (bus) {
-			pci_scan_child_bus(bus);
-			pci_set_host_bridge_release(
-				to_pci_host_bridge(bus->bridge),
+			host = pci_scan_host_bridge(NULL,
+				PCI_DOMBUS(domain, busnum),
+				&pci_root_ops, sd, &resources, &phb_ops);
+
+		if (host) {
+			bus = host->bus;
+			pci_set_host_bridge_release(host,
 				release_pci_root_info, info);
 		} else {
 			resource_list_free(&resources);
@@ -456,14 +468,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	return bus;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_sysdata *sd = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
-	return 0;
-}
-
 int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.1

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

* [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: x86@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index ad0e926..e730d31 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info,
 			entry->res->name = info->name;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev);
+
+	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	LIST_HEAD(crs_res);
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *host = NULL;
 	struct pci_sysdata *sd;
 	int node;
 
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
 				(u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL,
-				PCI_DOMBUS(domain, busnum), &pci_root_ops,
-				sd, &resources);
-
-		if (bus) {
-			pci_scan_child_bus(bus);
-			pci_set_host_bridge_release(
-				to_pci_host_bridge(bus->bridge),
+			host = pci_scan_host_bridge(NULL,
+				PCI_DOMBUS(domain, busnum),
+				&pci_root_ops, sd, &resources, &phb_ops);
+
+		if (host) {
+			bus = host->bus;
+			pci_set_host_bridge_release(host,
 				release_pci_root_info, info);
 		} else {
 			resource_list_free(&resources);
@@ -456,14 +468,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	return bus;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_sysdata *sd = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
-	return 0;
-}
-
 int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.1


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

* [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: x86 at kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index ad0e926..e730d31 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info,
 			entry->res->name = info->name;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev);
+
+	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	LIST_HEAD(crs_res);
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *host = NULL;
 	struct pci_sysdata *sd;
 	int node;
 
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
 				(u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL,
-				PCI_DOMBUS(domain, busnum), &pci_root_ops,
-				sd, &resources);
-
-		if (bus) {
-			pci_scan_child_bus(bus);
-			pci_set_host_bridge_release(
-				to_pci_host_bridge(bus->bridge),
+			host = pci_scan_host_bridge(NULL,
+				PCI_DOMBUS(domain, busnum),
+				&pci_root_ops, sd, &resources, &phb_ops);
+
+		if (host) {
+			bus = host->bus;
+			pci_set_host_bridge_release(host,
 				release_pci_root_info, info);
 		} else {
 			resource_list_free(&resources);
@@ -456,14 +468,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	return bus;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_sysdata *sd = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
-	return 0;
-}
-
 int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.1

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

* [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: x86@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index ad0e926..e730d31 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info,
 			entry->res->name = info->name;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev);
+
+	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	LIST_HEAD(crs_res);
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *host = NULL;
 	struct pci_sysdata *sd;
 	int node;
 
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
 				(u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL,
-				PCI_DOMBUS(domain, busnum), &pci_root_ops,
-				sd, &resources);
-
-		if (bus) {
-			pci_scan_child_bus(bus);
-			pci_set_host_bridge_release(
-				to_pci_host_bridge(bus->bridge),
+			host = pci_scan_host_bridge(NULL,
+				PCI_DOMBUS(domain, busnum),
+				&pci_root_ops, sd, &resources, &phb_ops);
+
+		if (host) {
+			bus = host->bus;
+			pci_set_host_bridge_release(host,
 				release_pci_root_info, info);
 		} else {
 			resource_list_free(&resources);
@@ -456,14 +468,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	return bus;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_sysdata *sd = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
-	return 0;
-}
-
 int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.1


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

* [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: x86@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index ad0e926..e730d31 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info,
 			entry->res->name = info->name;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev);
+
+	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	LIST_HEAD(crs_res);
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *host = NULL;
 	struct pci_sysdata *sd;
 	int node;
 
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
 				(u8)root->secondary.end, root->mcfg_addr))
-			bus = pci_create_root_bus(NULL,
-				PCI_DOMBUS(domain, busnum), &pci_root_ops,
-				sd, &resources);
-
-		if (bus) {
-			pci_scan_child_bus(bus);
-			pci_set_host_bridge_release(
-				to_pci_host_bridge(bus->bridge),
+			host = pci_scan_host_bridge(NULL,
+				PCI_DOMBUS(domain, busnum),
+				&pci_root_ops, sd, &resources, &phb_ops);
+
+		if (host) {
+			bus = host->bus;
+			pci_set_host_bridge_release(host,
 				release_pci_root_info, info);
 		} else {
 			resource_list_free(&resources);
@@ -456,14 +468,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	return bus;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_sysdata *sd = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, sd->companion);
-	return 0;
-}
-
 int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.1

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

* [PATCH v6 15/30] ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, Fenghua Yu, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 675749f..0245862 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
 	return 0;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_controller *controller = bridge->bus->sysdata;
+
+	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct pci_controller *controller;
 	struct pci_root_info *info = NULL;
 	int busnum = root->secondary.start;
-	struct pci_bus *pbus;
+	struct pci_host_bridge *host;
 	int ret;
 
 	controller = alloc_pci_controller(domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
-			&pci_root_ops, controller, &info->resources);
-	if (!pbus) {
+	host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources, &phb_ops);
+	if (!host) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
 		return NULL;
 	}
 
-	pci_set_host_bridge_release(to_pci_host_bridge(pbus->bridge),
-			release_pci_root_info, info);
-	pci_scan_child_bus(pbus);
-	return pbus;
-}
-
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_controller *controller = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
-	return 0;
+	pci_set_host_bridge_release(host, release_pci_root_info, info);
+	return host->bus;
 }
 
 void pcibios_fixup_device_resources(struct pci_dev *dev)
-- 
1.7.1


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

* [PATCH v6 15/30] ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  2015-03-09  2:33 ` Yijing Wang
                   ` (31 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, Fenghua Yu, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 675749f..0245862 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
 	return 0;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_controller *controller = bridge->bus->sysdata;
+
+	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct pci_controller *controller;
 	struct pci_root_info *info = NULL;
 	int busnum = root->secondary.start;
-	struct pci_bus *pbus;
+	struct pci_host_bridge *host;
 	int ret;
 
 	controller = alloc_pci_controller(domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
-			&pci_root_ops, controller, &info->resources);
-	if (!pbus) {
+	host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources, &phb_ops);
+	if (!host) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
 		return NULL;
 	}
 
-	pci_set_host_bridge_release(to_pci_host_bridge(pbus->bridge),
-			release_pci_root_info, info);
-	pci_scan_child_bus(pbus);
-	return pbus;
-}
-
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_controller *controller = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
-	return 0;
+	pci_set_host_bridge_release(host, release_pci_root_info, info);
+	return host->bus;
 }
 
 void pcibios_fixup_device_resources(struct pci_dev *dev)
-- 
1.7.1

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

* [PATCH v6 15/30] ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, Fenghua Yu, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 675749f..0245862 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
 	return 0;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_controller *controller = bridge->bus->sysdata;
+
+	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct pci_controller *controller;
 	struct pci_root_info *info = NULL;
 	int busnum = root->secondary.start;
-	struct pci_bus *pbus;
+	struct pci_host_bridge *host;
 	int ret;
 
 	controller = alloc_pci_controller(domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
-			&pci_root_ops, controller, &info->resources);
-	if (!pbus) {
+	host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources, &phb_ops);
+	if (!host) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
 		return NULL;
 	}
 
-	pci_set_host_bridge_release(to_pci_host_bridge(pbus->bridge),
-			release_pci_root_info, info);
-	pci_scan_child_bus(pbus);
-	return pbus;
-}
-
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_controller *controller = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
-	return 0;
+	pci_set_host_bridge_release(host, release_pci_root_info, info);
+	return host->bus;
 }
 
 void pcibios_fixup_device_resources(struct pci_dev *dev)
-- 
1.7.1


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

* [PATCH v6 15/30] ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yijing Wang <wangyijing0307@gmail.com>

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64 at vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 675749f..0245862 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
 	return 0;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_controller *controller = bridge->bus->sysdata;
+
+	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct pci_controller *controller;
 	struct pci_root_info *info = NULL;
 	int busnum = root->secondary.start;
-	struct pci_bus *pbus;
+	struct pci_host_bridge *host;
 	int ret;
 
 	controller = alloc_pci_controller(domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
-			&pci_root_ops, controller, &info->resources);
-	if (!pbus) {
+	host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources, &phb_ops);
+	if (!host) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
 		return NULL;
 	}
 
-	pci_set_host_bridge_release(to_pci_host_bridge(pbus->bridge),
-			release_pci_root_info, info);
-	pci_scan_child_bus(pbus);
-	return pbus;
-}
-
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_controller *controller = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
-	return 0;
+	pci_set_host_bridge_release(host, release_pci_root_info, info);
+	return host->bus;
 }
 
 void pcibios_fixup_device_resources(struct pci_dev *dev)
-- 
1.7.1

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

* [PATCH v6 15/30] ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, Fenghua Yu, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 675749f..0245862 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
 	return 0;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_controller *controller = bridge->bus->sysdata;
+
+	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct pci_controller *controller;
 	struct pci_root_info *info = NULL;
 	int busnum = root->secondary.start;
-	struct pci_bus *pbus;
+	struct pci_host_bridge *host;
 	int ret;
 
 	controller = alloc_pci_controller(domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
-			&pci_root_ops, controller, &info->resources);
-	if (!pbus) {
+	host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources, &phb_ops);
+	if (!host) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
 		return NULL;
 	}
 
-	pci_set_host_bridge_release(to_pci_host_bridge(pbus->bridge),
-			release_pci_root_info, info);
-	pci_scan_child_bus(pbus);
-	return pbus;
-}
-
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_controller *controller = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
-	return 0;
+	pci_set_host_bridge_release(host, release_pci_root_info, info);
+	return host->bus;
 }
 
 void pcibios_fixup_device_resources(struct pci_dev *dev)
-- 
1.7.1


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

* [PATCH v6 15/30] ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, Fenghua Yu, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 675749f..0245862 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
 	return 0;
 }
 
+static int pci_host_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	struct pci_controller *controller = bridge->bus->sysdata;
+
+	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
+	return 0;
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.prepare = pci_host_bridge_prepare,
+};
+
 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 {
 	struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct pci_controller *controller;
 	struct pci_root_info *info = NULL;
 	int busnum = root->secondary.start;
-	struct pci_bus *pbus;
+	struct pci_host_bridge *host;
 	int ret;
 
 	controller = alloc_pci_controller(domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
-			&pci_root_ops, controller, &info->resources);
-	if (!pbus) {
+	host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, bus),
+			&pci_root_ops, controller, &info->resources, &phb_ops);
+	if (!host) {
 		pci_free_resource_list(&info->resources);
 		__release_pci_root_info(info);
 		return NULL;
 	}
 
-	pci_set_host_bridge_release(to_pci_host_bridge(pbus->bridge),
-			release_pci_root_info, info);
-	pci_scan_child_bus(pbus);
-	return pbus;
-}
-
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	struct pci_controller *controller = bridge->bus->sysdata;
-
-	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
-	return 0;
+	pci_set_host_bridge_release(host, release_pci_root_info, info);
+	return host->bus;
 }
 
 void pcibios_fixup_device_resources(struct pci_dev *dev)
-- 
1.7.1

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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1


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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
  2015-03-09  2:33 ` Yijing Wang
                   ` (34 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1

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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1


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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, Geert Uytterhoeven, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Bjorn Helgaas, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, linuxppc-dev,
	David S. Miller

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1

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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev at lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1

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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1


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

* [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |    4 ++--
 arch/powerpc/platforms/pseries/pci.c     |    2 +-
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 arch/powerpc/platforms/pseries/setup.c   |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
+	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a467aca..0d8b369 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,8 +769,8 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-	if (ppc_md.pcibios_root_bridge_prepare)
-		return ppc_md.pcibios_root_bridge_prepare(bridge);
+	if (ppc_md.pcibios_set_root_bus_speed)
+		return ppc_md.pcibios_set_root_bus_speed(bridge);
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
 		ppc_md.enable_pmcs = power4_enable_pmcs;
 	}
 
-	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
 	if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
 		long rc;
-- 
1.7.1


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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode == PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode == PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus == NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host == NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode == PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode == PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1


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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                   ` (36 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode == PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode == PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus == NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host == NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode == PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode == PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1

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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode == PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode == PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus == NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host == NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode == PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode == PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1


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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, Geert Uytterhoeven, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Bjorn Helgaas, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, linuxppc-dev,
	David S. Miller

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode == PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode == PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus == NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host == NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode == PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode == PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1

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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev at lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode == PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode == PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus == NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host == NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode == PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode == PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1

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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode = PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode = PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus = NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host = NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode = PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode = PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1


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

* [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	linuxppc-dev, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/machdep.h       |    2 +-
 arch/powerpc/kernel/pci-common.c         |   63 +++++++++++++++++------------
 arch/powerpc/platforms/pseries/pci.c     |    8 ++--
 arch/powerpc/platforms/pseries/pseries.h |    2 +-
 4 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
 	void		(*pcibios_fixup)(void);
 	int		(*pci_probe_mode)(struct pci_bus *);
 	void		(*pci_irq_fixup)(struct pci_dev *dev);
-	int		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
+	void		(*pcibios_set_root_bus_speed)(struct pci_host_bridge
 				*bridge);
 
 	/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d8b369..74cbb5d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,35 @@ int pci_proc_domain(struct pci_bus *bus)
 	return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+		struct pci_host_bridge *bridge)
 {
 	if (ppc_md.pcibios_set_root_bus_speed)
-		return ppc_md.pcibios_set_root_bus_speed(bridge);
+		ppc_md.pcibios_set_root_bus_speed(bridge);
+}
 
-	return 0;
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+	int mode = PCI_PROBE_NORMAL;
+	struct pci_bus *bus = host->bus;
+	struct pci_controller *hose = dev_get_drvdata(&host->dev);
+
+	/* Get probe mode and perform scan */
+	if (hose->dn && ppc_md.pci_probe_mode)
+		mode = ppc_md.pci_probe_mode(bus);
+
+	pr_debug("    probe mode: %d\n", mode);
+	if (mode == PCI_PROBE_DEVTREE)
+		of_scan_bus(hose->dn, bus);
+
+	if (mode == PCI_PROBE_NORMAL) {
+		pci_bus_update_busn_res_end(bus, 255);
+		hose->last_busno = pci_scan_child_bus(bus);
+		pci_bus_update_busn_res_end(bus, hose->last_busno);
+	}
 }
 
+
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 	return of_node_get(hose->dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+	.set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 	struct device_node *node = hose->dn;
-	int mode;
 
 	pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
 
@@ -1612,30 +1637,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
 	pci_add_resource(&resources, &hose->busn);
 
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent,
+	host = pci_scan_host_bridge(hose->parent,
 			PCI_DOMBUS(hose->global_number, hose->first_busno),
-			hose->ops, hose, &resources);
-	if (bus == NULL) {
-		pr_err("Failed to create bus for PCI domain %04x\n",
+			hose->ops, hose, &resources, &phb_ops);
+	if (host == NULL) {
+		pr_err("Failed to create host bridge for PCI domain %04x\n",
 			hose->global_number);
 		pci_free_resource_list(&resources);
 		return;
 	}
-	hose->bus = bus;
-
-	/* Get probe mode and perform scan */
-	mode = PCI_PROBE_NORMAL;
-	if (node && ppc_md.pci_probe_mode)
-		mode = ppc_md.pci_probe_mode(bus);
-	pr_debug("    probe mode: %d\n", mode);
-	if (mode == PCI_PROBE_DEVTREE)
-		of_scan_bus(node, bus);
-
-	if (mode == PCI_PROBE_NORMAL) {
-		pci_bus_update_busn_res_end(bus, 255);
-		hose->last_busno = pci_scan_child_bus(bus);
-		pci_bus_update_busn_res_end(bus, hose->last_busno);
-	}
+	hose->bus = host->bus;
 
 	/* Platform gets a chance to do some global fixups before
 	 * we proceed to resource allocation
@@ -1644,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
 		ppc_md.pcibios_fixup_phb(hose);
 
 	/* Configure PCI Express settings */
-	if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+	if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) {
 		struct pci_bus *child;
-		list_for_each_entry(child, &bus->children, node)
+		list_for_each_entry(child, &host->bus->children, node)
 			pcie_bus_configure_settings(child);
 	}
 }
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index af685d6..89ff79c 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
 
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
 	struct device_node *dn, *pdn;
 	struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	dn = pcibios_get_phb_of_node(bus);
 	if (!dn)
-		return 0;
+		return;
 
 	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
 		rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 
 	if (rc) {
 		pr_debug("no ibm,pcie-link-speed-stats property\n");
-		return 0;
+		return;
 	}
 
 	switch (pcie_link_speed_stats[0]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 		break;
 	}
 
-	return 0;
+	return;
 }
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 5d0be3a..9aa9c13 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
+void pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
-- 
1.7.1


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

* [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use weak pcibios_root_bridge_prepare(),
we could remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   16 +---------------
 include/linux/pci.h |    2 --
 2 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f17e3..1080eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1845,18 +1845,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
- * @bridge: Host bridge to set up.
- *
- * Default empty implementation.  Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	return 0;
-}
-
 void __weak pcibios_add_bus(struct pci_bus *bus)
 {
 }
@@ -1889,11 +1877,9 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+
 	if (bridge->ops && bridge->ops->set_root_bus_speed)
 		bridge->ops->set_root_bus_speed(bridge);
-	error = pcibios_root_bridge_prepare(bridge);
-	if (error)
-		goto err_out;
 
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 28eafb5..cfaf217 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -424,8 +424,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
 /*
  * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
  * to P2P or CardBus bridge windows) go in a table.  Additional ones (for
-- 
1.7.1


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

* [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use weak pcibios_root_bridge_prepare(),
we could remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   16 +---------------
 include/linux/pci.h |    2 --
 2 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f17e3..1080eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1845,18 +1845,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
- * @bridge: Host bridge to set up.
- *
- * Default empty implementation.  Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	return 0;
-}
-
 void __weak pcibios_add_bus(struct pci_bus *bus)
 {
 }
@@ -1889,11 +1877,9 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+
 	if (bridge->ops && bridge->ops->set_root_bus_speed)
 		bridge->ops->set_root_bus_speed(bridge);
-	error = pcibios_root_bridge_prepare(bridge);
-	if (error)
-		goto err_out;
 
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 28eafb5..cfaf217 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -424,8 +424,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
 /*
  * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
  * to P2P or CardBus bridge windows) go in a table.  Additional ones (for
-- 
1.7.1

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

* [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use weak pcibios_root_bridge_prepare(),
we could remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   16 +---------------
 include/linux/pci.h |    2 --
 2 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f17e3..1080eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1845,18 +1845,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
- * @bridge: Host bridge to set up.
- *
- * Default empty implementation.  Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	return 0;
-}
-
 void __weak pcibios_add_bus(struct pci_bus *bus)
 {
 }
@@ -1889,11 +1877,9 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+
 	if (bridge->ops && bridge->ops->set_root_bus_speed)
 		bridge->ops->set_root_bus_speed(bridge);
-	error = pcibios_root_bridge_prepare(bridge);
-	if (error)
-		goto err_out;
 
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 28eafb5..cfaf217 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -424,8 +424,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
 /*
  * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
  * to P2P or CardBus bridge windows) go in a table.  Additional ones (for
-- 
1.7.1


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

* [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now no one use weak pcibios_root_bridge_prepare(),
we could remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   16 +---------------
 include/linux/pci.h |    2 --
 2 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f17e3..1080eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1845,18 +1845,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
- * @bridge: Host bridge to set up.
- *
- * Default empty implementation.  Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	return 0;
-}
-
 void __weak pcibios_add_bus(struct pci_bus *bus)
 {
 }
@@ -1889,11 +1877,9 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+
 	if (bridge->ops && bridge->ops->set_root_bus_speed)
 		bridge->ops->set_root_bus_speed(bridge);
-	error = pcibios_root_bridge_prepare(bridge);
-	if (error)
-		goto err_out;
 
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 28eafb5..cfaf217 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -424,8 +424,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
 /*
  * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
  * to P2P or CardBus bridge windows) go in a table.  Additional ones (for
-- 
1.7.1

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

* [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use weak pcibios_root_bridge_prepare(),
we could remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   16 +---------------
 include/linux/pci.h |    2 --
 2 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f17e3..1080eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1845,18 +1845,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
- * @bridge: Host bridge to set up.
- *
- * Default empty implementation.  Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	return 0;
-}
-
 void __weak pcibios_add_bus(struct pci_bus *bus)
 {
 }
@@ -1889,11 +1877,9 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+
 	if (bridge->ops && bridge->ops->set_root_bus_speed)
 		bridge->ops->set_root_bus_speed(bridge);
-	error = pcibios_root_bridge_prepare(bridge);
-	if (error)
-		goto err_out;
 
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 28eafb5..cfaf217 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -424,8 +424,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
 /*
  * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
  * to P2P or CardBus bridge windows) go in a table.  Additional ones (for
-- 
1.7.1


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

* [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use weak pcibios_root_bridge_prepare(),
we could remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   16 +---------------
 include/linux/pci.h |    2 --
 2 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f17e3..1080eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1845,18 +1845,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
-/**
- * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
- * @bridge: Host bridge to set up.
- *
- * Default empty implementation.  Replace with an architecture-specific setup
- * routine, if necessary.
- */
-int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
-{
-	return 0;
-}
-
 void __weak pcibios_add_bus(struct pci_bus *bus)
 {
 }
@@ -1889,11 +1877,9 @@ static struct pci_bus *__pci_create_root_bus(
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
+
 	if (bridge->ops && bridge->ops->set_root_bus_speed)
 		bridge->ops->set_root_bus_speed(bridge);
-	error = pcibios_root_bridge_prepare(bridge);
-	if (error)
-		goto err_out;
 
 	device_enable_async_suspend(b->bridge);
 	pci_set_bus_of_node(b);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 28eafb5..cfaf217 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -424,8 +424,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
-
 /*
  * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
  * to P2P or CardBus bridge windows) go in a table.  Additional ones (for
-- 
1.7.1

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

* [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Pci_claim_bus_resources() should be called before
pci_bus_add_devices(), or driver may failed to
load, because the resources had not claimed.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 838fe1e..21f804a 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -678,11 +678,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	}
 
 	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
-
+	pci_bus_add_devices(bus);
 	return bus;
 }
 
-- 
1.7.1


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

* [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices()
  2015-03-09  2:33 ` Yijing Wang
                   ` (38 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Pci_claim_bus_resources() should be called before
pci_bus_add_devices(), or driver may failed to
load, because the resources had not claimed.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 838fe1e..21f804a 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -678,11 +678,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	}
 
 	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
-
+	pci_bus_add_devices(bus);
 	return bus;
 }
 
-- 
1.7.1

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

* [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Pci_claim_bus_resources() should be called before
pci_bus_add_devices(), or driver may failed to
load, because the resources had not claimed.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 838fe1e..21f804a 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -678,11 +678,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	}
 
 	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
-
+	pci_bus_add_devices(bus);
 	return bus;
 }
 
-- 
1.7.1


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

* [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Pci_claim_bus_resources() should be called before
pci_bus_add_devices(), or driver may failed to
load, because the resources had not claimed.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 838fe1e..21f804a 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -678,11 +678,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	}
 
 	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
-
+	pci_bus_add_devices(bus);
 	return bus;
 }
 
-- 
1.7.1

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

* [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Pci_claim_bus_resources() should be called before
pci_bus_add_devices(), or driver may failed to
load, because the resources had not claimed.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 838fe1e..21f804a 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -678,11 +678,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	}
 
 	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
-
+	pci_bus_add_devices(bus);
 	return bus;
 }
 
-- 
1.7.1


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

* [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang

Pci_claim_bus_resources() should be called before
pci_bus_add_devices(), or driver may failed to
load, because the resources had not claimed.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 838fe1e..21f804a 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -678,11 +678,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	}
 
 	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
-
+	pci_bus_add_devices(bus);
 	return bus;
 }
 
-- 
1.7.1


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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	sparclinux, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1


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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                   ` (41 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	sparclinux, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1

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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	sparclinux, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1


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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1


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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux at vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1

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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	sparclinux, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1


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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	sparclinux, Bjorn Helgaas

Now we could use pci_scan_host_bridge() to scan
pci buses, provide sparc specific pci_host_bridge_ops.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 21f804a..7e28f74 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
 		pci_claim_bus_resources(child_bus);
 }
 
+static void pci_host_bridge_of_scan_bus(
+		struct pci_host_bridge *host)
+{
+	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
+	struct device_node *node = pbm->op->dev.of_node;
+
+	pci_of_scan_bus(pbm, node, host->bus);
+}
+
+static struct pci_host_bridge_ops phb_ops = {
+	.scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 				 struct device *parent)
 {
 	LIST_HEAD(resources);
 	struct device_node *node = pbm->op->dev.of_node;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
@@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pbm->busn.end	= pbm->pci_last_busno;
 	pbm->busn.flags	= IORESOURCE_BUS;
 	pci_add_resource(&resources, &pbm->busn);
-	bus = pci_create_root_bus(parent,
+	host = pci_scan_host_bridge(parent,
 			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
-			pbm->pci_ops, pbm, &resources);
-	if (!bus) {
-		printk(KERN_ERR "Failed to create bus for %s\n",
+			pbm->pci_ops, pbm, &resources, &phb_ops);
+	if (!host) {
+		printk(KERN_ERR "Failed to create host bridge for %s\n",
 		       node->full_name);
 		pci_free_resource_list(&resources);
 		return NULL;
 	}
 
-	pci_of_scan_bus(pbm, node, bus);
-	pci_bus_register_of_sysfs(bus);
+	pci_bus_register_of_sysfs(host->bus);
 
-	pci_claim_bus_resources(bus);
-	pci_bus_add_devices(bus);
-	return bus;
+	pci_claim_bus_resources(host->bus);
+	pci_bus_add_devices(host->bus);
+	return host->bus;
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)
-- 
1.7.1


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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas, Fengguang Wu

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(-)

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


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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas, Fengguang Wu

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(-)

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

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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas, Fengguang Wu

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(-)

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


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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

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(-)

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

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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas, Fengguang Wu

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(-)

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


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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas, Fengguang Wu

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(-)

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

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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, James E.J. Bottomley, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Bjorn Helgaas, Thomas Gleixner,
	Yinghai Lu, Yijing Wang, Liviu Dudau, Tony Luck, linux-parisc,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1

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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, James E.J. Bottomley, linux-parisc, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1


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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                   ` (44 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, James E.J. Bottomley, linux-parisc, Bjorn

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1

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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Yijing Wang, James E.J. Bottomley, linux-parisc, Bjorn Helgaas

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1


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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc at vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1

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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, James E.J. Bottomley, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Bjorn Helgaas, Thomas Gleixner,
	Yinghai Lu, Yijing Wang, Liviu Dudau, Tony Luck, linux-parisc,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus -		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1


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

* [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, James E.J. Bottomley, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Bjorn Helgaas, Thomas Gleixner,
	Yinghai Lu, Yijing Wang, Liviu Dudau, Tony Luck, linux-parisc,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

From: Yijing Wang <wangyijing0307@gmail.com>

Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus()
instead of pci_create_root_bus() + pci_scan_child_bus()
for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: "James E.J. Bottomley" <jejb@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c    |    8 +++-----
 drivers/parisc/lba_pci.c |    7 ++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index a0580af..eb76a9d 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -981,11 +981,12 @@ static int __init dino_probe(struct parisc_device *dev)
 	dino_dev->hba.bus_num.end = 255;
 	dino_dev->hba.bus_num.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &dino_dev->hba.bus_num);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+	dino_dev->hba.hba_bus = bus = pci_scan_root_bus(&dev->dev,
 			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +997,10 @@ static int __init dino_probe(struct parisc_device *dev)
 		return 0;
 	}
 
-	max = pci_scan_child_bus(bus);
-	pci_bus_update_busn_res_end(bus, max);
-
 	/* This code *depends* on scanning being single threaded
 	 * if it isn't, this global bus number count will fail
 	 */
-	dino_current_bus = max + 1;
+	dino_current_bus = bus->busn_res.end + 1;
 	pci_bus_assign_resources(bus);
 	pci_bus_add_devices(bus);
 	return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index dceb9dd..ba6daec 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)
 	void *tmp_obj;
 	char *version;
 	void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096);
-	int max;
 
 	/* Read HW Rev First */
 	func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+		pci_scan_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
 				    cfg_ops, NULL, &resources);
 	if (!lba_bus) {
 		pci_free_resource_list(&resources);
 		return 0;
 	}
 
-	max = pci_scan_child_bus(lba_bus);
-
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	lba_next_bus = max + 1;
+	lba_next_bus = pci_bus_child_max_busnr(lba_bus) + 1;
 	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
-- 
1.7.1

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

* [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thomas Petazzoni, Jason Cooper, Bjorn Helgaas

Mvebu_pcie_scan_bus() is not necessary, we could use
pci_common_init_dev() instead of pci_common_init(),
and pass the device pointer as the parent. Then
pci_scan_root_bus() will be called to scan the pci busses.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
-- 
1.7.1


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

* [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thomas Petazzoni, Jason Cooper, Bjorn Helgaas

Mvebu_pcie_scan_bus() is not necessary, we could use
pci_common_init_dev() instead of pci_common_init(),
and pass the device pointer as the parent. Then
pci_scan_root_bus() will be called to scan the pci busses.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
-- 
1.7.1

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

* [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thomas Petazzoni, Jason Cooper, Bjorn Helgaas

Mvebu_pcie_scan_bus() is not necessary, we could use
pci_common_init_dev() instead of pci_common_init(),
and pass the device pointer as the parent. Then
pci_scan_root_bus() will be called to scan the pci busses.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
-- 
1.7.1


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

* [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Mvebu_pcie_scan_bus() is not necessary, we could use
pci_common_init_dev() instead of pci_common_init(),
and pass the device pointer as the parent. Then
pci_scan_root_bus() will be called to scan the pci busses.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
-- 
1.7.1

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

* [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thomas Petazzoni, Jason Cooper, Bjorn Helgaas

Mvebu_pcie_scan_bus() is not necessary, we could use
pci_common_init_dev() instead of pci_common_init(),
and pass the device pointer as the parent. Then
pci_scan_root_bus() will be called to scan the pci busses.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
-- 
1.7.1


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

* [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thomas Petazzoni, Jason Cooper, Bjorn Helgaas

Mvebu_pcie_scan_bus() is not necessary, we could use
pci_common_init_dev() instead of pci_common_init(),
and pass the device pointer as the parent. Then
pci_scan_root_bus() will be called to scan the pci busses.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
-- 
1.7.1

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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: linux-ia64, linux-pci, Bjorn Helgaas, Thierry Reding,
	Yijing Wang, Guan Xuetao, Russell King, x86, Geert Uytterhoeven,
	Benjamin Herrenschmidt, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, linux-tegra, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1

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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thierry Reding, linux-tegra, Bjorn Helgaas

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1


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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  2015-03-09  2:33 ` Yijing Wang
                   ` (46 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thierry Reding, linux-tegra, Bjorn Helgaas

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1

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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Thierry Reding, linux-tegra, Bjorn Helgaas

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1


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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra at vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1

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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: linux-ia64, linux-pci, Bjorn Helgaas, Thierry Reding,
	Yijing Wang, Guan Xuetao, Russell King, x86, Geert Uytterhoeven,
	Benjamin Herrenschmidt, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, linux-tegra, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1


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

* [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Bjorn Helgaas, Thierry Reding,
	Yijing Wang, Guan Xuetao, Russell King, x86, Geert Uytterhoeven,
	Benjamin Herrenschmidt, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, linux-tegra, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

Now pci_scan_root_bus() is almost similar to
pci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() in
pci_common_init_dev() to scan pci busses.
tegra_pcie_scan_bus() is redundant, remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: linux-tegra@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 00e9272..10c0571 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
-- 
1.7.1

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

* [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Mohit Kumar, Jingoo Han, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Mohit Kumar <mohit.kumar@st.com>
CC: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f..658b46b 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-- 
1.7.1


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

* [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity
  2015-03-09  2:33 ` Yijing Wang
                   ` (49 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Mohit Kumar, Jingoo Han, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Mohit Kumar <mohit.kumar@st.com>
CC: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f..658b46b 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-- 
1.7.1

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

* [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Mohit Kumar, Jingoo Han, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Mohit Kumar <mohit.kumar@st.com>
CC: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f..658b46b 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-- 
1.7.1


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

* [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Mohit Kumar <mohit.kumar@st.com>
CC: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f..658b46b 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-- 
1.7.1

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

* [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Mohit Kumar, Jingoo Han, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Mohit Kumar <mohit.kumar@st.com>
CC: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f..658b46b 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-- 
1.7.1


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

* [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Mohit Kumar, Jingoo Han, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Mohit Kumar <mohit.kumar@st.com>
CC: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f..658b46b 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
-- 
1.7.1

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

* [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Tanmay Inamdar, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index aab5547..0c0e632 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
-- 
1.7.1


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

* [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                   ` (51 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Tanmay Inamdar, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index aab5547..0c0e632 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
-- 
1.7.1

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

* [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Tanmay Inamdar, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index aab5547..0c0e632 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
-- 
1.7.1


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

* [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index aab5547..0c0e632 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
-- 
1.7.1

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

* [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Tanmay Inamdar, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index aab5547..0c0e632 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
-- 
1.7.1


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

* [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Tanmay Inamdar, Bjorn Helgaas

Use pci_scan_root_bus() instead of pci_create_root_bus() +
pci_scan_child_bus() for simplicity.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index aab5547..0c0e632 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
-- 
1.7.1


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

* [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use pci_create_root_bus(), we could remove it
and rename __pci_create_root_bus() to pci_create_root_bus().

Signed-off-by: wangyijing@huawei.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   27 ++++++++-------------------
 include/linux/pci.h |    3 ---
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1080eff..196f08a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1853,7 +1853,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-static struct pci_bus *__pci_create_root_bus(
+static struct pci_bus *pci_create_root_bus(
 		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
@@ -1937,18 +1937,6 @@ err_out:
 	return NULL;
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
-	struct pci_host_bridge *host;
-
-	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
-	if (!host)
-		return NULL;
-
-	return __pci_create_root_bus(host, ops);
-}
-
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2026,7 +2014,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops);
+	b = pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2089,18 +2077,19 @@ struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *b;
+	struct pci_host_bridge *host;
 
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
-	if (b) {
-		pci_scan_child_bus(b);
+	host = pci_create_host_bridge(NULL, db, sysdata, &resources, NULL);
+	if (host) {
+		__pci_scan_root_bus(host, ops);
+		return host->bus;
 	} else {
 		pci_free_resource_list(&resources);
 	}
-	return b;
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 261b8de..5717b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -779,9 +779,6 @@ void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
 struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
-				    struct pci_ops *ops, void *sysdata,
-				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-- 
1.7.1


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

* [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
  2015-03-09  2:33 ` Yijing Wang
                   ` (52 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use pci_create_root_bus(), we could remove it
and rename __pci_create_root_bus() to pci_create_root_bus().

Signed-off-by: wangyijing@huawei.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   27 ++++++++-------------------
 include/linux/pci.h |    3 ---
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1080eff..196f08a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1853,7 +1853,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-static struct pci_bus *__pci_create_root_bus(
+static struct pci_bus *pci_create_root_bus(
 		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
@@ -1937,18 +1937,6 @@ err_out:
 	return NULL;
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
-	struct pci_host_bridge *host;
-
-	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
-	if (!host)
-		return NULL;
-
-	return __pci_create_root_bus(host, ops);
-}
-
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2026,7 +2014,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops);
+	b = pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2089,18 +2077,19 @@ struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *b;
+	struct pci_host_bridge *host;
 
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
-	if (b) {
-		pci_scan_child_bus(b);
+	host = pci_create_host_bridge(NULL, db, sysdata, &resources, NULL);
+	if (host) {
+		__pci_scan_root_bus(host, ops);
+		return host->bus;
 	} else {
 		pci_free_resource_list(&resources);
 	}
-	return b;
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 261b8de..5717b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -779,9 +779,6 @@ void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
 struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
-				    struct pci_ops *ops, void *sysdata,
-				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-- 
1.7.1

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

* [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use pci_create_root_bus(), we could remove it
and rename __pci_create_root_bus() to pci_create_root_bus().

Signed-off-by: wangyijing@huawei.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   27 ++++++++-------------------
 include/linux/pci.h |    3 ---
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1080eff..196f08a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1853,7 +1853,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-static struct pci_bus *__pci_create_root_bus(
+static struct pci_bus *pci_create_root_bus(
 		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
@@ -1937,18 +1937,6 @@ err_out:
 	return NULL;
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
-	struct pci_host_bridge *host;
-
-	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
-	if (!host)
-		return NULL;
-
-	return __pci_create_root_bus(host, ops);
-}
-
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2026,7 +2014,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops);
+	b = pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2089,18 +2077,19 @@ struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *b;
+	struct pci_host_bridge *host;
 
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
-	if (b) {
-		pci_scan_child_bus(b);
+	host = pci_create_host_bridge(NULL, db, sysdata, &resources, NULL);
+	if (host) {
+		__pci_scan_root_bus(host, ops);
+		return host->bus;
 	} else {
 		pci_free_resource_list(&resources);
 	}
-	return b;
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 261b8de..5717b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -779,9 +779,6 @@ void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
 struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
-				    struct pci_ops *ops, void *sysdata,
-				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-- 
1.7.1


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

* [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now no one use pci_create_root_bus(), we could remove it
and rename __pci_create_root_bus() to pci_create_root_bus().

Signed-off-by: wangyijing at huawei.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   27 ++++++++-------------------
 include/linux/pci.h |    3 ---
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1080eff..196f08a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1853,7 +1853,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-static struct pci_bus *__pci_create_root_bus(
+static struct pci_bus *pci_create_root_bus(
 		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
@@ -1937,18 +1937,6 @@ err_out:
 	return NULL;
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
-	struct pci_host_bridge *host;
-
-	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
-	if (!host)
-		return NULL;
-
-	return __pci_create_root_bus(host, ops);
-}
-
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2026,7 +2014,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops);
+	b = pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2089,18 +2077,19 @@ struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *b;
+	struct pci_host_bridge *host;
 
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
-	if (b) {
-		pci_scan_child_bus(b);
+	host = pci_create_host_bridge(NULL, db, sysdata, &resources, NULL);
+	if (host) {
+		__pci_scan_root_bus(host, ops);
+		return host->bus;
 	} else {
 		pci_free_resource_list(&resources);
 	}
-	return b;
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 261b8de..5717b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -779,9 +779,6 @@ void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
 struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
-				    struct pci_ops *ops, void *sysdata,
-				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-- 
1.7.1

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

* [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use pci_create_root_bus(), we could remove it
and rename __pci_create_root_bus() to pci_create_root_bus().

Signed-off-by: wangyijing@huawei.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   27 ++++++++-------------------
 include/linux/pci.h |    3 ---
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1080eff..196f08a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1853,7 +1853,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-static struct pci_bus *__pci_create_root_bus(
+static struct pci_bus *pci_create_root_bus(
 		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
@@ -1937,18 +1937,6 @@ err_out:
 	return NULL;
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
-	struct pci_host_bridge *host;
-
-	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
-	if (!host)
-		return NULL;
-
-	return __pci_create_root_bus(host, ops);
-}
-
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2026,7 +2014,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops);
+	b = pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2089,18 +2077,19 @@ struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *b;
+	struct pci_host_bridge *host;
 
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
-	if (b) {
-		pci_scan_child_bus(b);
+	host = pci_create_host_bridge(NULL, db, sysdata, &resources, NULL);
+	if (host) {
+		__pci_scan_root_bus(host, ops);
+		return host->bus;
 	} else {
 		pci_free_resource_list(&resources);
 	}
-	return b;
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 261b8de..5717b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -779,9 +779,6 @@ void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
 struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
-				    struct pci_ops *ops, void *sysdata,
-				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-- 
1.7.1


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

* [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now no one use pci_create_root_bus(), we could remove it
and rename __pci_create_root_bus() to pci_create_root_bus().

Signed-off-by: wangyijing@huawei.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   27 ++++++++-------------------
 include/linux/pci.h |    3 ---
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1080eff..196f08a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1853,7 +1853,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
 {
 }
 
-static struct pci_bus *__pci_create_root_bus(
+static struct pci_bus *pci_create_root_bus(
 		struct pci_host_bridge *bridge, struct pci_ops *ops)
 {
 	int error;
@@ -1937,18 +1937,6 @@ err_out:
 	return NULL;
 }
 
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
-		struct pci_ops *ops, void *sysdata, struct list_head *resources)
-{
-	struct pci_host_bridge *host;
-
-	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
-	if (!host)
-		return NULL;
-
-	return __pci_create_root_bus(host, ops);
-}
-
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
 	struct resource *res = &b->busn_res;
@@ -2026,7 +2014,7 @@ static struct pci_bus *__pci_scan_root_bus(
 			break;
 		}
 
-	b = __pci_create_root_bus(host, ops);
+	b = pci_create_root_bus(host, ops);
 	if (!b) {
 		pci_free_host_bridge(host);
 		return NULL;
@@ -2089,18 +2077,19 @@ struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
 					void *sysdata)
 {
 	LIST_HEAD(resources);
-	struct pci_bus *b;
+	struct pci_host_bridge *host;
 
 	pci_add_resource(&resources, &ioport_resource);
 	pci_add_resource(&resources, &iomem_resource);
 	pci_add_resource(&resources, &busn_resource);
-	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
-	if (b) {
-		pci_scan_child_bus(b);
+	host = pci_create_host_bridge(NULL, db, sysdata, &resources, NULL);
+	if (host) {
+		__pci_scan_root_bus(host, ops);
+		return host->bus;
 	} else {
 		pci_free_resource_list(&resources);
 	}
-	return b;
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 261b8de..5717b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -779,9 +779,6 @@ void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
 struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
-struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
-				    struct pci_ops *ops, void *sysdata,
-				    struct list_head *resources);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
-- 
1.7.1


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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    6 +++---
 drivers/pci/pci.h         |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index bc1de59..51f0a82 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 {
 	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
@@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
@@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a1dc9f2..45252dd 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
 		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
+
 #endif /* DRIVERS_PCI_H */
-- 
1.7.1


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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
  2015-03-09  2:33 ` Yijing Wang
                   ` (54 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    6 +++---
 drivers/pci/pci.h         |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index bc1de59..51f0a82 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 {
 	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
@@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
@@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a1dc9f2..45252dd 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
 		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
+
 #endif /* DRIVERS_PCI_H */
-- 
1.7.1

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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    6 +++---
 drivers/pci/pci.h         |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index bc1de59..51f0a82 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 {
 	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
@@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
@@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a1dc9f2..45252dd 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
 		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
+
 #endif /* DRIVERS_PCI_H */
-- 
1.7.1


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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    6 +++---
 drivers/pci/pci.h         |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index bc1de59..51f0a82 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 {
 	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
@@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
@@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a1dc9f2..45252dd 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
 		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
+
 #endif /* DRIVERS_PCI_H */
-- 
1.7.1

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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    6 +++---
 drivers/pci/pci.h         |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index bc1de59..51f0a82 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 {
 	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
@@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
@@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a1dc9f2..45252dd 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
 		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
+
 #endif /* DRIVERS_PCI_H */
-- 
1.7.1


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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Yijing Wang, Guan Xuetao, Russell King,
	x86, Geert Uytterhoeven, Benjamin Herrenschmidt, Arnd Bergmann,
	Marc Zyngier, Rusty Russell, linux-m68k, Bjorn Helgaas,
	Thomas Gleixner, Yinghai Lu, linux-arm-kernel, Liviu Dudau,
	Tony Luck, linux-kernel, Jiang Liu, linux-alpha, David S. Miller

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host-bridge.c |    6 +++---
 drivers/pci/pci.h         |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index bc1de59..51f0a82 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
 {
 	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
@@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
@@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
+	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
 	struct resource_entry *window;
 	resource_size_t offset = 0;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a1dc9f2..45252dd 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
 		void *sysdata, struct pci_host_bridge_ops *ops);
 
 void pci_free_host_bridge(struct pci_host_bridge *host);
+struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
+
 #endif /* DRIVERS_PCI_H */
-- 
1.7.1

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

* [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr()
  2015-03-09  2:33 ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now pci_host_bridge holds the domain number,
so we could eliminate all platform specific
pci_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/include/asm/pci.h     |    2 --
 arch/ia64/include/asm/pci.h      |    1 -
 arch/microblaze/pci/pci-common.c |   11 -----------
 arch/mips/include/asm/pci.h      |    2 --
 arch/powerpc/kernel/pci-common.c |   11 -----------
 arch/s390/pci/pci.c              |    6 ------
 arch/sh/include/asm/pci.h        |    2 --
 arch/sparc/kernel/pci.c          |   17 -----------------
 arch/tile/include/asm/pci.h      |    2 --
 arch/x86/include/asm/pci.h       |    6 ------
 drivers/pci/pci.c                |    8 ++++++++
 include/linux/pci.h              |    7 ++-----
 12 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index f7f680f..63a9a1e 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 52af5ed..1dcea49 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -99,7 +99,6 @@ struct pci_controller {
 
 
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
-#define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
 extern struct pci_ops pci_root_ops;
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 34a32ec..8651089 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 193b4c6..2e4d808 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 #endif
 
 #ifdef CONFIG_PCI_DOMAINS
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74cbb5d..c0a3aa4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 20e662f..4823b0e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
 	return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
 }
 
-int pci_domain_nr(struct pci_bus *bus)
-{
-	return ((struct zpci_dev *) bus->sysdata)->domain;
-}
-EXPORT_SYMBOL_GPL(pci_domain_nr);
-
 int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 5b45115..4dc3ad6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 /* Board-specific fixup routines. */
 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 
-#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_channel *hose = bus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7e28f74..b847d0c 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -902,23 +902,6 @@ int pcibus_to_node(struct pci_bus *pbus)
 EXPORT_SYMBOL(pcibus_to_node);
 #endif
 
-/* Return the domain number for this pci bus */
-
-int pci_domain_nr(struct pci_bus *pbus)
-{
-	struct pci_pbm_info *pbm = pbus->sysdata;
-	int ret;
-
-	if (!pbm) {
-		ret = -ENXIO;
-	} else {
-		ret = pbm->index;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 #ifdef CONFIG_PCI_MSI
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..23a726e 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -199,8 +199,6 @@ int __init pcibios_init(void);
 
 void pcibios_fixup_bus(struct pci_bus *bus);
 
-#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
-
 /*
  * This decides whether to display the domain number in /proc.
  */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4e370a5..4fe0458 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -29,12 +29,6 @@ extern int noioapicreroute;
 #ifdef CONFIG_PCI
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_sysdata *sd = bus->sysdata;
-	return sd->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0001896..2cf942b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)
 	return atomic_inc_return(&__domain_nr);
 }
 
+int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host = pci_find_host_bridge(bus);
+
+	return host->domain;
+}
+EXPORT_SYMBOL(pci_domain_nr);
+
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
 static int pci_assign_domain_nr(struct device *dev)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5717b14..dc1c710 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1318,6 +1318,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);
 #ifdef CONFIG_PCI_DOMAINS
 extern int pci_domains_supported;
 int pci_get_new_domain_nr(void);
+int pci_domain_nr(struct pci_bus *bus);
 #else
 enum { pci_domains_supported = 0 };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
@@ -1331,15 +1332,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
  * domains then this implementation will be used
  */
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	return bus->domain_nr;
-}
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
-					struct device *parent)
+		struct device *parent)
 {
 }
 static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
-- 
1.7.1


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

* [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now pci_host_bridge holds the domain number,
so we could eliminate all platform specific
pci_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/include/asm/pci.h     |    2 --
 arch/ia64/include/asm/pci.h      |    1 -
 arch/microblaze/pci/pci-common.c |   11 -----------
 arch/mips/include/asm/pci.h      |    2 --
 arch/powerpc/kernel/pci-common.c |   11 -----------
 arch/s390/pci/pci.c              |    6 ------
 arch/sh/include/asm/pci.h        |    2 --
 arch/sparc/kernel/pci.c          |   17 -----------------
 arch/tile/include/asm/pci.h      |    2 --
 arch/x86/include/asm/pci.h       |    6 ------
 drivers/pci/pci.c                |    8 ++++++++
 include/linux/pci.h              |    7 ++-----
 12 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index f7f680f..63a9a1e 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 52af5ed..1dcea49 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -99,7 +99,6 @@ struct pci_controller {
 
 
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
-#define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
 extern struct pci_ops pci_root_ops;
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 34a32ec..8651089 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 193b4c6..2e4d808 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 #endif
 
 #ifdef CONFIG_PCI_DOMAINS
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74cbb5d..c0a3aa4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 20e662f..4823b0e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
 	return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
 }
 
-int pci_domain_nr(struct pci_bus *bus)
-{
-	return ((struct zpci_dev *) bus->sysdata)->domain;
-}
-EXPORT_SYMBOL_GPL(pci_domain_nr);
-
 int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 5b45115..4dc3ad6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 /* Board-specific fixup routines. */
 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 
-#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_channel *hose = bus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7e28f74..b847d0c 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -902,23 +902,6 @@ int pcibus_to_node(struct pci_bus *pbus)
 EXPORT_SYMBOL(pcibus_to_node);
 #endif
 
-/* Return the domain number for this pci bus */
-
-int pci_domain_nr(struct pci_bus *pbus)
-{
-	struct pci_pbm_info *pbm = pbus->sysdata;
-	int ret;
-
-	if (!pbm) {
-		ret = -ENXIO;
-	} else {
-		ret = pbm->index;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 #ifdef CONFIG_PCI_MSI
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..23a726e 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -199,8 +199,6 @@ int __init pcibios_init(void);
 
 void pcibios_fixup_bus(struct pci_bus *bus);
 
-#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
-
 /*
  * This decides whether to display the domain number in /proc.
  */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4e370a5..4fe0458 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -29,12 +29,6 @@ extern int noioapicreroute;
 #ifdef CONFIG_PCI
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_sysdata *sd = bus->sysdata;
-	return sd->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0001896..2cf942b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)
 	return atomic_inc_return(&__domain_nr);
 }
 
+int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host = pci_find_host_bridge(bus);
+
+	return host->domain;
+}
+EXPORT_SYMBOL(pci_domain_nr);
+
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
 static int pci_assign_domain_nr(struct device *dev)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5717b14..dc1c710 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1318,6 +1318,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);
 #ifdef CONFIG_PCI_DOMAINS
 extern int pci_domains_supported;
 int pci_get_new_domain_nr(void);
+int pci_domain_nr(struct pci_bus *bus);
 #else
 enum { pci_domains_supported = 0 };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
@@ -1331,15 +1332,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
  * domains then this implementation will be used
  */
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	return bus->domain_nr;
-}
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
-					struct device *parent)
+		struct device *parent)
 {
 }
 static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
-- 
1.7.1

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

* [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now pci_host_bridge holds the domain number,
so we could eliminate all platform specific
pci_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/include/asm/pci.h     |    2 --
 arch/ia64/include/asm/pci.h      |    1 -
 arch/microblaze/pci/pci-common.c |   11 -----------
 arch/mips/include/asm/pci.h      |    2 --
 arch/powerpc/kernel/pci-common.c |   11 -----------
 arch/s390/pci/pci.c              |    6 ------
 arch/sh/include/asm/pci.h        |    2 --
 arch/sparc/kernel/pci.c          |   17 -----------------
 arch/tile/include/asm/pci.h      |    2 --
 arch/x86/include/asm/pci.h       |    6 ------
 drivers/pci/pci.c                |    8 ++++++++
 include/linux/pci.h              |    7 ++-----
 12 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index f7f680f..63a9a1e 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 52af5ed..1dcea49 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -99,7 +99,6 @@ struct pci_controller {
 
 
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
-#define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
 extern struct pci_ops pci_root_ops;
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 34a32ec..8651089 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 193b4c6..2e4d808 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 #endif
 
 #ifdef CONFIG_PCI_DOMAINS
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74cbb5d..c0a3aa4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 20e662f..4823b0e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
 	return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
 }
 
-int pci_domain_nr(struct pci_bus *bus)
-{
-	return ((struct zpci_dev *) bus->sysdata)->domain;
-}
-EXPORT_SYMBOL_GPL(pci_domain_nr);
-
 int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 5b45115..4dc3ad6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 /* Board-specific fixup routines. */
 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 
-#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_channel *hose = bus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7e28f74..b847d0c 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -902,23 +902,6 @@ int pcibus_to_node(struct pci_bus *pbus)
 EXPORT_SYMBOL(pcibus_to_node);
 #endif
 
-/* Return the domain number for this pci bus */
-
-int pci_domain_nr(struct pci_bus *pbus)
-{
-	struct pci_pbm_info *pbm = pbus->sysdata;
-	int ret;
-
-	if (!pbm) {
-		ret = -ENXIO;
-	} else {
-		ret = pbm->index;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 #ifdef CONFIG_PCI_MSI
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..23a726e 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -199,8 +199,6 @@ int __init pcibios_init(void);
 
 void pcibios_fixup_bus(struct pci_bus *bus);
 
-#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
-
 /*
  * This decides whether to display the domain number in /proc.
  */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4e370a5..4fe0458 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -29,12 +29,6 @@ extern int noioapicreroute;
 #ifdef CONFIG_PCI
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_sysdata *sd = bus->sysdata;
-	return sd->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0001896..2cf942b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)
 	return atomic_inc_return(&__domain_nr);
 }
 
+int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host = pci_find_host_bridge(bus);
+
+	return host->domain;
+}
+EXPORT_SYMBOL(pci_domain_nr);
+
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
 static int pci_assign_domain_nr(struct device *dev)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5717b14..dc1c710 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1318,6 +1318,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);
 #ifdef CONFIG_PCI_DOMAINS
 extern int pci_domains_supported;
 int pci_get_new_domain_nr(void);
+int pci_domain_nr(struct pci_bus *bus);
 #else
 enum { pci_domains_supported = 0 };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
@@ -1331,15 +1332,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
  * domains then this implementation will be used
  */
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	return bus->domain_nr;
-}
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
-					struct device *parent)
+		struct device *parent)
 {
 }
 static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
-- 
1.7.1


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

* [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now pci_host_bridge holds the domain number,
so we could eliminate all platform specific
pci_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/include/asm/pci.h     |    2 --
 arch/ia64/include/asm/pci.h      |    1 -
 arch/microblaze/pci/pci-common.c |   11 -----------
 arch/mips/include/asm/pci.h      |    2 --
 arch/powerpc/kernel/pci-common.c |   11 -----------
 arch/s390/pci/pci.c              |    6 ------
 arch/sh/include/asm/pci.h        |    2 --
 arch/sparc/kernel/pci.c          |   17 -----------------
 arch/tile/include/asm/pci.h      |    2 --
 arch/x86/include/asm/pci.h       |    6 ------
 drivers/pci/pci.c                |    8 ++++++++
 include/linux/pci.h              |    7 ++-----
 12 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index f7f680f..63a9a1e 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 52af5ed..1dcea49 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -99,7 +99,6 @@ struct pci_controller {
 
 
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
-#define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
 extern struct pci_ops pci_root_ops;
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 34a32ec..8651089 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 193b4c6..2e4d808 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 #endif
 
 #ifdef CONFIG_PCI_DOMAINS
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74cbb5d..c0a3aa4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 20e662f..4823b0e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
 	return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
 }
 
-int pci_domain_nr(struct pci_bus *bus)
-{
-	return ((struct zpci_dev *) bus->sysdata)->domain;
-}
-EXPORT_SYMBOL_GPL(pci_domain_nr);
-
 int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 5b45115..4dc3ad6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 /* Board-specific fixup routines. */
 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 
-#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_channel *hose = bus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7e28f74..b847d0c 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -902,23 +902,6 @@ int pcibus_to_node(struct pci_bus *pbus)
 EXPORT_SYMBOL(pcibus_to_node);
 #endif
 
-/* Return the domain number for this pci bus */
-
-int pci_domain_nr(struct pci_bus *pbus)
-{
-	struct pci_pbm_info *pbm = pbus->sysdata;
-	int ret;
-
-	if (!pbm) {
-		ret = -ENXIO;
-	} else {
-		ret = pbm->index;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 #ifdef CONFIG_PCI_MSI
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..23a726e 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -199,8 +199,6 @@ int __init pcibios_init(void);
 
 void pcibios_fixup_bus(struct pci_bus *bus);
 
-#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
-
 /*
  * This decides whether to display the domain number in /proc.
  */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4e370a5..4fe0458 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -29,12 +29,6 @@ extern int noioapicreroute;
 #ifdef CONFIG_PCI
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_sysdata *sd = bus->sysdata;
-	return sd->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0001896..2cf942b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)
 	return atomic_inc_return(&__domain_nr);
 }
 
+int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host = pci_find_host_bridge(bus);
+
+	return host->domain;
+}
+EXPORT_SYMBOL(pci_domain_nr);
+
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
 static int pci_assign_domain_nr(struct device *dev)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5717b14..dc1c710 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1318,6 +1318,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);
 #ifdef CONFIG_PCI_DOMAINS
 extern int pci_domains_supported;
 int pci_get_new_domain_nr(void);
+int pci_domain_nr(struct pci_bus *bus);
 #else
 enum { pci_domains_supported = 0 };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
@@ -1331,15 +1332,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
  * domains then this implementation will be used
  */
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	return bus->domain_nr;
-}
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
-					struct device *parent)
+		struct device *parent)
 {
 }
 static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
-- 
1.7.1

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

* [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now pci_host_bridge holds the domain number,
so we could eliminate all platform specific
pci_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/include/asm/pci.h     |    2 --
 arch/ia64/include/asm/pci.h      |    1 -
 arch/microblaze/pci/pci-common.c |   11 -----------
 arch/mips/include/asm/pci.h      |    2 --
 arch/powerpc/kernel/pci-common.c |   11 -----------
 arch/s390/pci/pci.c              |    6 ------
 arch/sh/include/asm/pci.h        |    2 --
 arch/sparc/kernel/pci.c          |   17 -----------------
 arch/tile/include/asm/pci.h      |    2 --
 arch/x86/include/asm/pci.h       |    6 ------
 drivers/pci/pci.c                |    8 ++++++++
 include/linux/pci.h              |    7 ++-----
 12 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index f7f680f..63a9a1e 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 52af5ed..1dcea49 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -99,7 +99,6 @@ struct pci_controller {
 
 
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
-#define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
 extern struct pci_ops pci_root_ops;
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 34a32ec..8651089 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 193b4c6..2e4d808 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 #endif
 
 #ifdef CONFIG_PCI_DOMAINS
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74cbb5d..c0a3aa4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 20e662f..4823b0e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
 	return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
 }
 
-int pci_domain_nr(struct pci_bus *bus)
-{
-	return ((struct zpci_dev *) bus->sysdata)->domain;
-}
-EXPORT_SYMBOL_GPL(pci_domain_nr);
-
 int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 5b45115..4dc3ad6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 /* Board-specific fixup routines. */
 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 
-#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_channel *hose = bus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7e28f74..b847d0c 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -902,23 +902,6 @@ int pcibus_to_node(struct pci_bus *pbus)
 EXPORT_SYMBOL(pcibus_to_node);
 #endif
 
-/* Return the domain number for this pci bus */
-
-int pci_domain_nr(struct pci_bus *pbus)
-{
-	struct pci_pbm_info *pbm = pbus->sysdata;
-	int ret;
-
-	if (!pbm) {
-		ret = -ENXIO;
-	} else {
-		ret = pbm->index;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 #ifdef CONFIG_PCI_MSI
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..23a726e 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -199,8 +199,6 @@ int __init pcibios_init(void);
 
 void pcibios_fixup_bus(struct pci_bus *bus);
 
-#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
-
 /*
  * This decides whether to display the domain number in /proc.
  */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4e370a5..4fe0458 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -29,12 +29,6 @@ extern int noioapicreroute;
 #ifdef CONFIG_PCI
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_sysdata *sd = bus->sysdata;
-	return sd->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0001896..2cf942b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)
 	return atomic_inc_return(&__domain_nr);
 }
 
+int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host = pci_find_host_bridge(bus);
+
+	return host->domain;
+}
+EXPORT_SYMBOL(pci_domain_nr);
+
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
 static int pci_assign_domain_nr(struct device *dev)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5717b14..dc1c710 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1318,6 +1318,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);
 #ifdef CONFIG_PCI_DOMAINS
 extern int pci_domains_supported;
 int pci_get_new_domain_nr(void);
+int pci_domain_nr(struct pci_bus *bus);
 #else
 enum { pci_domains_supported = 0 };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
@@ -1331,15 +1332,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
  * domains then this implementation will be used
  */
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	return bus->domain_nr;
-}
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
-					struct device *parent)
+		struct device *parent)
 {
 }
 static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
-- 
1.7.1


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

* [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now pci_host_bridge holds the domain number,
so we could eliminate all platform specific
pci_domain_nr().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/include/asm/pci.h     |    2 --
 arch/ia64/include/asm/pci.h      |    1 -
 arch/microblaze/pci/pci-common.c |   11 -----------
 arch/mips/include/asm/pci.h      |    2 --
 arch/powerpc/kernel/pci-common.c |   11 -----------
 arch/s390/pci/pci.c              |    6 ------
 arch/sh/include/asm/pci.h        |    2 --
 arch/sparc/kernel/pci.c          |   17 -----------------
 arch/tile/include/asm/pci.h      |    2 --
 arch/x86/include/asm/pci.h       |    6 ------
 drivers/pci/pci.c                |    8 ++++++++
 include/linux/pci.h              |    7 ++-----
 12 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index f7f680f..63a9a1e 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 52af5ed..1dcea49 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -99,7 +99,6 @@ struct pci_controller {
 
 
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
-#define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
 extern struct pci_ops pci_root_ops;
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 34a32ec..8651089 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 193b4c6..2e4d808 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 #endif
 
 #ifdef CONFIG_PCI_DOMAINS
-#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_controller *hose = bus->sysdata;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74cbb5d..c0a3aa4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address)
 }
 EXPORT_SYMBOL_GPL(pci_address_to_pio);
 
-/*
- * Return the domain number for this bus.
- */
-int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_controller *hose = pci_bus_to_host(bus);
-
-	return hose->global_number;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 /* This routine is meant to be used early during boot, when the
  * PCI bus numbers have not yet been assigned, and you need to
  * issue PCI config cycles to an OF device.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 20e662f..4823b0e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
 	return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
 }
 
-int pci_domain_nr(struct pci_bus *bus)
-{
-	return ((struct zpci_dev *) bus->sysdata)->domain;
-}
-EXPORT_SYMBOL_GPL(pci_domain_nr);
-
 int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 5b45115..4dc3ad6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 /* Board-specific fixup routines. */
 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 
-#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	struct pci_channel *hose = bus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7e28f74..b847d0c 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -902,23 +902,6 @@ int pcibus_to_node(struct pci_bus *pbus)
 EXPORT_SYMBOL(pcibus_to_node);
 #endif
 
-/* Return the domain number for this pci bus */
-
-int pci_domain_nr(struct pci_bus *pbus)
-{
-	struct pci_pbm_info *pbm = pbus->sysdata;
-	int ret;
-
-	if (!pbm) {
-		ret = -ENXIO;
-	} else {
-		ret = pbm->index;
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(pci_domain_nr);
-
 #ifdef CONFIG_PCI_MSI
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..23a726e 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -199,8 +199,6 @@ int __init pcibios_init(void);
 
 void pcibios_fixup_bus(struct pci_bus *bus);
 
-#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
-
 /*
  * This decides whether to display the domain number in /proc.
  */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4e370a5..4fe0458 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -29,12 +29,6 @@ extern int noioapicreroute;
 #ifdef CONFIG_PCI
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	struct pci_sysdata *sd = bus->sysdata;
-	return sd->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return pci_domain_nr(bus);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0001896..2cf942b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)
 	return atomic_inc_return(&__domain_nr);
 }
 
+int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host = pci_find_host_bridge(bus);
+
+	return host->domain;
+}
+EXPORT_SYMBOL(pci_domain_nr);
+
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
 static int pci_assign_domain_nr(struct device *dev)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5717b14..dc1c710 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1318,6 +1318,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);
 #ifdef CONFIG_PCI_DOMAINS
 extern int pci_domains_supported;
 int pci_get_new_domain_nr(void);
+int pci_domain_nr(struct pci_bus *bus);
 #else
 enum { pci_domains_supported = 0 };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
@@ -1331,15 +1332,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
  * domains then this implementation will be used
  */
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-	return bus->domain_nr;
-}
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_host_assign_domain_nr(struct pci_host_bridge *host);
 #else
 static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
-					struct device *parent)
+		struct device *parent)
 {
 }
 static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
-- 
1.7.1

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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
  2015-03-09  2:33 ` Yijing Wang
                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-09  2:34   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |    5 -----
 drivers/pci/probe.c |   12 ++++--------
 include/linux/pci.h |    3 ---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2cf942b..4d8dfe4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
 {
 	host->domain = pci_assign_domain_nr(host->dev.parent);
 }
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-	bus->domain_nr = pci_assign_domain_nr(parent);
-}
 #endif
 #endif
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 196f08a..9cd3ca2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 	}
 }
 
-static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
+static struct pci_bus *pci_alloc_bus(void)
 {
 	struct pci_bus *b;
 
@@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	INIT_LIST_HEAD(&b->resources);
 	b->max_bus_speed = PCI_SPEED_UNKNOWN;
 	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	if (parent)
-		b->domain_nr = parent->domain_nr;
-#endif
+
 	return b;
 }
 
@@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
 	 */
-	child = pci_alloc_bus(parent);
+	child = pci_alloc_bus();
 	if (!child)
 		return NULL;
 
@@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
 	char *fmt;
 
 	parent = bridge->dev.parent;
-	b = pci_alloc_bus(NULL);
+	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
-	pci_bus_assign_domain_nr(b, parent);
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dc1c710..ebc70bb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -467,9 +467,6 @@ struct pci_bus {
 	unsigned char	primary;	/* number of primary bridge */
 	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
 	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	int		domain_nr;
-#endif
 
 	char		name[48];
 
-- 
1.7.1


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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
  2015-03-09  2:33 ` Yijing Wang
                   ` (58 preceding siblings ...)
  (?)
@ 2015-03-09  2:34 ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |    5 -----
 drivers/pci/probe.c |   12 ++++--------
 include/linux/pci.h |    3 ---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2cf942b..4d8dfe4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
 {
 	host->domain = pci_assign_domain_nr(host->dev.parent);
 }
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-	bus->domain_nr = pci_assign_domain_nr(parent);
-}
 #endif
 #endif
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 196f08a..9cd3ca2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 	}
 }
 
-static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
+static struct pci_bus *pci_alloc_bus(void)
 {
 	struct pci_bus *b;
 
@@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	INIT_LIST_HEAD(&b->resources);
 	b->max_bus_speed = PCI_SPEED_UNKNOWN;
 	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	if (parent)
-		b->domain_nr = parent->domain_nr;
-#endif
+
 	return b;
 }
 
@@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
 	 */
-	child = pci_alloc_bus(parent);
+	child = pci_alloc_bus();
 	if (!child)
 		return NULL;
 
@@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
 	char *fmt;
 
 	parent = bridge->dev.parent;
-	b = pci_alloc_bus(NULL);
+	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
-	pci_bus_assign_domain_nr(b, parent);
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dc1c710..ebc70bb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -467,9 +467,6 @@ struct pci_bus {
 	unsigned char	primary;	/* number of primary bridge */
 	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
 	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	int		domain_nr;
-#endif
 
 	char		name[48];
 
-- 
1.7.1

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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |    5 -----
 drivers/pci/probe.c |   12 ++++--------
 include/linux/pci.h |    3 ---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2cf942b..4d8dfe4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
 {
 	host->domain = pci_assign_domain_nr(host->dev.parent);
 }
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-	bus->domain_nr = pci_assign_domain_nr(parent);
-}
 #endif
 #endif
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 196f08a..9cd3ca2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 	}
 }
 
-static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
+static struct pci_bus *pci_alloc_bus(void)
 {
 	struct pci_bus *b;
 
@@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	INIT_LIST_HEAD(&b->resources);
 	b->max_bus_speed = PCI_SPEED_UNKNOWN;
 	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	if (parent)
-		b->domain_nr = parent->domain_nr;
-#endif
+
 	return b;
 }
 
@@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
 	 */
-	child = pci_alloc_bus(parent);
+	child = pci_alloc_bus();
 	if (!child)
 		return NULL;
 
@@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
 	char *fmt;
 
 	parent = bridge->dev.parent;
-	b = pci_alloc_bus(NULL);
+	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
-	pci_bus_assign_domain_nr(b, parent);
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dc1c710..ebc70bb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -467,9 +467,6 @@ struct pci_bus {
 	unsigned char	primary;	/* number of primary bridge */
 	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
 	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	int		domain_nr;
-#endif
 
 	char		name[48];
 
-- 
1.7.1


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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |    5 -----
 drivers/pci/probe.c |   12 ++++--------
 include/linux/pci.h |    3 ---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2cf942b..4d8dfe4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
 {
 	host->domain = pci_assign_domain_nr(host->dev.parent);
 }
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-	bus->domain_nr = pci_assign_domain_nr(parent);
-}
 #endif
 #endif
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 196f08a..9cd3ca2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 	}
 }
 
-static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
+static struct pci_bus *pci_alloc_bus(void)
 {
 	struct pci_bus *b;
 
@@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	INIT_LIST_HEAD(&b->resources);
 	b->max_bus_speed = PCI_SPEED_UNKNOWN;
 	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	if (parent)
-		b->domain_nr = parent->domain_nr;
-#endif
+
 	return b;
 }
 
@@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
 	 */
-	child = pci_alloc_bus(parent);
+	child = pci_alloc_bus();
 	if (!child)
 		return NULL;
 
@@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
 	char *fmt;
 
 	parent = bridge->dev.parent;
-	b = pci_alloc_bus(NULL);
+	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
-	pci_bus_assign_domain_nr(b, parent);
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dc1c710..ebc70bb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -467,9 +467,6 @@ struct pci_bus {
 	unsigned char	primary;	/* number of primary bridge */
 	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
 	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	int		domain_nr;
-#endif
 
 	char		name[48];
 
-- 
1.7.1

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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |    5 -----
 drivers/pci/probe.c |   12 ++++--------
 include/linux/pci.h |    3 ---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2cf942b..4d8dfe4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
 {
 	host->domain = pci_assign_domain_nr(host->dev.parent);
 }
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-	bus->domain_nr = pci_assign_domain_nr(parent);
-}
 #endif
 #endif
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 196f08a..9cd3ca2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 	}
 }
 
-static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
+static struct pci_bus *pci_alloc_bus(void)
 {
 	struct pci_bus *b;
 
@@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	INIT_LIST_HEAD(&b->resources);
 	b->max_bus_speed = PCI_SPEED_UNKNOWN;
 	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	if (parent)
-		b->domain_nr = parent->domain_nr;
-#endif
+
 	return b;
 }
 
@@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
 	 */
-	child = pci_alloc_bus(parent);
+	child = pci_alloc_bus();
 	if (!child)
 		return NULL;
 
@@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
 	char *fmt;
 
 	parent = bridge->dev.parent;
-	b = pci_alloc_bus(NULL);
+	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
-	pci_bus_assign_domain_nr(b, parent);
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dc1c710..ebc70bb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -467,9 +467,6 @@ struct pci_bus {
 	unsigned char	primary;	/* number of primary bridge */
 	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
 	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	int		domain_nr;
-#endif
 
 	char		name[48];
 
-- 
1.7.1


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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-09  2:34   ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-09  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Yijing Wang,
	Bjorn Helgaas

Now we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c   |    5 -----
 drivers/pci/probe.c |   12 ++++--------
 include/linux/pci.h |    3 ---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2cf942b..4d8dfe4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
 {
 	host->domain = pci_assign_domain_nr(host->dev.parent);
 }
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-	bus->domain_nr = pci_assign_domain_nr(parent);
-}
 #endif
 #endif
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 196f08a..9cd3ca2 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 	}
 }
 
-static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
+static struct pci_bus *pci_alloc_bus(void)
 {
 	struct pci_bus *b;
 
@@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
 	INIT_LIST_HEAD(&b->resources);
 	b->max_bus_speed = PCI_SPEED_UNKNOWN;
 	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	if (parent)
-		b->domain_nr = parent->domain_nr;
-#endif
+
 	return b;
 }
 
@@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
 	 */
-	child = pci_alloc_bus(parent);
+	child = pci_alloc_bus();
 	if (!child)
 		return NULL;
 
@@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
 	char *fmt;
 
 	parent = bridge->dev.parent;
-	b = pci_alloc_bus(NULL);
+	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = dev_get_drvdata(&bridge->dev);
 	b->ops = ops;
 	b->number = b->busn_res.start = bridge->busnum;
-	pci_bus_assign_domain_nr(b, parent);
 
 	bridge->bus = b;
 	b->bridge = get_device(&bridge->dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dc1c710..ebc70bb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -467,9 +467,6 @@ struct pci_bus {
 	unsigned char	primary;	/* number of primary bridge */
 	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
 	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-	int		domain_nr;
-#endif
 
 	char		name[48];
 
-- 
1.7.1

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-11 22:28     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:28 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:00AM +0800, Yijing Wang wrote:
> Export out busn_resource. Xen pcifront module need it.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/pci.h   |    2 ++
>  drivers/pci/probe.c |    3 ++-
>  2 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4091f82..eeacab9 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
>  
>  /* Functions internal to the PCI core code */
>  
> +extern struct resource busn_resource;
> +
>  int pci_create_sysfs_dev_files(struct pci_dev *pdev);
>  void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
>  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8ef0375..b97ea81 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -17,12 +17,13 @@
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
>  #define CARDBUS_RESERVE_BUSNR	3
>  
> -static struct resource busn_resource = {
> +struct resource busn_resource = {
>  	.name	= "PCI busn",
>  	.start	= 0,
>  	.end	= 255,
>  	.flags	= IORESOURCE_BUS,
>  };
> +EXPORT_SYMBOL(busn_resource);

I don't think this is a good idea.  We support multiple PCI domains, and
each domain has its own 0-255 bus number range.  This busn_resource is
only for domain 0 and probably should be handled in arch code instead of
the PCI core.

Right now, I think it's possible to call pci_scan_bus_parented() or
pci_scan_bus() several times for buses in different domains, and they would
all share the same busn_resource, which would cause corruption.

So it's already broken, but I don't want to make it harder to fix by
exporting this stuff.

>  
>  /* Ugh.  Need to stop exporting this to modules. */
>  LIST_HEAD(pci_root_buses);
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-11 22:28   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:28 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:00AM +0800, Yijing Wang wrote:
> Export out busn_resource. Xen pcifront module need it.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/pci.h   |    2 ++
>  drivers/pci/probe.c |    3 ++-
>  2 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4091f82..eeacab9 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
>  
>  /* Functions internal to the PCI core code */
>  
> +extern struct resource busn_resource;
> +
>  int pci_create_sysfs_dev_files(struct pci_dev *pdev);
>  void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
>  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8ef0375..b97ea81 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -17,12 +17,13 @@
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
>  #define CARDBUS_RESERVE_BUSNR	3
>  
> -static struct resource busn_resource = {
> +struct resource busn_resource = {
>  	.name	= "PCI busn",
>  	.start	= 0,
>  	.end	= 255,
>  	.flags	= IORESOURCE_BUS,
>  };
> +EXPORT_SYMBOL(busn_resource);

I don't think this is a good idea.  We support multiple PCI domains, and
each domain has its own 0-255 bus number range.  This busn_resource is
only for domain 0 and probably should be handled in arch code instead of
the PCI core.

Right now, I think it's possible to call pci_scan_bus_parented() or
pci_scan_bus() several times for buses in different domains, and they would
all share the same busn_resource, which would cause corruption.

So it's already broken, but I don't want to make it harder to fix by
exporting this stuff.

>  
>  /* Ugh.  Need to stop exporting this to modules. */
>  LIST_HEAD(pci_root_buses);
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-11 22:28     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:28 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:00AM +0800, Yijing Wang wrote:
> Export out busn_resource. Xen pcifront module need it.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/pci.h   |    2 ++
>  drivers/pci/probe.c |    3 ++-
>  2 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4091f82..eeacab9 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
>  
>  /* Functions internal to the PCI core code */
>  
> +extern struct resource busn_resource;
> +
>  int pci_create_sysfs_dev_files(struct pci_dev *pdev);
>  void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
>  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8ef0375..b97ea81 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -17,12 +17,13 @@
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
>  #define CARDBUS_RESERVE_BUSNR	3
>  
> -static struct resource busn_resource = {
> +struct resource busn_resource = {
>  	.name	= "PCI busn",
>  	.start	= 0,
>  	.end	= 255,
>  	.flags	= IORESOURCE_BUS,
>  };
> +EXPORT_SYMBOL(busn_resource);

I don't think this is a good idea.  We support multiple PCI domains, and
each domain has its own 0-255 bus number range.  This busn_resource is
only for domain 0 and probably should be handled in arch code instead of
the PCI core.

Right now, I think it's possible to call pci_scan_bus_parented() or
pci_scan_bus() several times for buses in different domains, and they would
all share the same busn_resource, which would cause corruption.

So it's already broken, but I don't want to make it harder to fix by
exporting this stuff.

>  
>  /* Ugh.  Need to stop exporting this to modules. */
>  LIST_HEAD(pci_root_buses);
> -- 
> 1.7.1
> 

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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-11 22:28     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:00AM +0800, Yijing Wang wrote:
> Export out busn_resource. Xen pcifront module need it.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/pci.h   |    2 ++
>  drivers/pci/probe.c |    3 ++-
>  2 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4091f82..eeacab9 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
>  
>  /* Functions internal to the PCI core code */
>  
> +extern struct resource busn_resource;
> +
>  int pci_create_sysfs_dev_files(struct pci_dev *pdev);
>  void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
>  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8ef0375..b97ea81 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -17,12 +17,13 @@
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
>  #define CARDBUS_RESERVE_BUSNR	3
>  
> -static struct resource busn_resource = {
> +struct resource busn_resource = {
>  	.name	= "PCI busn",
>  	.start	= 0,
>  	.end	= 255,
>  	.flags	= IORESOURCE_BUS,
>  };
> +EXPORT_SYMBOL(busn_resource);

I don't think this is a good idea.  We support multiple PCI domains, and
each domain has its own 0-255 bus number range.  This busn_resource is
only for domain 0 and probably should be handled in arch code instead of
the PCI core.

Right now, I think it's possible to call pci_scan_bus_parented() or
pci_scan_bus() several times for buses in different domains, and they would
all share the same busn_resource, which would cause corruption.

So it's already broken, but I don't want to make it harder to fix by
exporting this stuff.

>  
>  /* Ugh.  Need to stop exporting this to modules. */
>  LIST_HEAD(pci_root_buses);
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-11 22:28     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:28 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:00AM +0800, Yijing Wang wrote:
> Export out busn_resource. Xen pcifront module need it.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
>  drivers/pci/pci.h   |    2 ++
>  drivers/pci/probe.c |    3 ++-
>  2 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4091f82..eeacab9 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -10,6 +10,8 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
>  
>  /* Functions internal to the PCI core code */
>  
> +extern struct resource busn_resource;
> +
>  int pci_create_sysfs_dev_files(struct pci_dev *pdev);
>  void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
>  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8ef0375..b97ea81 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -17,12 +17,13 @@
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
>  #define CARDBUS_RESERVE_BUSNR	3
>  
> -static struct resource busn_resource = {
> +struct resource busn_resource = {
>  	.name	= "PCI busn",
>  	.start	= 0,
>  	.end	= 255,
>  	.flags	= IORESOURCE_BUS,
>  };
> +EXPORT_SYMBOL(busn_resource);

I don't think this is a good idea.  We support multiple PCI domains, and
each domain has its own 0-255 bus number range.  This busn_resource is
only for domain 0 and probably should be handled in arch code instead of
the PCI core.

Right now, I think it's possible to call pci_scan_bus_parented() or
pci_scan_bus() several times for buses in different domains, and they would
all share the same busn_resource, which would cause corruption.

So it's already broken, but I don't want to make it harder to fix by
exporting this stuff.

>  
>  /* Ugh.  Need to stop exporting this to modules. */
>  LIST_HEAD(pci_root_buses);
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-11 22:32     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Mon, Mar 09, 2015 at 10:34:01AM +0800, Yijing Wang wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Use pci_scan_root_bus() instead of deprecated function
> pci_scan_bus_parented().
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/xen-pcifront.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..9e7c28b 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -21,6 +21,7 @@
>  #include <linux/bitops.h>
>  #include <linux/time.h>
>  #include <xen/platform_pci.h>
> +#include "pci.h"
>  
>  #include <asm/xen/swiotlb-xen.h>
>  #define INVALID_GRANT_REF (0)
> @@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  				 unsigned int domain, unsigned int bus)
>  {
>  	struct pci_bus *b;
> +	LIST_HEAD(resources);
>  	struct pcifront_sd *sd = NULL;
>  	struct pci_bus_entry *bus_entry = NULL;
>  	int err = 0;
> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> +	pci_add_resource(&resources, &ioport_resource);
> +	pci_add_resource(&resources, &iomem_resource);
> +	pci_add_resource(&resources, &busn_resource);

Since I don't want to export busn_resource, you might have to allocate your
own struct resource for it here.  And, of course, figure out the details of
which PCI domain you're in and whether you need to share one struct
resource across several host bridges in the same domain.

>  	pcifront_init_sd(sd, domain, bus, pdev);
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd);
> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +				  &pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
>  		err = -ENOMEM;
>  		pci_unlock_rescan_remove();
> +		pci_free_resource_list(&resources);
>  		goto err_out;
>  	}
>  
> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	list_add(&bus_entry->list, &pdev->root_buses);
>  
> -	/* pci_scan_bus_parented skips devices which do not have a have
> +	/* pci_scan_root_bus skips devices which do not have a
>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>  
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-09  2:34   ` Yijing Wang
                     ` (4 preceding siblings ...)
  (?)
@ 2015-03-11 22:32   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Mon, Mar 09, 2015 at 10:34:01AM +0800, Yijing Wang wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Use pci_scan_root_bus() instead of deprecated function
> pci_scan_bus_parented().
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/xen-pcifront.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..9e7c28b 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -21,6 +21,7 @@
>  #include <linux/bitops.h>
>  #include <linux/time.h>
>  #include <xen/platform_pci.h>
> +#include "pci.h"
>  
>  #include <asm/xen/swiotlb-xen.h>
>  #define INVALID_GRANT_REF (0)
> @@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  				 unsigned int domain, unsigned int bus)
>  {
>  	struct pci_bus *b;
> +	LIST_HEAD(resources);
>  	struct pcifront_sd *sd = NULL;
>  	struct pci_bus_entry *bus_entry = NULL;
>  	int err = 0;
> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> +	pci_add_resource(&resources, &ioport_resource);
> +	pci_add_resource(&resources, &iomem_resource);
> +	pci_add_resource(&resources, &busn_resource);

Since I don't want to export busn_resource, you might have to allocate your
own struct resource for it here.  And, of course, figure out the details of
which PCI domain you're in and whether you need to share one struct
resource across several host bridges in the same domain.

>  	pcifront_init_sd(sd, domain, bus, pdev);
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd);
> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +				  &pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
>  		err = -ENOMEM;
>  		pci_unlock_rescan_remove();
> +		pci_free_resource_list(&resources);
>  		goto err_out;
>  	}
>  
> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	list_add(&bus_entry->list, &pdev->root_buses);
>  
> -	/* pci_scan_bus_parented skips devices which do not have a have
> +	/* pci_scan_root_bus skips devices which do not have a
>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>  
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-11 22:32     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Mon, Mar 09, 2015 at 10:34:01AM +0800, Yijing Wang wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Use pci_scan_root_bus() instead of deprecated function
> pci_scan_bus_parented().
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/xen-pcifront.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..9e7c28b 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -21,6 +21,7 @@
>  #include <linux/bitops.h>
>  #include <linux/time.h>
>  #include <xen/platform_pci.h>
> +#include "pci.h"
>  
>  #include <asm/xen/swiotlb-xen.h>
>  #define INVALID_GRANT_REF (0)
> @@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  				 unsigned int domain, unsigned int bus)
>  {
>  	struct pci_bus *b;
> +	LIST_HEAD(resources);
>  	struct pcifront_sd *sd = NULL;
>  	struct pci_bus_entry *bus_entry = NULL;
>  	int err = 0;
> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> +	pci_add_resource(&resources, &ioport_resource);
> +	pci_add_resource(&resources, &iomem_resource);
> +	pci_add_resource(&resources, &busn_resource);

Since I don't want to export busn_resource, you might have to allocate your
own struct resource for it here.  And, of course, figure out the details of
which PCI domain you're in and whether you need to share one struct
resource across several host bridges in the same domain.

>  	pcifront_init_sd(sd, domain, bus, pdev);
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd);
> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +				  &pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
>  		err = -ENOMEM;
>  		pci_unlock_rescan_remove();
> +		pci_free_resource_list(&resources);
>  		goto err_out;
>  	}
>  
> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	list_add(&bus_entry->list, &pdev->root_buses);
>  
> -	/* pci_scan_bus_parented skips devices which do not have a have
> +	/* pci_scan_root_bus skips devices which do not have a
>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>  
> -- 
> 1.7.1
> 
> --
> 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

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-11 22:32     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:01AM +0800, Yijing Wang wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Use pci_scan_root_bus() instead of deprecated function
> pci_scan_bus_parented().
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: xen-devel at lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/xen-pcifront.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..9e7c28b 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -21,6 +21,7 @@
>  #include <linux/bitops.h>
>  #include <linux/time.h>
>  #include <xen/platform_pci.h>
> +#include "pci.h"
>  
>  #include <asm/xen/swiotlb-xen.h>
>  #define INVALID_GRANT_REF (0)
> @@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  				 unsigned int domain, unsigned int bus)
>  {
>  	struct pci_bus *b;
> +	LIST_HEAD(resources);
>  	struct pcifront_sd *sd = NULL;
>  	struct pci_bus_entry *bus_entry = NULL;
>  	int err = 0;
> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> +	pci_add_resource(&resources, &ioport_resource);
> +	pci_add_resource(&resources, &iomem_resource);
> +	pci_add_resource(&resources, &busn_resource);

Since I don't want to export busn_resource, you might have to allocate your
own struct resource for it here.  And, of course, figure out the details of
which PCI domain you're in and whether you need to share one struct
resource across several host bridges in the same domain.

>  	pcifront_init_sd(sd, domain, bus, pdev);
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd);
> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +				  &pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
>  		err = -ENOMEM;
>  		pci_unlock_rescan_remove();
> +		pci_free_resource_list(&resources);
>  		goto err_out;
>  	}
>  
> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	list_add(&bus_entry->list, &pdev->root_buses);
>  
> -	/* pci_scan_bus_parented skips devices which do not have a have
> +	/* pci_scan_root_bus skips devices which do not have a
>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>  
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-11 22:32   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: linux-ia64, linux-pci, Guan Xuetao, Russell King, x86,
	Geert Uytterhoeven, Benjamin Herrenschmidt, xen-devel,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Thomas Gleixner, Yinghai Lu, linux-arm-kernel, Liviu Dudau,
	Tony Luck, linux-kernel, Jiang Liu, linux-alpha, David S. Miller

On Mon, Mar 09, 2015 at 10:34:01AM +0800, Yijing Wang wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Use pci_scan_root_bus() instead of deprecated function
> pci_scan_bus_parented().
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/xen-pcifront.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..9e7c28b 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -21,6 +21,7 @@
>  #include <linux/bitops.h>
>  #include <linux/time.h>
>  #include <xen/platform_pci.h>
> +#include "pci.h"
>  
>  #include <asm/xen/swiotlb-xen.h>
>  #define INVALID_GRANT_REF (0)
> @@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  				 unsigned int domain, unsigned int bus)
>  {
>  	struct pci_bus *b;
> +	LIST_HEAD(resources);
>  	struct pcifront_sd *sd = NULL;
>  	struct pci_bus_entry *bus_entry = NULL;
>  	int err = 0;
> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> +	pci_add_resource(&resources, &ioport_resource);
> +	pci_add_resource(&resources, &iomem_resource);
> +	pci_add_resource(&resources, &busn_resource);

Since I don't want to export busn_resource, you might have to allocate your
own struct resource for it here.  And, of course, figure out the details of
which PCI domain you're in and whether you need to share one struct
resource across several host bridges in the same domain.

>  	pcifront_init_sd(sd, domain, bus, pdev);
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd);
> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +				  &pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
>  		err = -ENOMEM;
>  		pci_unlock_rescan_remove();
> +		pci_free_resource_list(&resources);
>  		goto err_out;
>  	}
>  
> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	list_add(&bus_entry->list, &pdev->root_buses);
>  
> -	/* pci_scan_bus_parented skips devices which do not have a have
> +	/* pci_scan_root_bus skips devices which do not have a
>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>  
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-11 22:32     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-11 22:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Mon, Mar 09, 2015 at 10:34:01AM +0800, Yijing Wang wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Use pci_scan_root_bus() instead of deprecated function
> pci_scan_bus_parented().
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/xen-pcifront.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..9e7c28b 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -21,6 +21,7 @@
>  #include <linux/bitops.h>
>  #include <linux/time.h>
>  #include <xen/platform_pci.h>
> +#include "pci.h"
>  
>  #include <asm/xen/swiotlb-xen.h>
>  #define INVALID_GRANT_REF (0)
> @@ -446,6 +447,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  				 unsigned int domain, unsigned int bus)
>  {
>  	struct pci_bus *b;
> +	LIST_HEAD(resources);
>  	struct pcifront_sd *sd = NULL;
>  	struct pci_bus_entry *bus_entry = NULL;
>  	int err = 0;
> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> +	pci_add_resource(&resources, &ioport_resource);
> +	pci_add_resource(&resources, &iomem_resource);
> +	pci_add_resource(&resources, &busn_resource);

Since I don't want to export busn_resource, you might have to allocate your
own struct resource for it here.  And, of course, figure out the details of
which PCI domain you're in and whether you need to share one struct
resource across several host bridges in the same domain.

>  	pcifront_init_sd(sd, domain, bus, pdev);
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd);
> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +				  &pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
>  		err = -ENOMEM;
>  		pci_unlock_rescan_remove();
> +		pci_free_resource_list(&resources);
>  		goto err_out;
>  	}
>  
> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	list_add(&bus_entry->list, &pdev->root_buses);
>  
> -	/* pci_scan_bus_parented skips devices which do not have a have
> +	/* pci_scan_root_bus skips devices which do not have a
>  	* devfn=0. The pcifront_scan_bus enumerates all devfn. */
>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>  
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  1:29     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:29 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> Currently, we use int type for bus number in
> pci_create_root_bus(), pci_scan_root_bus() and
> pci_scan_bus_legacy. Because PCI bus number
> always <= 255, so we could change the bus number
> argument type to u32, and combine PCI domain and
> bus number in one. 

This makes no sense.  Or rather, it only states the obvious: an 8-bit value
and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
*why* you think it's a good idea to pass a single value that contains both
domain and bus numbers.  The obvious thing is to pass two separate values,
and you don't say why passing a single combined value is better.

Also see whitespace mistakes below.  I get a little testy when people don't
follow the whitespace convention of neighboring lines because if people are
sloppy about whitespace I assume they're sloppy about the code.

> Also add a domain member in
> pci_host_bridge to save domain number. Finally,
> we could eliminate lots of the platform specific
> pci_domain_nr() in the last of the series.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c      |   16 +++++++++-------
>  include/linux/pci.h      |    7 ++++---
>  include/uapi/linux/pci.h |    3 +++
>  3 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 187fa54..3d6befd 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	int error;
> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> +	u8	bus = PCI_BUSNUM(db);

Whitespace botch.

>  
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	if (!bridge)
>  		goto err_out;
>  
> +	bridge->domain = PCI_DOMAIN(db);
>  	bridge->dev.parent = parent;
>  	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	struct resource_entry *window;
> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>  	if (!b)
>  		return NULL;
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			bus);
> -		pci_bus_insert_busn_res(b, bus, 255);
> +			PCI_BUSNUM(db));
> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  }
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>  					void *sysdata)
>  {
>  	LIST_HEAD(resources);
> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>  	pci_add_resource(&resources, &ioport_resource);
>  	pci_add_resource(&resources, &iomem_resource);
>  	pci_add_resource(&resources, &busn_resource);
> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>  	if (b) {
>  		pci_scan_child_bus(b);
>  	} else {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 36effb8..8b3d245 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  }
>  
>  struct pci_host_bridge {
> +	u16	domain;

Please follow the existing whitespace convention, i.e., use a space, not a
tab, between "u16 domain".

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  void pcibios_scan_specific_bus(int busn);
>  struct pci_bus *pci_find_bus(int domain, int busnr);
>  void pci_bus_add_devices(const struct pci_bus *bus);
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>  				    struct pci_ops *ops, void *sysdata,
>  				    struct list_head *resources);
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>  void pci_bus_release_busn_res(struct pci_bus *b);
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
> index 3c292bc..89c6f15 100644
> --- a/include/uapi/linux/pci.h
> +++ b/include/uapi/linux/pci.h
> @@ -30,6 +30,9 @@
>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
> +#define PCI_DOMAIN(db)		((db) >> 16)
> +#define PCI_BUSNUM(db)		((db) & 0xffff)
> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>  
>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-12  1:29   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:29 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> Currently, we use int type for bus number in
> pci_create_root_bus(), pci_scan_root_bus() and
> pci_scan_bus_legacy. Because PCI bus number
> always <= 255, so we could change the bus number
> argument type to u32, and combine PCI domain and
> bus number in one. 

This makes no sense.  Or rather, it only states the obvious: an 8-bit value
and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
*why* you think it's a good idea to pass a single value that contains both
domain and bus numbers.  The obvious thing is to pass two separate values,
and you don't say why passing a single combined value is better.

Also see whitespace mistakes below.  I get a little testy when people don't
follow the whitespace convention of neighboring lines because if people are
sloppy about whitespace I assume they're sloppy about the code.

> Also add a domain member in
> pci_host_bridge to save domain number. Finally,
> we could eliminate lots of the platform specific
> pci_domain_nr() in the last of the series.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c      |   16 +++++++++-------
>  include/linux/pci.h      |    7 ++++---
>  include/uapi/linux/pci.h |    3 +++
>  3 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 187fa54..3d6befd 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	int error;
> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> +	u8	bus = PCI_BUSNUM(db);

Whitespace botch.

>  
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	if (!bridge)
>  		goto err_out;
>  
> +	bridge->domain = PCI_DOMAIN(db);
>  	bridge->dev.parent = parent;
>  	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	struct resource_entry *window;
> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>  	if (!b)
>  		return NULL;
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			bus);
> -		pci_bus_insert_busn_res(b, bus, 255);
> +			PCI_BUSNUM(db));
> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  }
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>  					void *sysdata)
>  {
>  	LIST_HEAD(resources);
> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>  	pci_add_resource(&resources, &ioport_resource);
>  	pci_add_resource(&resources, &iomem_resource);
>  	pci_add_resource(&resources, &busn_resource);
> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>  	if (b) {
>  		pci_scan_child_bus(b);
>  	} else {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 36effb8..8b3d245 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  }
>  
>  struct pci_host_bridge {
> +	u16	domain;

Please follow the existing whitespace convention, i.e., use a space, not a
tab, between "u16 domain".

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  void pcibios_scan_specific_bus(int busn);
>  struct pci_bus *pci_find_bus(int domain, int busnr);
>  void pci_bus_add_devices(const struct pci_bus *bus);
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>  				    struct pci_ops *ops, void *sysdata,
>  				    struct list_head *resources);
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>  void pci_bus_release_busn_res(struct pci_bus *b);
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
> index 3c292bc..89c6f15 100644
> --- a/include/uapi/linux/pci.h
> +++ b/include/uapi/linux/pci.h
> @@ -30,6 +30,9 @@
>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
> +#define PCI_DOMAIN(db)		((db) >> 16)
> +#define PCI_BUSNUM(db)		((db) & 0xffff)
> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>  
>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12  1:29     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:29 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> Currently, we use int type for bus number in
> pci_create_root_bus(), pci_scan_root_bus() and
> pci_scan_bus_legacy. Because PCI bus number
> always <= 255, so we could change the bus number
> argument type to u32, and combine PCI domain and
> bus number in one. 

This makes no sense.  Or rather, it only states the obvious: an 8-bit value
and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
*why* you think it's a good idea to pass a single value that contains both
domain and bus numbers.  The obvious thing is to pass two separate values,
and you don't say why passing a single combined value is better.

Also see whitespace mistakes below.  I get a little testy when people don't
follow the whitespace convention of neighboring lines because if people are
sloppy about whitespace I assume they're sloppy about the code.

> Also add a domain member in
> pci_host_bridge to save domain number. Finally,
> we could eliminate lots of the platform specific
> pci_domain_nr() in the last of the series.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c      |   16 +++++++++-------
>  include/linux/pci.h      |    7 ++++---
>  include/uapi/linux/pci.h |    3 +++
>  3 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 187fa54..3d6befd 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	int error;
> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> +	u8	bus = PCI_BUSNUM(db);

Whitespace botch.

>  
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	if (!bridge)
>  		goto err_out;
>  
> +	bridge->domain = PCI_DOMAIN(db);
>  	bridge->dev.parent = parent;
>  	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	struct resource_entry *window;
> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>  	if (!b)
>  		return NULL;
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			bus);
> -		pci_bus_insert_busn_res(b, bus, 255);
> +			PCI_BUSNUM(db));
> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  }
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>  					void *sysdata)
>  {
>  	LIST_HEAD(resources);
> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>  	pci_add_resource(&resources, &ioport_resource);
>  	pci_add_resource(&resources, &iomem_resource);
>  	pci_add_resource(&resources, &busn_resource);
> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>  	if (b) {
>  		pci_scan_child_bus(b);
>  	} else {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 36effb8..8b3d245 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  }
>  
>  struct pci_host_bridge {
> +	u16	domain;

Please follow the existing whitespace convention, i.e., use a space, not a
tab, between "u16 domain".

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  void pcibios_scan_specific_bus(int busn);
>  struct pci_bus *pci_find_bus(int domain, int busnr);
>  void pci_bus_add_devices(const struct pci_bus *bus);
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>  				    struct pci_ops *ops, void *sysdata,
>  				    struct list_head *resources);
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>  void pci_bus_release_busn_res(struct pci_bus *b);
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
> index 3c292bc..89c6f15 100644
> --- a/include/uapi/linux/pci.h
> +++ b/include/uapi/linux/pci.h
> @@ -30,6 +30,9 @@
>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
> +#define PCI_DOMAIN(db)		((db) >> 16)
> +#define PCI_BUSNUM(db)		((db) & 0xffff)
> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>  
>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
> -- 
> 1.7.1
> 
> --
> 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

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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12  1:29     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> Currently, we use int type for bus number in
> pci_create_root_bus(), pci_scan_root_bus() and
> pci_scan_bus_legacy. Because PCI bus number
> always <= 255, so we could change the bus number
> argument type to u32, and combine PCI domain and
> bus number in one. 

This makes no sense.  Or rather, it only states the obvious: an 8-bit value
and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
*why* you think it's a good idea to pass a single value that contains both
domain and bus numbers.  The obvious thing is to pass two separate values,
and you don't say why passing a single combined value is better.

Also see whitespace mistakes below.  I get a little testy when people don't
follow the whitespace convention of neighboring lines because if people are
sloppy about whitespace I assume they're sloppy about the code.

> Also add a domain member in
> pci_host_bridge to save domain number. Finally,
> we could eliminate lots of the platform specific
> pci_domain_nr() in the last of the series.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c      |   16 +++++++++-------
>  include/linux/pci.h      |    7 ++++---
>  include/uapi/linux/pci.h |    3 +++
>  3 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 187fa54..3d6befd 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	int error;
> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> +	u8	bus = PCI_BUSNUM(db);

Whitespace botch.

>  
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	if (!bridge)
>  		goto err_out;
>  
> +	bridge->domain = PCI_DOMAIN(db);
>  	bridge->dev.parent = parent;
>  	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	struct resource_entry *window;
> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>  	if (!b)
>  		return NULL;
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			bus);
> -		pci_bus_insert_busn_res(b, bus, 255);
> +			PCI_BUSNUM(db));
> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  }
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>  					void *sysdata)
>  {
>  	LIST_HEAD(resources);
> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>  	pci_add_resource(&resources, &ioport_resource);
>  	pci_add_resource(&resources, &iomem_resource);
>  	pci_add_resource(&resources, &busn_resource);
> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>  	if (b) {
>  		pci_scan_child_bus(b);
>  	} else {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 36effb8..8b3d245 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  }
>  
>  struct pci_host_bridge {
> +	u16	domain;

Please follow the existing whitespace convention, i.e., use a space, not a
tab, between "u16 domain".

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  void pcibios_scan_specific_bus(int busn);
>  struct pci_bus *pci_find_bus(int domain, int busnr);
>  void pci_bus_add_devices(const struct pci_bus *bus);
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>  				    struct pci_ops *ops, void *sysdata,
>  				    struct list_head *resources);
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>  void pci_bus_release_busn_res(struct pci_bus *b);
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
> index 3c292bc..89c6f15 100644
> --- a/include/uapi/linux/pci.h
> +++ b/include/uapi/linux/pci.h
> @@ -30,6 +30,9 @@
>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
> +#define PCI_DOMAIN(db)		((db) >> 16)
> +#define PCI_BUSNUM(db)		((db) & 0xffff)
> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>  
>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12  1:29     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:29 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> Currently, we use int type for bus number in
> pci_create_root_bus(), pci_scan_root_bus() and
> pci_scan_bus_legacy. Because PCI bus number
> always <= 255, so we could change the bus number
> argument type to u32, and combine PCI domain and
> bus number in one. 

This makes no sense.  Or rather, it only states the obvious: an 8-bit value
and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
*why* you think it's a good idea to pass a single value that contains both
domain and bus numbers.  The obvious thing is to pass two separate values,
and you don't say why passing a single combined value is better.

Also see whitespace mistakes below.  I get a little testy when people don't
follow the whitespace convention of neighboring lines because if people are
sloppy about whitespace I assume they're sloppy about the code.

> Also add a domain member in
> pci_host_bridge to save domain number. Finally,
> we could eliminate lots of the platform specific
> pci_domain_nr() in the last of the series.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c      |   16 +++++++++-------
>  include/linux/pci.h      |    7 ++++---
>  include/uapi/linux/pci.h |    3 +++
>  3 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 187fa54..3d6befd 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1890,7 +1890,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	int error;
> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> +	u8	bus = PCI_BUSNUM(db);

Whitespace botch.

>  
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	if (!bridge)
>  		goto err_out;
>  
> +	bridge->domain = PCI_DOMAIN(db);
>  	bridge->dev.parent = parent;
>  	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
>  	struct resource_entry *window;
> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>  	if (!b)
>  		return NULL;
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			bus);
> -		pci_bus_insert_busn_res(b, bus, 255);
> +			PCI_BUSNUM(db));
> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>  }
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>  					void *sysdata)
>  {
>  	LIST_HEAD(resources);
> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>  	pci_add_resource(&resources, &ioport_resource);
>  	pci_add_resource(&resources, &iomem_resource);
>  	pci_add_resource(&resources, &busn_resource);
> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>  	if (b) {
>  		pci_scan_child_bus(b);
>  	} else {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 36effb8..8b3d245 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  }
>  
>  struct pci_host_bridge {
> +	u16	domain;

Please follow the existing whitespace convention, i.e., use a space, not a
tab, between "u16 domain".

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  void pcibios_scan_specific_bus(int busn);
>  struct pci_bus *pci_find_bus(int domain, int busnr);
>  void pci_bus_add_devices(const struct pci_bus *bus);
> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>  				    struct pci_ops *ops, void *sysdata,
>  				    struct list_head *resources);
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>  void pci_bus_release_busn_res(struct pci_bus *b);
> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
> index 3c292bc..89c6f15 100644
> --- a/include/uapi/linux/pci.h
> +++ b/include/uapi/linux/pci.h
> @@ -30,6 +30,9 @@
>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
> +#define PCI_DOMAIN(db)		((db) >> 16)
> +#define PCI_BUSNUM(db)		((db) & 0xffff)
> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>  
>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:34   ` Yijing Wang
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-12  1:34     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus = NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus = NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus = NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12  1:34     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:34   ` Yijing Wang
                     ` (5 preceding siblings ...)
  (?)
@ 2015-03-12  1:34   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12  1:34     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12  1:34     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: Yijing Wang
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Chris Metcalf,
	Paul Mackerras, sparclinux, Guan Xuetao, linux-s390,
	Russell King, x86, Sebastian Ott, Geert Uytterhoeven,
	Gerald Schaefer, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Konrad Rzeszutek Wilk, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Richard Henderson, Liviu Dudau,
	Michal Simek, Tony Luck, linux-kernel, Ralf Baechle, Jiang Liu,
	linux-alpha, linuxppc-dev, David S. Miller

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12  1:34     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha at vger.kernel.org
> CC: linux-kernel at vger.kernel.org
> CC: linux-ia64 at vger.kernel.org
> CC: linux-mips at linux-mips.org
> CC: linuxppc-dev at lists.ozlabs.org
> CC: linux-s390 at vger.kernel.org
> CC: linux-sh at vger.kernel.org
> CC: sparclinux at vger.kernel.org
> CC: xen-devel at lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:34   ` Yijing Wang
                     ` (6 preceding siblings ...)
  (?)
@ 2015-03-12  1:34   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: Yijing Wang
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Chris Metcalf,
	Paul Mackerras, sparclinux, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12  1:34     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:34 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, R

On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged.

I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
convinced that's a good idea yet), I'm not happy with most code being

  pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

but ARM being

  pci_scan_root_bus(..., sys->busnr, ...)

That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
you want, but at least make it look like you did a thorough job.

> A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/alpha/kernel/pci.c          |    5 +++--
>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>  arch/ia64/pci/pci.c              |    4 ++--
>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>  arch/microblaze/pci/pci-common.c |    5 +++--
>  arch/mips/pci/pci.c              |    4 ++--
>  arch/powerpc/kernel/pci-common.c |    5 +++--
>  arch/s390/pci/pci.c              |    5 +++--
>  arch/sh/drivers/pci/pci.c        |    5 +++--
>  arch/sparc/kernel/pci.c          |    5 +++--
>  arch/tile/kernel/pci.c           |    5 +++--
>  arch/tile/kernel/pci_gx.c        |    5 +++--
>  arch/x86/pci/acpi.c              |    7 ++++---
>  arch/x86/pci/common.c            |    3 ++-
>  drivers/pci/xen-pcifront.c       |    5 +++--
>  15 files changed, 42 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>  		pci_add_resource_offset(&resources, hose->mem_space,
>  					hose->mem_space->start);
>  
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>  		if (!bus)
>  			continue;
>  		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>  
>  	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>  	if (!bus)
>  		return;
> -
>  	hose->bus = bus;
>  	pcibios_claim_one_bus(bus);
>  
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	 * should handle the case here, but it appears that IA64 hasn't
>  	 * such quirk. So we just ignore the case now.
>  	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>  	if (!pbus) {
>  		pci_free_resource_list(&info->resources);
>  		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>  	pci_add_resource_offset(&resources,	&res[1],
>  			prom_bussoft_ptr->bs_legacy_mem);
>  
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>   	if (bus == NULL) {
>  		kfree(res);
>  		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>  
>  	pcibios_setup_phb_resources(hose, &resources);
>  
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	pci_add_resource_offset(&resources,
>  				hose->mem_resource, hose->mem_offset);
>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	if (!bus)
>  		pci_free_resource_list(&resources);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>  	pci_add_resource(&resources, &hose->busn);
>  
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>  	if (ret)
>  		return ret;
>  
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>  	if (!zdev->bus) {
>  		zpci_cleanup_bus_resources(zdev);
>  		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		pci_add_resource_offset(&resources, res, offset);
>  	}
>  
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>  	hose->bus = bus;
>  
>  	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>  	if (!bus) {
>  		printk(KERN_ERR "Failed to create bus for %s\n",
>  		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>  
>  			pci_add_resource(&resources, &ioport_resource);
>  			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>  			controller->root_bus = bus;
>  			controller->last_busno = bus->busn_res.end;
>  		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>  					controller->mem_offset);
>  		pci_add_resource(&resources, &controller->io_space);
>  		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>  		controller->root_bus = bus;
>  		next_busno = bus->busn_res.end + 1;
>  	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		}
>  
>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>  
>  		if (bus) {
>  			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>  	sd->node = x86_pci_root_bus_node(busnum);
>  	x86_pci_root_bus_resources(busnum, &resources);
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>  	if (!bus) {
>  		pci_free_resource_list(&resources);
>  		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>  
>  	pci_lock_rescan_remove();
>  
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>  	if (!b) {
>  		dev_err(&pdev->xdev->dev,
>  			"Error creating PCI Frontend Bus!\n");
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  1:39     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:39 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:05AM +0800, Yijing Wang wrote:
> Introduce pci_host_assign_domain_nr() to assign domain
> number for pci_host_bridge. Later we will remove
> pci_bus_assign_domain_nr().
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |   20 +++++++++++++++-----
>  include/linux/pci.h |    4 ++++
>  2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 81f06e8..c49eec1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS_GENERIC
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +static int pci_assign_domain_nr(struct device *dev)
>  {
>  	static int use_dt_domains = -1;
> -	int domain = of_get_pci_domain_nr(parent->of_node);
> +	int domain = of_get_pci_domain_nr(dev->of_node);
>  
>  	/*
>  	 * Check DT domain and use_dt_domains values.
> @@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  		use_dt_domains = 0;
>  		domain = pci_get_new_domain_nr();
>  	} else {
> -		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> -			parent->of_node->full_name);
> +		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> +			dev->of_node->full_name);
>  		domain = -1;
>  	}
>  
> -	bus->domain_nr = domain;
> +	return domain;
> +}
> +
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +	host->domain = pci_assign_domain_nr(host->dev.parent);
> +}
> +
> +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +{
> +	bus->domain_nr = pci_assign_domain_nr(parent);
>  }
>  #endif
>  #endif
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 8b3d245..2b1b998 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>  	return bus->domain_nr;
>  }
>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);

I do not think this needs to be in include/linux/pci.h.  It's called only
from drivers/pci/host-bridge.c, so at most, it needs to be in
drivers/pci/pci.h.

Better still would be if the definition could be moved from
drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
in a header file at all.

>  #else
>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>  					struct device *parent)
>  {
>  }
> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +}
>  #endif
>  
>  /* some architectures require additional setup to direct VGA traffic */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-12  1:39   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:39 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:05AM +0800, Yijing Wang wrote:
> Introduce pci_host_assign_domain_nr() to assign domain
> number for pci_host_bridge. Later we will remove
> pci_bus_assign_domain_nr().
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |   20 +++++++++++++++-----
>  include/linux/pci.h |    4 ++++
>  2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 81f06e8..c49eec1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS_GENERIC
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +static int pci_assign_domain_nr(struct device *dev)
>  {
>  	static int use_dt_domains = -1;
> -	int domain = of_get_pci_domain_nr(parent->of_node);
> +	int domain = of_get_pci_domain_nr(dev->of_node);
>  
>  	/*
>  	 * Check DT domain and use_dt_domains values.
> @@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  		use_dt_domains = 0;
>  		domain = pci_get_new_domain_nr();
>  	} else {
> -		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> -			parent->of_node->full_name);
> +		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> +			dev->of_node->full_name);
>  		domain = -1;
>  	}
>  
> -	bus->domain_nr = domain;
> +	return domain;
> +}
> +
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +	host->domain = pci_assign_domain_nr(host->dev.parent);
> +}
> +
> +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +{
> +	bus->domain_nr = pci_assign_domain_nr(parent);
>  }
>  #endif
>  #endif
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 8b3d245..2b1b998 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>  	return bus->domain_nr;
>  }
>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);

I do not think this needs to be in include/linux/pci.h.  It's called only
from drivers/pci/host-bridge.c, so at most, it needs to be in
drivers/pci/pci.h.

Better still would be if the definition could be moved from
drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
in a header file at all.

>  #else
>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>  					struct device *parent)
>  {
>  }
> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +}
>  #endif
>  
>  /* some architectures require additional setup to direct VGA traffic */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12  1:39     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:39 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:05AM +0800, Yijing Wang wrote:
> Introduce pci_host_assign_domain_nr() to assign domain
> number for pci_host_bridge. Later we will remove
> pci_bus_assign_domain_nr().
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |   20 +++++++++++++++-----
>  include/linux/pci.h |    4 ++++
>  2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 81f06e8..c49eec1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS_GENERIC
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +static int pci_assign_domain_nr(struct device *dev)
>  {
>  	static int use_dt_domains = -1;
> -	int domain = of_get_pci_domain_nr(parent->of_node);
> +	int domain = of_get_pci_domain_nr(dev->of_node);
>  
>  	/*
>  	 * Check DT domain and use_dt_domains values.
> @@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  		use_dt_domains = 0;
>  		domain = pci_get_new_domain_nr();
>  	} else {
> -		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> -			parent->of_node->full_name);
> +		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> +			dev->of_node->full_name);
>  		domain = -1;
>  	}
>  
> -	bus->domain_nr = domain;
> +	return domain;
> +}
> +
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +	host->domain = pci_assign_domain_nr(host->dev.parent);
> +}
> +
> +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +{
> +	bus->domain_nr = pci_assign_domain_nr(parent);
>  }
>  #endif
>  #endif
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 8b3d245..2b1b998 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>  	return bus->domain_nr;
>  }
>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);

I do not think this needs to be in include/linux/pci.h.  It's called only
from drivers/pci/host-bridge.c, so at most, it needs to be in
drivers/pci/pci.h.

Better still would be if the definition could be moved from
drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
in a header file at all.

>  #else
>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>  					struct device *parent)
>  {
>  }
> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +}
>  #endif
>  
>  /* some architectures require additional setup to direct VGA traffic */
> -- 
> 1.7.1
> 

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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12  1:39     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:05AM +0800, Yijing Wang wrote:
> Introduce pci_host_assign_domain_nr() to assign domain
> number for pci_host_bridge. Later we will remove
> pci_bus_assign_domain_nr().
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |   20 +++++++++++++++-----
>  include/linux/pci.h |    4 ++++
>  2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 81f06e8..c49eec1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS_GENERIC
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +static int pci_assign_domain_nr(struct device *dev)
>  {
>  	static int use_dt_domains = -1;
> -	int domain = of_get_pci_domain_nr(parent->of_node);
> +	int domain = of_get_pci_domain_nr(dev->of_node);
>  
>  	/*
>  	 * Check DT domain and use_dt_domains values.
> @@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  		use_dt_domains = 0;
>  		domain = pci_get_new_domain_nr();
>  	} else {
> -		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> -			parent->of_node->full_name);
> +		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> +			dev->of_node->full_name);
>  		domain = -1;
>  	}
>  
> -	bus->domain_nr = domain;
> +	return domain;
> +}
> +
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +	host->domain = pci_assign_domain_nr(host->dev.parent);
> +}
> +
> +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +{
> +	bus->domain_nr = pci_assign_domain_nr(parent);
>  }
>  #endif
>  #endif
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 8b3d245..2b1b998 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>  	return bus->domain_nr;
>  }
>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);

I do not think this needs to be in include/linux/pci.h.  It's called only
from drivers/pci/host-bridge.c, so at most, it needs to be in
drivers/pci/pci.h.

Better still would be if the definition could be moved from
drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
in a header file at all.

>  #else
>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>  					struct device *parent)
>  {
>  }
> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +}
>  #endif
>  
>  /* some architectures require additional setup to direct VGA traffic */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12  1:39     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  1:39 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:05AM +0800, Yijing Wang wrote:
> Introduce pci_host_assign_domain_nr() to assign domain
> number for pci_host_bridge. Later we will remove
> pci_bus_assign_domain_nr().
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |   20 +++++++++++++++-----
>  include/linux/pci.h |    4 ++++
>  2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 81f06e8..c49eec1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void)
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS_GENERIC
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +static int pci_assign_domain_nr(struct device *dev)
>  {
>  	static int use_dt_domains = -1;
> -	int domain = of_get_pci_domain_nr(parent->of_node);
> +	int domain = of_get_pci_domain_nr(dev->of_node);
>  
>  	/*
>  	 * Check DT domain and use_dt_domains values.
> @@ -4538,12 +4538,22 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  		use_dt_domains = 0;
>  		domain = pci_get_new_domain_nr();
>  	} else {
> -		dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> -			parent->of_node->full_name);
> +		dev_err(dev, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
> +			dev->of_node->full_name);
>  		domain = -1;
>  	}
>  
> -	bus->domain_nr = domain;
> +	return domain;
> +}
> +
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +	host->domain = pci_assign_domain_nr(host->dev.parent);
> +}
> +
> +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> +{
> +	bus->domain_nr = pci_assign_domain_nr(parent);
>  }
>  #endif
>  #endif
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 8b3d245..2b1b998 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>  	return bus->domain_nr;
>  }
>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);

I do not think this needs to be in include/linux/pci.h.  It's called only
from drivers/pci/host-bridge.c, so at most, it needs to be in
drivers/pci/pci.h.

Better still would be if the definition could be moved from
drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
in a header file at all.

>  #else
>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>  					struct device *parent)
>  {
>  }
> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
> +{
> +}
>  #endif
>  
>  /* some architectures require additional setup to direct VGA traffic */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  2:55     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  2:55 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> Introduce pci_host_bridge_list to manage pci host
> bridges in system, so we could detect whether
> the host in domain:bus is alreay registered.
> Then we could remove bus alreay exist test in
> __pci_create_root_bus().

It's a nice idea to move this test into the core.  While you're at it, why
don't you check for any overlap with the bus ranges of existing host
bridges?  For example, if we're trying to create a new host bridge to
[bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
as well as to [bus 40-ff].  I think your current patch will detect the
latter conflict but not the former.

> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>  drivers/pci/probe.c       |    8 +-------
>  include/linux/pci.h       |    1 +
>  3 files changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3bd45e7..0bb08ef 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,9 @@
>  
>  #include "pci.h"
>  
> +static LIST_HEAD(pci_host_bridge_list);
> +static DEFINE_MUTEX(phb_mutex);

We don't use the "phb" abbreviation in the PCI core.

> +
>  static void pci_release_host_bridge_dev(struct device *dev)
>  {
>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	int error;
>  	int bus = PCI_BUSNUM(db);
>  	int domain = PCI_DOMAIN(db);
> -	struct pci_host_bridge *host;
> +	struct pci_host_bridge *host, *temp;
>  	struct resource_entry *window, *n;
>  
>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	 */
>  	pci_host_assign_domain_nr(host);
>  
> +	mutex_lock(&phb_mutex);
> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
> +		if (temp->domain == host->domain
> +				&& temp->busnum == host->busnum) {
> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
> +					host->domain, host->busnum);

&host->dev hasn't been initialized yet!  And the text of the original
message was better.

> +			mutex_unlock(&phb_mutex);
> +			kfree(host);
> +			return NULL;
> +		}
> +	mutex_unlock(&phb_mutex);

This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
time can both succeed.

And it needs curly braces around the list_for_each_entry() body.

> +
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	resource_list_for_each_entry_safe(window, n, resources)
>  		list_move_tail(&window->node, &host->windows);
>  
> +	mutex_lock(&phb_mutex);
> +	list_add_tail(&host->list, &pci_host_bridge_list);
> +	mutex_unlock(&phb_mutex);
>  	return host;
>  }
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host)
>  {
> +	mutex_lock(&phb_mutex);
> +	list_del(&host->list);
> +	mutex_unlock(&phb_mutex);
> +
>  	device_unregister(&host->dev);
>  }
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 27ec612..7238fa3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>  		void *sysdata)
>  {
>  	int error;
> -	struct pci_bus *b, *b2;
> +	struct pci_bus *b;
>  	struct resource_entry *window;
>  	struct device *parent;
>  	struct resource *res;
> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
> -	if (b2) {
> -		/* If we already got to this bus through a different bridge, ignore it */
> -		dev_dbg(&b2->dev, "bus already known\n");
> -		goto err_out;
> -	}
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 463eaa3..b621f5b 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> +	struct list_head list;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12  2:55     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  2:55 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> Introduce pci_host_bridge_list to manage pci host
> bridges in system, so we could detect whether
> the host in domain:bus is alreay registered.
> Then we could remove bus alreay exist test in
> __pci_create_root_bus().

It's a nice idea to move this test into the core.  While you're at it, why
don't you check for any overlap with the bus ranges of existing host
bridges?  For example, if we're trying to create a new host bridge to
[bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
as well as to [bus 40-ff].  I think your current patch will detect the
latter conflict but not the former.

> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>  drivers/pci/probe.c       |    8 +-------
>  include/linux/pci.h       |    1 +
>  3 files changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3bd45e7..0bb08ef 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,9 @@
>  
>  #include "pci.h"
>  
> +static LIST_HEAD(pci_host_bridge_list);
> +static DEFINE_MUTEX(phb_mutex);

We don't use the "phb" abbreviation in the PCI core.

> +
>  static void pci_release_host_bridge_dev(struct device *dev)
>  {
>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	int error;
>  	int bus = PCI_BUSNUM(db);
>  	int domain = PCI_DOMAIN(db);
> -	struct pci_host_bridge *host;
> +	struct pci_host_bridge *host, *temp;
>  	struct resource_entry *window, *n;
>  
>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	 */
>  	pci_host_assign_domain_nr(host);
>  
> +	mutex_lock(&phb_mutex);
> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
> +		if (temp->domain == host->domain
> +				&& temp->busnum == host->busnum) {
> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
> +					host->domain, host->busnum);

&host->dev hasn't been initialized yet!  And the text of the original
message was better.

> +			mutex_unlock(&phb_mutex);
> +			kfree(host);
> +			return NULL;
> +		}
> +	mutex_unlock(&phb_mutex);

This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
time can both succeed.

And it needs curly braces around the list_for_each_entry() body.

> +
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	resource_list_for_each_entry_safe(window, n, resources)
>  		list_move_tail(&window->node, &host->windows);
>  
> +	mutex_lock(&phb_mutex);
> +	list_add_tail(&host->list, &pci_host_bridge_list);
> +	mutex_unlock(&phb_mutex);
>  	return host;
>  }
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host)
>  {
> +	mutex_lock(&phb_mutex);
> +	list_del(&host->list);
> +	mutex_unlock(&phb_mutex);
> +
>  	device_unregister(&host->dev);
>  }
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 27ec612..7238fa3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>  		void *sysdata)
>  {
>  	int error;
> -	struct pci_bus *b, *b2;
> +	struct pci_bus *b;
>  	struct resource_entry *window;
>  	struct device *parent;
>  	struct resource *res;
> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
> -	if (b2) {
> -		/* If we already got to this bus through a different bridge, ignore it */
> -		dev_dbg(&b2->dev, "bus already known\n");
> -		goto err_out;
> -	}
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 463eaa3..b621f5b 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> +	struct list_head list;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 

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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12  2:55     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  2:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> Introduce pci_host_bridge_list to manage pci host
> bridges in system, so we could detect whether
> the host in domain:bus is alreay registered.
> Then we could remove bus alreay exist test in
> __pci_create_root_bus().

It's a nice idea to move this test into the core.  While you're at it, why
don't you check for any overlap with the bus ranges of existing host
bridges?  For example, if we're trying to create a new host bridge to
[bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
as well as to [bus 40-ff].  I think your current patch will detect the
latter conflict but not the former.

> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>  drivers/pci/probe.c       |    8 +-------
>  include/linux/pci.h       |    1 +
>  3 files changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3bd45e7..0bb08ef 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,9 @@
>  
>  #include "pci.h"
>  
> +static LIST_HEAD(pci_host_bridge_list);
> +static DEFINE_MUTEX(phb_mutex);

We don't use the "phb" abbreviation in the PCI core.

> +
>  static void pci_release_host_bridge_dev(struct device *dev)
>  {
>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	int error;
>  	int bus = PCI_BUSNUM(db);
>  	int domain = PCI_DOMAIN(db);
> -	struct pci_host_bridge *host;
> +	struct pci_host_bridge *host, *temp;
>  	struct resource_entry *window, *n;
>  
>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	 */
>  	pci_host_assign_domain_nr(host);
>  
> +	mutex_lock(&phb_mutex);
> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
> +		if (temp->domain == host->domain
> +				&& temp->busnum == host->busnum) {
> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
> +					host->domain, host->busnum);

&host->dev hasn't been initialized yet!  And the text of the original
message was better.

> +			mutex_unlock(&phb_mutex);
> +			kfree(host);
> +			return NULL;
> +		}
> +	mutex_unlock(&phb_mutex);

This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
time can both succeed.

And it needs curly braces around the list_for_each_entry() body.

> +
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	resource_list_for_each_entry_safe(window, n, resources)
>  		list_move_tail(&window->node, &host->windows);
>  
> +	mutex_lock(&phb_mutex);
> +	list_add_tail(&host->list, &pci_host_bridge_list);
> +	mutex_unlock(&phb_mutex);
>  	return host;
>  }
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host)
>  {
> +	mutex_lock(&phb_mutex);
> +	list_del(&host->list);
> +	mutex_unlock(&phb_mutex);
> +
>  	device_unregister(&host->dev);
>  }
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 27ec612..7238fa3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>  		void *sysdata)
>  {
>  	int error;
> -	struct pci_bus *b, *b2;
> +	struct pci_bus *b;
>  	struct resource_entry *window;
>  	struct device *parent;
>  	struct resource *res;
> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
> -	if (b2) {
> -		/* If we already got to this bus through a different bridge, ignore it */
> -		dev_dbg(&b2->dev, "bus already known\n");
> -		goto err_out;
> -	}
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 463eaa3..b621f5b 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> +	struct list_head list;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12  2:55     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  2:55 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> Introduce pci_host_bridge_list to manage pci host
> bridges in system, so we could detect whether
> the host in domain:bus is alreay registered.
> Then we could remove bus alreay exist test in
> __pci_create_root_bus().

It's a nice idea to move this test into the core.  While you're at it, why
don't you check for any overlap with the bus ranges of existing host
bridges?  For example, if we're trying to create a new host bridge to
[bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
as well as to [bus 40-ff].  I think your current patch will detect the
latter conflict but not the former.

> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>  drivers/pci/probe.c       |    8 +-------
>  include/linux/pci.h       |    1 +
>  3 files changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3bd45e7..0bb08ef 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,9 @@
>  
>  #include "pci.h"
>  
> +static LIST_HEAD(pci_host_bridge_list);
> +static DEFINE_MUTEX(phb_mutex);

We don't use the "phb" abbreviation in the PCI core.

> +
>  static void pci_release_host_bridge_dev(struct device *dev)
>  {
>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	int error;
>  	int bus = PCI_BUSNUM(db);
>  	int domain = PCI_DOMAIN(db);
> -	struct pci_host_bridge *host;
> +	struct pci_host_bridge *host, *temp;
>  	struct resource_entry *window, *n;
>  
>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	 */
>  	pci_host_assign_domain_nr(host);
>  
> +	mutex_lock(&phb_mutex);
> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
> +		if (temp->domain = host->domain
> +				&& temp->busnum = host->busnum) {
> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
> +					host->domain, host->busnum);

&host->dev hasn't been initialized yet!  And the text of the original
message was better.

> +			mutex_unlock(&phb_mutex);
> +			kfree(host);
> +			return NULL;
> +		}
> +	mutex_unlock(&phb_mutex);

This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
time can both succeed.

And it needs curly braces around the list_for_each_entry() body.

> +
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	resource_list_for_each_entry_safe(window, n, resources)
>  		list_move_tail(&window->node, &host->windows);
>  
> +	mutex_lock(&phb_mutex);
> +	list_add_tail(&host->list, &pci_host_bridge_list);
> +	mutex_unlock(&phb_mutex);
>  	return host;
>  }
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host)
>  {
> +	mutex_lock(&phb_mutex);
> +	list_del(&host->list);
> +	mutex_unlock(&phb_mutex);
> +
>  	device_unregister(&host->dev);
>  }
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 27ec612..7238fa3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>  		void *sysdata)
>  {
>  	int error;
> -	struct pci_bus *b, *b2;
> +	struct pci_bus *b;
>  	struct resource_entry *window;
>  	struct device *parent;
>  	struct resource *res;
> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
> -	if (b2) {
> -		/* If we already got to this bus through a different bridge, ignore it */
> -		dev_dbg(&b2->dev, "bus already known\n");
> -		goto err_out;
> -	}
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 463eaa3..b621f5b 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> +	struct list_head list;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:23     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:09AM +0800, Yijing Wang wrote:
> Now we have weak functions like pcibios_root_bridge_prepare()
> to setup pci host bridge, We could introduce pci_host_bridge_ops
> which contain host bridge specific ops to setup pci_host_bridge.
> Then host bridge driver could add pci_host_bridge_ops hooks
> intead of weak function to setup pci_host_bridge.
> This patch add following pci_host_bridge_ops hooks:
> 
> pci_host_bridge_ops {
> 	/* set root bus speed, some platform need this like powerpc */
> 	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> 	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
> 	int (*prepare)(struct pci_host_bridge *host);
> 	/* platform specific of scan hook to scan pci device */
> 	void (*scan_bus)(struct pci_host_bridge *);
> }
> We could easily extend it to support different host bridge
> specific operations.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   12 ++++++++++--
>  drivers/pci/pci.h         |    4 ++--
>  drivers/pci/probe.c       |   17 +++++++++++------
>  include/linux/pci.h       |    8 ++++++++
>  4 files changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3c34c49..bc1de59 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
>  }
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 db,
> -		struct list_head *resources, void *sysdata)
> +		struct device *parent, u32 db, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops)
>  {
>  	int error;
>  	int bus = PCI_BUSNUM(db);
> @@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		}
>  	mutex_unlock(&phb_mutex);
>  
> +	host->ops = ops;
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
>  			host->busnum);
>  
> +	if (host->ops && host->ops->prepare) {
> +		error = host->ops->prepare(host);
> +		if (error) {
> +			kfree(host);
> +			return NULL;
> +		}
> +	}
>  	error = device_register(&host->dev);
>  	if (error) {
>  		put_device(&host->dev);
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 79a8894..a1dc9f2 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  #endif
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 dombus,
> -		struct list_head *resources, void *sysdata);
> +		struct device *parent, u32 dombus, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c8e074d..59d9be3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
> +		bridge->ops->set_root_bus_speed(bridge);

Before this patch, can you do this:

  - Rename the powerpc pcibios_root_bridge_prepare() to
    pcibios_set_root_bus_speed() and add a call to it here

  - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()

Then this patch will make a lot more sense because it will look like this,
with the host bridge ops call right next to the matching pcibios call:

  +	if (host->ops && host->ops->prepare) {
  +		error = host->ops->prepare(host);
  +		...
  +	}
	pcibios_root_bridge_prepare(...);

  +	if (bridge->ops && bridge->ops->set_root_bus_speed)
  +		bridge->ops->set_root_bus_speed(bridge);
	pcibios_set_root_bus_speed(...);

>  	error = pcibios_root_bridge_prepare(bridge);
>  	if (error)
>  		goto err_out;
> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>  		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
> -	max = pci_scan_child_bus(b);
> -
> -	if (!found)
> -		pci_bus_update_busn_res_end(b, max);
> +	if (host->ops && host->ops->scan_bus) {
> +		host->ops->scan_bus(host);
> +	} else {
> +		max = pci_scan_child_bus(b);
> +		if (!found)
> +			pci_bus_update_busn_res_end(b, max);
> +	}

I think host->ops->scan_bus() should have the same prototype as
pci_scan_child_bus(), and it should return max, and you should do the same
busn update as when you call pci_scan_child_bus().  So the code would look
like this:

    if (host->ops && host->ops->scan_bus)
	max = host->ops->scan_bus(b);
    else
	max = pci_scan_child_bus(b);

    if (!found)
	pci_bus_update_busn_res_end(b, max);

>  
>  	return b;
>  }
> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b621f5b..e9922b1 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  	return (pdev->error_state != pci_channel_io_normal);
>  }
>  
> +struct pci_host_bridge;
> +struct pci_host_bridge_ops {
> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> +	int (*prepare)(struct pci_host_bridge *host);
> +	void (*scan_bus)(struct pci_host_bridge *);

Needs an argument name to match the style of the other ops.

> +};
> +
>  struct pci_host_bridge {
>  	u16	domain;
>  	u16 busnum;
> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
>  	struct list_head list;
> +	struct pci_host_bridge_ops *ops;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-12  3:23   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:09AM +0800, Yijing Wang wrote:
> Now we have weak functions like pcibios_root_bridge_prepare()
> to setup pci host bridge, We could introduce pci_host_bridge_ops
> which contain host bridge specific ops to setup pci_host_bridge.
> Then host bridge driver could add pci_host_bridge_ops hooks
> intead of weak function to setup pci_host_bridge.
> This patch add following pci_host_bridge_ops hooks:
> 
> pci_host_bridge_ops {
> 	/* set root bus speed, some platform need this like powerpc */
> 	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> 	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
> 	int (*prepare)(struct pci_host_bridge *host);
> 	/* platform specific of scan hook to scan pci device */
> 	void (*scan_bus)(struct pci_host_bridge *);
> }
> We could easily extend it to support different host bridge
> specific operations.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   12 ++++++++++--
>  drivers/pci/pci.h         |    4 ++--
>  drivers/pci/probe.c       |   17 +++++++++++------
>  include/linux/pci.h       |    8 ++++++++
>  4 files changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3c34c49..bc1de59 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
>  }
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 db,
> -		struct list_head *resources, void *sysdata)
> +		struct device *parent, u32 db, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops)
>  {
>  	int error;
>  	int bus = PCI_BUSNUM(db);
> @@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		}
>  	mutex_unlock(&phb_mutex);
>  
> +	host->ops = ops;
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
>  			host->busnum);
>  
> +	if (host->ops && host->ops->prepare) {
> +		error = host->ops->prepare(host);
> +		if (error) {
> +			kfree(host);
> +			return NULL;
> +		}
> +	}
>  	error = device_register(&host->dev);
>  	if (error) {
>  		put_device(&host->dev);
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 79a8894..a1dc9f2 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  #endif
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 dombus,
> -		struct list_head *resources, void *sysdata);
> +		struct device *parent, u32 dombus, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c8e074d..59d9be3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
> +		bridge->ops->set_root_bus_speed(bridge);

Before this patch, can you do this:

  - Rename the powerpc pcibios_root_bridge_prepare() to
    pcibios_set_root_bus_speed() and add a call to it here

  - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()

Then this patch will make a lot more sense because it will look like this,
with the host bridge ops call right next to the matching pcibios call:

  +	if (host->ops && host->ops->prepare) {
  +		error = host->ops->prepare(host);
  +		...
  +	}
	pcibios_root_bridge_prepare(...);

  +	if (bridge->ops && bridge->ops->set_root_bus_speed)
  +		bridge->ops->set_root_bus_speed(bridge);
	pcibios_set_root_bus_speed(...);

>  	error = pcibios_root_bridge_prepare(bridge);
>  	if (error)
>  		goto err_out;
> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>  		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
> -	max = pci_scan_child_bus(b);
> -
> -	if (!found)
> -		pci_bus_update_busn_res_end(b, max);
> +	if (host->ops && host->ops->scan_bus) {
> +		host->ops->scan_bus(host);
> +	} else {
> +		max = pci_scan_child_bus(b);
> +		if (!found)
> +			pci_bus_update_busn_res_end(b, max);
> +	}

I think host->ops->scan_bus() should have the same prototype as
pci_scan_child_bus(), and it should return max, and you should do the same
busn update as when you call pci_scan_child_bus().  So the code would look
like this:

    if (host->ops && host->ops->scan_bus)
	max = host->ops->scan_bus(b);
    else
	max = pci_scan_child_bus(b);

    if (!found)
	pci_bus_update_busn_res_end(b, max);

>  
>  	return b;
>  }
> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b621f5b..e9922b1 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  	return (pdev->error_state != pci_channel_io_normal);
>  }
>  
> +struct pci_host_bridge;
> +struct pci_host_bridge_ops {
> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> +	int (*prepare)(struct pci_host_bridge *host);
> +	void (*scan_bus)(struct pci_host_bridge *);

Needs an argument name to match the style of the other ops.

> +};
> +
>  struct pci_host_bridge {
>  	u16	domain;
>  	u16 busnum;
> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
>  	struct list_head list;
> +	struct pci_host_bridge_ops *ops;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12  3:23     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:09AM +0800, Yijing Wang wrote:
> Now we have weak functions like pcibios_root_bridge_prepare()
> to setup pci host bridge, We could introduce pci_host_bridge_ops
> which contain host bridge specific ops to setup pci_host_bridge.
> Then host bridge driver could add pci_host_bridge_ops hooks
> intead of weak function to setup pci_host_bridge.
> This patch add following pci_host_bridge_ops hooks:
> 
> pci_host_bridge_ops {
> 	/* set root bus speed, some platform need this like powerpc */
> 	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> 	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
> 	int (*prepare)(struct pci_host_bridge *host);
> 	/* platform specific of scan hook to scan pci device */
> 	void (*scan_bus)(struct pci_host_bridge *);
> }
> We could easily extend it to support different host bridge
> specific operations.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   12 ++++++++++--
>  drivers/pci/pci.h         |    4 ++--
>  drivers/pci/probe.c       |   17 +++++++++++------
>  include/linux/pci.h       |    8 ++++++++
>  4 files changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3c34c49..bc1de59 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
>  }
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 db,
> -		struct list_head *resources, void *sysdata)
> +		struct device *parent, u32 db, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops)
>  {
>  	int error;
>  	int bus = PCI_BUSNUM(db);
> @@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		}
>  	mutex_unlock(&phb_mutex);
>  
> +	host->ops = ops;
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
>  			host->busnum);
>  
> +	if (host->ops && host->ops->prepare) {
> +		error = host->ops->prepare(host);
> +		if (error) {
> +			kfree(host);
> +			return NULL;
> +		}
> +	}
>  	error = device_register(&host->dev);
>  	if (error) {
>  		put_device(&host->dev);
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 79a8894..a1dc9f2 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  #endif
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 dombus,
> -		struct list_head *resources, void *sysdata);
> +		struct device *parent, u32 dombus, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c8e074d..59d9be3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
> +		bridge->ops->set_root_bus_speed(bridge);

Before this patch, can you do this:

  - Rename the powerpc pcibios_root_bridge_prepare() to
    pcibios_set_root_bus_speed() and add a call to it here

  - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()

Then this patch will make a lot more sense because it will look like this,
with the host bridge ops call right next to the matching pcibios call:

  +	if (host->ops && host->ops->prepare) {
  +		error = host->ops->prepare(host);
  +		...
  +	}
	pcibios_root_bridge_prepare(...);

  +	if (bridge->ops && bridge->ops->set_root_bus_speed)
  +		bridge->ops->set_root_bus_speed(bridge);
	pcibios_set_root_bus_speed(...);

>  	error = pcibios_root_bridge_prepare(bridge);
>  	if (error)
>  		goto err_out;
> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>  		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
> -	max = pci_scan_child_bus(b);
> -
> -	if (!found)
> -		pci_bus_update_busn_res_end(b, max);
> +	if (host->ops && host->ops->scan_bus) {
> +		host->ops->scan_bus(host);
> +	} else {
> +		max = pci_scan_child_bus(b);
> +		if (!found)
> +			pci_bus_update_busn_res_end(b, max);
> +	}

I think host->ops->scan_bus() should have the same prototype as
pci_scan_child_bus(), and it should return max, and you should do the same
busn update as when you call pci_scan_child_bus().  So the code would look
like this:

    if (host->ops && host->ops->scan_bus)
	max = host->ops->scan_bus(b);
    else
	max = pci_scan_child_bus(b);

    if (!found)
	pci_bus_update_busn_res_end(b, max);

>  
>  	return b;
>  }
> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b621f5b..e9922b1 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  	return (pdev->error_state != pci_channel_io_normal);
>  }
>  
> +struct pci_host_bridge;
> +struct pci_host_bridge_ops {
> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> +	int (*prepare)(struct pci_host_bridge *host);
> +	void (*scan_bus)(struct pci_host_bridge *);

Needs an argument name to match the style of the other ops.

> +};
> +
>  struct pci_host_bridge {
>  	u16	domain;
>  	u16 busnum;
> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
>  	struct list_head list;
> +	struct pci_host_bridge_ops *ops;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12  3:23     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:09AM +0800, Yijing Wang wrote:
> Now we have weak functions like pcibios_root_bridge_prepare()
> to setup pci host bridge, We could introduce pci_host_bridge_ops
> which contain host bridge specific ops to setup pci_host_bridge.
> Then host bridge driver could add pci_host_bridge_ops hooks
> intead of weak function to setup pci_host_bridge.
> This patch add following pci_host_bridge_ops hooks:
> 
> pci_host_bridge_ops {
> 	/* set root bus speed, some platform need this like powerpc */
> 	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> 	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
> 	int (*prepare)(struct pci_host_bridge *host);
> 	/* platform specific of scan hook to scan pci device */
> 	void (*scan_bus)(struct pci_host_bridge *);
> }
> We could easily extend it to support different host bridge
> specific operations.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   12 ++++++++++--
>  drivers/pci/pci.h         |    4 ++--
>  drivers/pci/probe.c       |   17 +++++++++++------
>  include/linux/pci.h       |    8 ++++++++
>  4 files changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3c34c49..bc1de59 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
>  }
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 db,
> -		struct list_head *resources, void *sysdata)
> +		struct device *parent, u32 db, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops)
>  {
>  	int error;
>  	int bus = PCI_BUSNUM(db);
> @@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		}
>  	mutex_unlock(&phb_mutex);
>  
> +	host->ops = ops;
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
>  			host->busnum);
>  
> +	if (host->ops && host->ops->prepare) {
> +		error = host->ops->prepare(host);
> +		if (error) {
> +			kfree(host);
> +			return NULL;
> +		}
> +	}
>  	error = device_register(&host->dev);
>  	if (error) {
>  		put_device(&host->dev);
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 79a8894..a1dc9f2 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  #endif
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 dombus,
> -		struct list_head *resources, void *sysdata);
> +		struct device *parent, u32 dombus, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c8e074d..59d9be3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
> +		bridge->ops->set_root_bus_speed(bridge);

Before this patch, can you do this:

  - Rename the powerpc pcibios_root_bridge_prepare() to
    pcibios_set_root_bus_speed() and add a call to it here

  - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()

Then this patch will make a lot more sense because it will look like this,
with the host bridge ops call right next to the matching pcibios call:

  +	if (host->ops && host->ops->prepare) {
  +		error = host->ops->prepare(host);
  +		...
  +	}
	pcibios_root_bridge_prepare(...);

  +	if (bridge->ops && bridge->ops->set_root_bus_speed)
  +		bridge->ops->set_root_bus_speed(bridge);
	pcibios_set_root_bus_speed(...);

>  	error = pcibios_root_bridge_prepare(bridge);
>  	if (error)
>  		goto err_out;
> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>  		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
> -	max = pci_scan_child_bus(b);
> -
> -	if (!found)
> -		pci_bus_update_busn_res_end(b, max);
> +	if (host->ops && host->ops->scan_bus) {
> +		host->ops->scan_bus(host);
> +	} else {
> +		max = pci_scan_child_bus(b);
> +		if (!found)
> +			pci_bus_update_busn_res_end(b, max);
> +	}

I think host->ops->scan_bus() should have the same prototype as
pci_scan_child_bus(), and it should return max, and you should do the same
busn update as when you call pci_scan_child_bus().  So the code would look
like this:

    if (host->ops && host->ops->scan_bus)
	max = host->ops->scan_bus(b);
    else
	max = pci_scan_child_bus(b);

    if (!found)
	pci_bus_update_busn_res_end(b, max);

>  
>  	return b;
>  }
> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b621f5b..e9922b1 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  	return (pdev->error_state != pci_channel_io_normal);
>  }
>  
> +struct pci_host_bridge;
> +struct pci_host_bridge_ops {
> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> +	int (*prepare)(struct pci_host_bridge *host);
> +	void (*scan_bus)(struct pci_host_bridge *);

Needs an argument name to match the style of the other ops.

> +};
> +
>  struct pci_host_bridge {
>  	u16	domain;
>  	u16 busnum;
> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
>  	struct list_head list;
> +	struct pci_host_bridge_ops *ops;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12  3:23     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:09AM +0800, Yijing Wang wrote:
> Now we have weak functions like pcibios_root_bridge_prepare()
> to setup pci host bridge, We could introduce pci_host_bridge_ops
> which contain host bridge specific ops to setup pci_host_bridge.
> Then host bridge driver could add pci_host_bridge_ops hooks
> intead of weak function to setup pci_host_bridge.
> This patch add following pci_host_bridge_ops hooks:
> 
> pci_host_bridge_ops {
> 	/* set root bus speed, some platform need this like powerpc */
> 	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> 	/* setup pci_host_bridge before pci_host_bridge be added to driver core */
> 	int (*prepare)(struct pci_host_bridge *host);
> 	/* platform specific of scan hook to scan pci device */
> 	void (*scan_bus)(struct pci_host_bridge *);
> }
> We could easily extend it to support different host bridge
> specific operations.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   12 ++++++++++--
>  drivers/pci/pci.h         |    4 ++--
>  drivers/pci/probe.c       |   17 +++++++++++------
>  include/linux/pci.h       |    8 ++++++++
>  4 files changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 3c34c49..bc1de59 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev)
>  }
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 db,
> -		struct list_head *resources, void *sysdata)
> +		struct device *parent, u32 db, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops)
>  {
>  	int error;
>  	int bus = PCI_BUSNUM(db);
> @@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		}
>  	mutex_unlock(&phb_mutex);
>  
> +	host->ops = ops;
>  	host->dev.parent = parent;
>  	INIT_LIST_HEAD(&host->windows);
>  	host->dev.release = pci_release_host_bridge_dev;
> @@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(
>  	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
>  			host->busnum);
>  
> +	if (host->ops && host->ops->prepare) {
> +		error = host->ops->prepare(host);
> +		if (error) {
> +			kfree(host);
> +			return NULL;
> +		}
> +	}
>  	error = device_register(&host->dev);
>  	if (error) {
>  		put_device(&host->dev);
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 79a8894..a1dc9f2 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -324,8 +324,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  #endif
>  
>  struct pci_host_bridge *pci_create_host_bridge(
> -		struct device *parent, u32 dombus,
> -		struct list_head *resources, void *sysdata);
> +		struct device *parent, u32 dombus, struct list_head *resources,
> +		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c8e074d..59d9be3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
> +		bridge->ops->set_root_bus_speed(bridge);

Before this patch, can you do this:

  - Rename the powerpc pcibios_root_bridge_prepare() to
    pcibios_set_root_bus_speed() and add a call to it here

  - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()

Then this patch will make a lot more sense because it will look like this,
with the host bridge ops call right next to the matching pcibios call:

  +	if (host->ops && host->ops->prepare) {
  +		error = host->ops->prepare(host);
  +		...
  +	}
	pcibios_root_bridge_prepare(...);

  +	if (bridge->ops && bridge->ops->set_root_bus_speed)
  +		bridge->ops->set_root_bus_speed(bridge);
	pcibios_set_root_bus_speed(...);

>  	error = pcibios_root_bridge_prepare(bridge);
>  	if (error)
>  		goto err_out;
> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>  		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
> -	max = pci_scan_child_bus(b);
> -
> -	if (!found)
> -		pci_bus_update_busn_res_end(b, max);
> +	if (host->ops && host->ops->scan_bus) {
> +		host->ops->scan_bus(host);
> +	} else {
> +		max = pci_scan_child_bus(b);
> +		if (!found)
> +			pci_bus_update_busn_res_end(b, max);
> +	}

I think host->ops->scan_bus() should have the same prototype as
pci_scan_child_bus(), and it should return max, and you should do the same
busn update as when you call pci_scan_child_bus().  So the code would look
like this:

    if (host->ops && host->ops->scan_bus)
	max = host->ops->scan_bus(b);
    else
	max = pci_scan_child_bus(b);

    if (!found)
	pci_bus_update_busn_res_end(b, max);

>  
>  	return b;
>  }
> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  {
>  	struct pci_host_bridge *host;
>  
> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>  	if (!host)
>  		return NULL;
>  
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b621f5b..e9922b1 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  	return (pdev->error_state != pci_channel_io_normal);
>  }
>  
> +struct pci_host_bridge;
> +struct pci_host_bridge_ops {
> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
> +	int (*prepare)(struct pci_host_bridge *host);
> +	void (*scan_bus)(struct pci_host_bridge *);

Needs an argument name to match the style of the other ops.

> +};
> +
>  struct pci_host_bridge {
>  	u16	domain;
>  	u16 busnum;
> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
>  	struct list_head list;
> +	struct pci_host_bridge_ops *ops;
>  	void (*release_fn)(struct pci_host_bridge *);
>  	void *release_data;
>  };
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:25     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:25 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:10AM +0800, Yijing Wang wrote:
> Introduce new scan function pci_scan_host_bridge() to
> support host bridge drivers that need to provide platform
> own pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c |   22 ++++++++++++++++++++++
>  include/linux/pci.h |    4 ++++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 59d9be3..99f17e3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
>  	return b;
>  }
>  
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 db, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops)

Drop the "phb_" prefix.

> +{
> +	struct pci_host_bridge *host;
> +	struct pci_bus *bus;
> +
> +	host = pci_create_host_bridge(parent, db, resources,
> +			sysdata, phb_ops);
> +	if (!host)
> +		return NULL;
> +
> +	bus = __pci_scan_root_bus(host, ops);
> +	if (!bus)
> +		pci_free_host_bridge(host);
> +
> +	return host;
> +}
> +EXPORT_SYMBOL(pci_scan_host_bridge);
> +
> +
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index e9922b1..28eafb5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 dombus, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>  				int busnr);
>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
  2015-03-09  2:34   ` Yijing Wang
                     ` (5 preceding siblings ...)
  (?)
@ 2015-03-12  3:25   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:25 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:10AM +0800, Yijing Wang wrote:
> Introduce new scan function pci_scan_host_bridge() to
> support host bridge drivers that need to provide platform
> own pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c |   22 ++++++++++++++++++++++
>  include/linux/pci.h |    4 ++++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 59d9be3..99f17e3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
>  	return b;
>  }
>  
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 db, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops)

Drop the "phb_" prefix.

> +{
> +	struct pci_host_bridge *host;
> +	struct pci_bus *bus;
> +
> +	host = pci_create_host_bridge(parent, db, resources,
> +			sysdata, phb_ops);
> +	if (!host)
> +		return NULL;
> +
> +	bus = __pci_scan_root_bus(host, ops);
> +	if (!bus)
> +		pci_free_host_bridge(host);
> +
> +	return host;
> +}
> +EXPORT_SYMBOL(pci_scan_host_bridge);
> +
> +
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index e9922b1..28eafb5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 dombus, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>  				int busnr);
>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12  3:25     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:25 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:10AM +0800, Yijing Wang wrote:
> Introduce new scan function pci_scan_host_bridge() to
> support host bridge drivers that need to provide platform
> own pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c |   22 ++++++++++++++++++++++
>  include/linux/pci.h |    4 ++++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 59d9be3..99f17e3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
>  	return b;
>  }
>  
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 db, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops)

Drop the "phb_" prefix.

> +{
> +	struct pci_host_bridge *host;
> +	struct pci_bus *bus;
> +
> +	host = pci_create_host_bridge(parent, db, resources,
> +			sysdata, phb_ops);
> +	if (!host)
> +		return NULL;
> +
> +	bus = __pci_scan_root_bus(host, ops);
> +	if (!bus)
> +		pci_free_host_bridge(host);
> +
> +	return host;
> +}
> +EXPORT_SYMBOL(pci_scan_host_bridge);
> +
> +
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index e9922b1..28eafb5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 dombus, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>  				int busnr);
>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
> -- 
> 1.7.1
> 
> --
> 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

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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12  3:25     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:10AM +0800, Yijing Wang wrote:
> Introduce new scan function pci_scan_host_bridge() to
> support host bridge drivers that need to provide platform
> own pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c |   22 ++++++++++++++++++++++
>  include/linux/pci.h |    4 ++++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 59d9be3..99f17e3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
>  	return b;
>  }
>  
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 db, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops)

Drop the "phb_" prefix.

> +{
> +	struct pci_host_bridge *host;
> +	struct pci_bus *bus;
> +
> +	host = pci_create_host_bridge(parent, db, resources,
> +			sysdata, phb_ops);
> +	if (!host)
> +		return NULL;
> +
> +	bus = __pci_scan_root_bus(host, ops);
> +	if (!bus)
> +		pci_free_host_bridge(host);
> +
> +	return host;
> +}
> +EXPORT_SYMBOL(pci_scan_host_bridge);
> +
> +
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index e9922b1..28eafb5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 dombus, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>  				int busnr);
>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12  3:25     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:25 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:10AM +0800, Yijing Wang wrote:
> Introduce new scan function pci_scan_host_bridge() to
> support host bridge drivers that need to provide platform
> own pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/probe.c |   22 ++++++++++++++++++++++
>  include/linux/pci.h |    4 ++++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 59d9be3..99f17e3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(
>  	return b;
>  }
>  
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 db, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops)

Drop the "phb_" prefix.

> +{
> +	struct pci_host_bridge *host;
> +	struct pci_bus *bus;
> +
> +	host = pci_create_host_bridge(parent, db, resources,
> +			sysdata, phb_ops);
> +	if (!host)
> +		return NULL;
> +
> +	bus = __pci_scan_root_bus(host, ops);
> +	if (!bus)
> +		pci_free_host_bridge(host);
> +
> +	return host;
> +}
> +EXPORT_SYMBOL(pci_scan_host_bridge);
> +
> +
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>  {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index e9922b1..28eafb5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>  					     struct pci_ops *ops, void *sysdata,
>  					     struct list_head *resources);
> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
> +		u32 dombus, struct pci_ops *ops, void *sysdata,
> +		struct list_head *resources,
> +		struct pci_host_bridge_ops *phb_ops);
>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>  				int busnr);
>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
> -- 
> 1.7.1
> 
> --
> 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

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
  2015-03-09  2:34   ` Yijing Wang
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12  3:30     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:30 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

On Mon, Mar 09, 2015 at 10:34:17AM +0800, Yijing Wang wrote:
> Now we could use pci_scan_host_bridge() to scan
> pci buses, provide sparc specific pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: sparclinux@vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 21f804a..7e28f74 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
>  		pci_claim_bus_resources(child_bus);
>  }
>  
> +static void pci_host_bridge_of_scan_bus(
> +		struct pci_host_bridge *host)
> +{
> +	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
> +	struct device_node *node = pbm->op->dev.of_node;
> +
> +	pci_of_scan_bus(pbm, node, host->bus);
> +}
> +
> +static struct pci_host_bridge_ops phb_ops = {
> +	.scan_bus = pci_host_bridge_of_scan_bus,
> +};
> +
>  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  				 struct device *parent)
>  {
>  	LIST_HEAD(resources);
>  	struct device_node *node = pbm->op->dev.of_node;
> -	struct pci_bus *bus;
> +	struct pci_host_bridge *host;
>  
>  	printk("PCI: Scanning PBM %s\n", node->full_name);
>  
> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent,
> +	host = pci_scan_host_bridge(parent,
>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> -			pbm->pci_ops, pbm, &resources);
> -	if (!bus) {
> -		printk(KERN_ERR "Failed to create bus for %s\n",
> +			pbm->pci_ops, pbm, &resources, &phb_ops);
> +	if (!host) {
> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>  		       node->full_name);
>  		pci_free_resource_list(&resources);
>  		return NULL;
>  	}
>  

I would keep "bus" and set it here:

	bus = host->bus;

That would remove some lines from your patch that really didn't change,
which makes it easier to see what actually *is* changing, namely, you're
removing the pci_of_scan_bus() call because it is now done inside
pci_scan_host_bridge().

> -	pci_of_scan_bus(pbm, node, bus);
> -	pci_bus_register_of_sysfs(bus);
> +	pci_bus_register_of_sysfs(host->bus);
>  
> -	pci_claim_bus_resources(bus);
> -	pci_bus_add_devices(bus);
> -	return bus;
> +	pci_claim_bus_resources(host->bus);
> +	pci_bus_add_devices(host->bus);
> +	return host->bus;
>  }
>  
>  void pcibios_fixup_bus(struct pci_bus *pbus)
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
  2015-03-09  2:34   ` Yijing Wang
                     ` (4 preceding siblings ...)
  (?)
@ 2015-03-12  3:30   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:30 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

On Mon, Mar 09, 2015 at 10:34:17AM +0800, Yijing Wang wrote:
> Now we could use pci_scan_host_bridge() to scan
> pci buses, provide sparc specific pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: sparclinux@vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 21f804a..7e28f74 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
>  		pci_claim_bus_resources(child_bus);
>  }
>  
> +static void pci_host_bridge_of_scan_bus(
> +		struct pci_host_bridge *host)
> +{
> +	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
> +	struct device_node *node = pbm->op->dev.of_node;
> +
> +	pci_of_scan_bus(pbm, node, host->bus);
> +}
> +
> +static struct pci_host_bridge_ops phb_ops = {
> +	.scan_bus = pci_host_bridge_of_scan_bus,
> +};
> +
>  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  				 struct device *parent)
>  {
>  	LIST_HEAD(resources);
>  	struct device_node *node = pbm->op->dev.of_node;
> -	struct pci_bus *bus;
> +	struct pci_host_bridge *host;
>  
>  	printk("PCI: Scanning PBM %s\n", node->full_name);
>  
> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent,
> +	host = pci_scan_host_bridge(parent,
>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> -			pbm->pci_ops, pbm, &resources);
> -	if (!bus) {
> -		printk(KERN_ERR "Failed to create bus for %s\n",
> +			pbm->pci_ops, pbm, &resources, &phb_ops);
> +	if (!host) {
> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>  		       node->full_name);
>  		pci_free_resource_list(&resources);
>  		return NULL;
>  	}
>  

I would keep "bus" and set it here:

	bus = host->bus;

That would remove some lines from your patch that really didn't change,
which makes it easier to see what actually *is* changing, namely, you're
removing the pci_of_scan_bus() call because it is now done inside
pci_scan_host_bridge().

> -	pci_of_scan_bus(pbm, node, bus);
> -	pci_bus_register_of_sysfs(bus);
> +	pci_bus_register_of_sysfs(host->bus);
>  
> -	pci_claim_bus_resources(bus);
> -	pci_bus_add_devices(bus);
> -	return bus;
> +	pci_claim_bus_resources(host->bus);
> +	pci_bus_add_devices(host->bus);
> +	return host->bus;
>  }
>  
>  void pcibios_fixup_bus(struct pci_bus *pbus)
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12  3:30     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:30 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

On Mon, Mar 09, 2015 at 10:34:17AM +0800, Yijing Wang wrote:
> Now we could use pci_scan_host_bridge() to scan
> pci buses, provide sparc specific pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: sparclinux@vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 21f804a..7e28f74 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
>  		pci_claim_bus_resources(child_bus);
>  }
>  
> +static void pci_host_bridge_of_scan_bus(
> +		struct pci_host_bridge *host)
> +{
> +	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
> +	struct device_node *node = pbm->op->dev.of_node;
> +
> +	pci_of_scan_bus(pbm, node, host->bus);
> +}
> +
> +static struct pci_host_bridge_ops phb_ops = {
> +	.scan_bus = pci_host_bridge_of_scan_bus,
> +};
> +
>  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  				 struct device *parent)
>  {
>  	LIST_HEAD(resources);
>  	struct device_node *node = pbm->op->dev.of_node;
> -	struct pci_bus *bus;
> +	struct pci_host_bridge *host;
>  
>  	printk("PCI: Scanning PBM %s\n", node->full_name);
>  
> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent,
> +	host = pci_scan_host_bridge(parent,
>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> -			pbm->pci_ops, pbm, &resources);
> -	if (!bus) {
> -		printk(KERN_ERR "Failed to create bus for %s\n",
> +			pbm->pci_ops, pbm, &resources, &phb_ops);
> +	if (!host) {
> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>  		       node->full_name);
>  		pci_free_resource_list(&resources);
>  		return NULL;
>  	}
>  

I would keep "bus" and set it here:

	bus = host->bus;

That would remove some lines from your patch that really didn't change,
which makes it easier to see what actually *is* changing, namely, you're
removing the pci_of_scan_bus() call because it is now done inside
pci_scan_host_bridge().

> -	pci_of_scan_bus(pbm, node, bus);
> -	pci_bus_register_of_sysfs(bus);
> +	pci_bus_register_of_sysfs(host->bus);
>  
> -	pci_claim_bus_resources(bus);
> -	pci_bus_add_devices(bus);
> -	return bus;
> +	pci_claim_bus_resources(host->bus);
> +	pci_bus_add_devices(host->bus);
> +	return host->bus;
>  }
>  
>  void pcibios_fixup_bus(struct pci_bus *pbus)
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12  3:30     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:17AM +0800, Yijing Wang wrote:
> Now we could use pci_scan_host_bridge() to scan
> pci buses, provide sparc specific pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: sparclinux@vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 21f804a..7e28f74 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
>  		pci_claim_bus_resources(child_bus);
>  }
>  
> +static void pci_host_bridge_of_scan_bus(
> +		struct pci_host_bridge *host)
> +{
> +	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
> +	struct device_node *node = pbm->op->dev.of_node;
> +
> +	pci_of_scan_bus(pbm, node, host->bus);
> +}
> +
> +static struct pci_host_bridge_ops phb_ops = {
> +	.scan_bus = pci_host_bridge_of_scan_bus,
> +};
> +
>  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  				 struct device *parent)
>  {
>  	LIST_HEAD(resources);
>  	struct device_node *node = pbm->op->dev.of_node;
> -	struct pci_bus *bus;
> +	struct pci_host_bridge *host;
>  
>  	printk("PCI: Scanning PBM %s\n", node->full_name);
>  
> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent,
> +	host = pci_scan_host_bridge(parent,
>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> -			pbm->pci_ops, pbm, &resources);
> -	if (!bus) {
> -		printk(KERN_ERR "Failed to create bus for %s\n",
> +			pbm->pci_ops, pbm, &resources, &phb_ops);
> +	if (!host) {
> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>  		       node->full_name);
>  		pci_free_resource_list(&resources);
>  		return NULL;
>  	}
>  

I would keep "bus" and set it here:

	bus = host->bus;

That would remove some lines from your patch that really didn't change,
which makes it easier to see what actually *is* changing, namely, you're
removing the pci_of_scan_bus() call because it is now done inside
pci_scan_host_bridge().

> -	pci_of_scan_bus(pbm, node, bus);
> -	pci_bus_register_of_sysfs(bus);
> +	pci_bus_register_of_sysfs(host->bus);
>  
> -	pci_claim_bus_resources(bus);
> -	pci_bus_add_devices(bus);
> -	return bus;
> +	pci_claim_bus_resources(host->bus);
> +	pci_bus_add_devices(host->bus);
> +	return host->bus;
>  }
>  
>  void pcibios_fixup_bus(struct pci_bus *pbus)
> -- 
> 1.7.1
> 

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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12  3:30     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:17AM +0800, Yijing Wang wrote:
> Now we could use pci_scan_host_bridge() to scan
> pci buses, provide sparc specific pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: sparclinux at vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 21f804a..7e28f74 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
>  		pci_claim_bus_resources(child_bus);
>  }
>  
> +static void pci_host_bridge_of_scan_bus(
> +		struct pci_host_bridge *host)
> +{
> +	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
> +	struct device_node *node = pbm->op->dev.of_node;
> +
> +	pci_of_scan_bus(pbm, node, host->bus);
> +}
> +
> +static struct pci_host_bridge_ops phb_ops = {
> +	.scan_bus = pci_host_bridge_of_scan_bus,
> +};
> +
>  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  				 struct device *parent)
>  {
>  	LIST_HEAD(resources);
>  	struct device_node *node = pbm->op->dev.of_node;
> -	struct pci_bus *bus;
> +	struct pci_host_bridge *host;
>  
>  	printk("PCI: Scanning PBM %s\n", node->full_name);
>  
> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent,
> +	host = pci_scan_host_bridge(parent,
>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> -			pbm->pci_ops, pbm, &resources);
> -	if (!bus) {
> -		printk(KERN_ERR "Failed to create bus for %s\n",
> +			pbm->pci_ops, pbm, &resources, &phb_ops);
> +	if (!host) {
> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>  		       node->full_name);
>  		pci_free_resource_list(&resources);
>  		return NULL;
>  	}
>  

I would keep "bus" and set it here:

	bus = host->bus;

That would remove some lines from your patch that really didn't change,
which makes it easier to see what actually *is* changing, namely, you're
removing the pci_of_scan_bus() call because it is now done inside
pci_scan_host_bridge().

> -	pci_of_scan_bus(pbm, node, bus);
> -	pci_bus_register_of_sysfs(bus);
> +	pci_bus_register_of_sysfs(host->bus);
>  
> -	pci_claim_bus_resources(bus);
> -	pci_bus_add_devices(bus);
> -	return bus;
> +	pci_claim_bus_resources(host->bus);
> +	pci_bus_add_devices(host->bus);
> +	return host->bus;
>  }
>  
>  void pcibios_fixup_bus(struct pci_bus *pbus)
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12  3:30     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:30 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

On Mon, Mar 09, 2015 at 10:34:17AM +0800, Yijing Wang wrote:
> Now we could use pci_scan_host_bridge() to scan
> pci buses, provide sparc specific pci_host_bridge_ops.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: sparclinux@vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/sparc/kernel/pci.c |   32 ++++++++++++++++++++++----------
>  1 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 21f804a..7e28f74 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
>  		pci_claim_bus_resources(child_bus);
>  }
>  
> +static void pci_host_bridge_of_scan_bus(
> +		struct pci_host_bridge *host)
> +{
> +	struct pci_pbm_info *pbm = dev_get_drvdata(&host->dev);
> +	struct device_node *node = pbm->op->dev.of_node;
> +
> +	pci_of_scan_bus(pbm, node, host->bus);
> +}
> +
> +static struct pci_host_bridge_ops phb_ops = {
> +	.scan_bus = pci_host_bridge_of_scan_bus,
> +};
> +
>  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  				 struct device *parent)
>  {
>  	LIST_HEAD(resources);
>  	struct device_node *node = pbm->op->dev.of_node;
> -	struct pci_bus *bus;
> +	struct pci_host_bridge *host;
>  
>  	printk("PCI: Scanning PBM %s\n", node->full_name);
>  
> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>  	pbm->busn.end	= pbm->pci_last_busno;
>  	pbm->busn.flags	= IORESOURCE_BUS;
>  	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent,
> +	host = pci_scan_host_bridge(parent,
>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> -			pbm->pci_ops, pbm, &resources);
> -	if (!bus) {
> -		printk(KERN_ERR "Failed to create bus for %s\n",
> +			pbm->pci_ops, pbm, &resources, &phb_ops);
> +	if (!host) {
> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>  		       node->full_name);
>  		pci_free_resource_list(&resources);
>  		return NULL;
>  	}
>  

I would keep "bus" and set it here:

	bus = host->bus;

That would remove some lines from your patch that really didn't change,
which makes it easier to see what actually *is* changing, namely, you're
removing the pci_of_scan_bus() call because it is now done inside
pci_scan_host_bridge().

> -	pci_of_scan_bus(pbm, node, bus);
> -	pci_bus_register_of_sysfs(bus);
> +	pci_bus_register_of_sysfs(host->bus);
>  
> -	pci_claim_bus_resources(bus);
> -	pci_bus_add_devices(bus);
> -	return bus;
> +	pci_claim_bus_resources(host->bus);
> +	pci_bus_add_devices(host->bus);
> +	return host->bus;
>  }
>  
>  void pcibios_fixup_bus(struct pci_bus *pbus)
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:33     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:33 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12  3:33     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:33 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12  3:33     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:33 UTC (permalink / raw)
  To: linux-arm-kernel

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
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12  3:33     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:33 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:36     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:36 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-09  2:34   ` Yijing Wang
                     ` (5 preceding siblings ...)
  (?)
@ 2015-03-12  3:36   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:36 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12  3:36     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:36 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12  3:36     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:36 UTC (permalink / raw)
  To: linux-arm-kernel

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
> 

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12  3:36     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:36 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
> 

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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:43     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:43 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:25AM +0800, Yijing Wang wrote:
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |    6 +++---
>  drivers/pci/pci.h         |    2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index bc1de59..51f0a82 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  	return bus;
>  }
>  
> -static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
>  {
>  	struct pci_bus *root_bus = find_pci_root_bus(bus);
>  
> @@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>  void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
>  			     struct resource *res)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> @@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
>  void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  			     struct pci_bus_region *region)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index a1dc9f2..45252dd 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);

This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
pci_domain_nr().  Can you drop this patch and put the generic
pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
pci.c?

> +
>  #endif /* DRIVERS_PCI_H */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-12  3:43   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:43 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:25AM +0800, Yijing Wang wrote:
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |    6 +++---
>  drivers/pci/pci.h         |    2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index bc1de59..51f0a82 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  	return bus;
>  }
>  
> -static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
>  {
>  	struct pci_bus *root_bus = find_pci_root_bus(bus);
>  
> @@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>  void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
>  			     struct resource *res)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> @@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
>  void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  			     struct pci_bus_region *region)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index a1dc9f2..45252dd 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);

This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
pci_domain_nr().  Can you drop this patch and put the generic
pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
pci.c?

> +
>  #endif /* DRIVERS_PCI_H */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12  3:43     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:43 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:25AM +0800, Yijing Wang wrote:
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |    6 +++---
>  drivers/pci/pci.h         |    2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index bc1de59..51f0a82 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  	return bus;
>  }
>  
> -static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
>  {
>  	struct pci_bus *root_bus = find_pci_root_bus(bus);
>  
> @@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>  void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
>  			     struct resource *res)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> @@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
>  void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  			     struct pci_bus_region *region)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index a1dc9f2..45252dd 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);

This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
pci_domain_nr().  Can you drop this patch and put the generic
pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
pci.c?

> +
>  #endif /* DRIVERS_PCI_H */
> -- 
> 1.7.1
> 

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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12  3:43     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:25AM +0800, Yijing Wang wrote:
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |    6 +++---
>  drivers/pci/pci.h         |    2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index bc1de59..51f0a82 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  	return bus;
>  }
>  
> -static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
>  {
>  	struct pci_bus *root_bus = find_pci_root_bus(bus);
>  
> @@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>  void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
>  			     struct resource *res)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> @@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
>  void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  			     struct pci_bus_region *region)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index a1dc9f2..45252dd 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);

This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
pci_domain_nr().  Can you drop this patch and put the generic
pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
pci.c?

> +
>  #endif /* DRIVERS_PCI_H */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12  3:43     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:43 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:25AM +0800, Yijing Wang wrote:
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |    6 +++---
>  drivers/pci/pci.h         |    2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index bc1de59..51f0a82 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -103,7 +103,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  	return bus;
>  }
>  
> -static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)
>  {
>  	struct pci_bus *root_bus = find_pci_root_bus(bus);
>  
> @@ -121,7 +121,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>  void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
>  			     struct resource *res)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> @@ -146,7 +146,7 @@ static bool region_contains(struct pci_bus_region *region1,
>  void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  			     struct pci_bus_region *region)
>  {
> -	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>  	struct resource_entry *window;
>  	resource_size_t offset = 0;
>  
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index a1dc9f2..45252dd 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>  		void *sysdata, struct pci_host_bridge_ops *ops);
>  
>  void pci_free_host_bridge(struct pci_host_bridge *host);
> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);

This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
pci_domain_nr().  Can you drop this patch and put the generic
pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
pci.c?

> +
>  #endif /* DRIVERS_PCI_H */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:48     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:48 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
> Now we save the domain number in pci_host_bridge,
> we could remove pci_bus_assign_domain_nr() and
> clean the domain member in pci_bus.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |    5 -----
>  drivers/pci/probe.c |   12 ++++--------
>  include/linux/pci.h |    3 ---
>  3 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 2cf942b..4d8dfe4 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>  {
>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>  }
> -
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> -{
> -	bus->domain_nr = pci_assign_domain_nr(parent);
> -}

I think you forgot to remove the empty pci_bus_assign_domain_nr()
definition from include/linux/pci.h.

I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
removed *almost* everything that uses it.  I wonder how hard it would be to
get rid of that last little bit.

>  #endif
>  #endif
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 196f08a..9cd3ca2 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>  	}
>  }
>  
> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
> +static struct pci_bus *pci_alloc_bus(void)
>  {
>  	struct pci_bus *b;
>  
> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	INIT_LIST_HEAD(&b->resources);
>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	if (parent)
> -		b->domain_nr = parent->domain_nr;
> -#endif
> +
>  	return b;
>  }
>  
> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>  	/*
>  	 * Allocate a new bus, and inherit stuff from the parent..
>  	 */
> -	child = pci_alloc_bus(parent);
> +	child = pci_alloc_bus();
>  	if (!child)
>  		return NULL;
>  
> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>  	char *fmt;
>  
>  	parent = bridge->dev.parent;
> -	b = pci_alloc_bus(NULL);
> +	b = pci_alloc_bus();
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
> -	pci_bus_assign_domain_nr(b, parent);
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index dc1c710..ebc70bb 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -467,9 +467,6 @@ struct pci_bus {
>  	unsigned char	primary;	/* number of primary bridge */
>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	int		domain_nr;
> -#endif
>  
>  	char		name[48];
>  
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
  2015-03-09  2:34   ` Yijing Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-12  3:48   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:48 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
> Now we save the domain number in pci_host_bridge,
> we could remove pci_bus_assign_domain_nr() and
> clean the domain member in pci_bus.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |    5 -----
>  drivers/pci/probe.c |   12 ++++--------
>  include/linux/pci.h |    3 ---
>  3 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 2cf942b..4d8dfe4 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>  {
>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>  }
> -
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> -{
> -	bus->domain_nr = pci_assign_domain_nr(parent);
> -}

I think you forgot to remove the empty pci_bus_assign_domain_nr()
definition from include/linux/pci.h.

I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
removed *almost* everything that uses it.  I wonder how hard it would be to
get rid of that last little bit.

>  #endif
>  #endif
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 196f08a..9cd3ca2 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>  	}
>  }
>  
> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
> +static struct pci_bus *pci_alloc_bus(void)
>  {
>  	struct pci_bus *b;
>  
> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	INIT_LIST_HEAD(&b->resources);
>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	if (parent)
> -		b->domain_nr = parent->domain_nr;
> -#endif
> +
>  	return b;
>  }
>  
> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>  	/*
>  	 * Allocate a new bus, and inherit stuff from the parent..
>  	 */
> -	child = pci_alloc_bus(parent);
> +	child = pci_alloc_bus();
>  	if (!child)
>  		return NULL;
>  
> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>  	char *fmt;
>  
>  	parent = bridge->dev.parent;
> -	b = pci_alloc_bus(NULL);
> +	b = pci_alloc_bus();
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
> -	pci_bus_assign_domain_nr(b, parent);
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index dc1c710..ebc70bb 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -467,9 +467,6 @@ struct pci_bus {
>  	unsigned char	primary;	/* number of primary bridge */
>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	int		domain_nr;
> -#endif
>  
>  	char		name[48];
>  
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12  3:48     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:48 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
> Now we save the domain number in pci_host_bridge,
> we could remove pci_bus_assign_domain_nr() and
> clean the domain member in pci_bus.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |    5 -----
>  drivers/pci/probe.c |   12 ++++--------
>  include/linux/pci.h |    3 ---
>  3 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 2cf942b..4d8dfe4 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>  {
>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>  }
> -
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> -{
> -	bus->domain_nr = pci_assign_domain_nr(parent);
> -}

I think you forgot to remove the empty pci_bus_assign_domain_nr()
definition from include/linux/pci.h.

I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
removed *almost* everything that uses it.  I wonder how hard it would be to
get rid of that last little bit.

>  #endif
>  #endif
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 196f08a..9cd3ca2 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>  	}
>  }
>  
> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
> +static struct pci_bus *pci_alloc_bus(void)
>  {
>  	struct pci_bus *b;
>  
> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	INIT_LIST_HEAD(&b->resources);
>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	if (parent)
> -		b->domain_nr = parent->domain_nr;
> -#endif
> +
>  	return b;
>  }
>  
> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>  	/*
>  	 * Allocate a new bus, and inherit stuff from the parent..
>  	 */
> -	child = pci_alloc_bus(parent);
> +	child = pci_alloc_bus();
>  	if (!child)
>  		return NULL;
>  
> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>  	char *fmt;
>  
>  	parent = bridge->dev.parent;
> -	b = pci_alloc_bus(NULL);
> +	b = pci_alloc_bus();
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
> -	pci_bus_assign_domain_nr(b, parent);
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index dc1c710..ebc70bb 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -467,9 +467,6 @@ struct pci_bus {
>  	unsigned char	primary;	/* number of primary bridge */
>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	int		domain_nr;
> -#endif
>  
>  	char		name[48];
>  
> -- 
> 1.7.1
> 

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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12  3:48     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
> Now we save the domain number in pci_host_bridge,
> we could remove pci_bus_assign_domain_nr() and
> clean the domain member in pci_bus.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |    5 -----
>  drivers/pci/probe.c |   12 ++++--------
>  include/linux/pci.h |    3 ---
>  3 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 2cf942b..4d8dfe4 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>  {
>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>  }
> -
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> -{
> -	bus->domain_nr = pci_assign_domain_nr(parent);
> -}

I think you forgot to remove the empty pci_bus_assign_domain_nr()
definition from include/linux/pci.h.

I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
removed *almost* everything that uses it.  I wonder how hard it would be to
get rid of that last little bit.

>  #endif
>  #endif
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 196f08a..9cd3ca2 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>  	}
>  }
>  
> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
> +static struct pci_bus *pci_alloc_bus(void)
>  {
>  	struct pci_bus *b;
>  
> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	INIT_LIST_HEAD(&b->resources);
>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	if (parent)
> -		b->domain_nr = parent->domain_nr;
> -#endif
> +
>  	return b;
>  }
>  
> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>  	/*
>  	 * Allocate a new bus, and inherit stuff from the parent..
>  	 */
> -	child = pci_alloc_bus(parent);
> +	child = pci_alloc_bus();
>  	if (!child)
>  		return NULL;
>  
> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>  	char *fmt;
>  
>  	parent = bridge->dev.parent;
> -	b = pci_alloc_bus(NULL);
> +	b = pci_alloc_bus();
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
> -	pci_bus_assign_domain_nr(b, parent);
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index dc1c710..ebc70bb 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -467,9 +467,6 @@ struct pci_bus {
>  	unsigned char	primary;	/* number of primary bridge */
>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	int		domain_nr;
> -#endif
>  
>  	char		name[48];
>  
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12  3:48     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:48 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
> Now we save the domain number in pci_host_bridge,
> we could remove pci_bus_assign_domain_nr() and
> clean the domain member in pci_bus.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.c   |    5 -----
>  drivers/pci/probe.c |   12 ++++--------
>  include/linux/pci.h |    3 ---
>  3 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 2cf942b..4d8dfe4 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>  {
>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>  }
> -
> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
> -{
> -	bus->domain_nr = pci_assign_domain_nr(parent);
> -}

I think you forgot to remove the empty pci_bus_assign_domain_nr()
definition from include/linux/pci.h.

I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
removed *almost* everything that uses it.  I wonder how hard it would be to
get rid of that last little bit.

>  #endif
>  #endif
>  
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 196f08a..9cd3ca2 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>  	}
>  }
>  
> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
> +static struct pci_bus *pci_alloc_bus(void)
>  {
>  	struct pci_bus *b;
>  
> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	INIT_LIST_HEAD(&b->resources);
>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	if (parent)
> -		b->domain_nr = parent->domain_nr;
> -#endif
> +
>  	return b;
>  }
>  
> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>  	/*
>  	 * Allocate a new bus, and inherit stuff from the parent..
>  	 */
> -	child = pci_alloc_bus(parent);
> +	child = pci_alloc_bus();
>  	if (!child)
>  		return NULL;
>  
> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>  	char *fmt;
>  
>  	parent = bridge->dev.parent;
> -	b = pci_alloc_bus(NULL);
> +	b = pci_alloc_bus();
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>  	b->ops = ops;
>  	b->number = b->busn_res.start = bridge->busnum;
> -	pci_bus_assign_domain_nr(b, parent);
>  
>  	bridge->bus = b;
>  	b->bridge = get_device(&bridge->dev);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index dc1c710..ebc70bb 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -467,9 +467,6 @@ struct pci_bus {
>  	unsigned char	primary;	/* number of primary bridge */
>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
> -	int		domain_nr;
> -#endif
>  
>  	char		name[48];
>  
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-09  2:34   ` Yijing Wang
  (?)
  (?)
@ 2015-03-12  3:52     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:52 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:06AM +0800, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>  drivers/pci/pci.h         |    3 +
>  drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>  include/linux/pci.h       |    1 +
>  4 files changed, 109 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>  
>  #include "pci.h"
>  
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */

Follow the normal Linux comment style:

	host->domain = domain;

	/*
	 * If we support ...
	 */

> +	pci_host_assign_domain_nr(host);
> +
> +	host->dev.parent = parent;
> +	INIT_LIST_HEAD(&host->windows);
> +	host->dev.release = pci_release_host_bridge_dev;
> +	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
> +			host->busnum);
> +
> +	error = device_register(&host->dev);
> +	if (error) {
> +		put_device(&host->dev);
> +		return NULL;
> +	}
> +
> +	resource_list_for_each_entry_safe(window, n, resources)
> +		list_move_tail(&window->node, &host->windows);
> +
> +	return host;
> +}
> +
> +void pci_free_host_bridge(struct pci_host_bridge *host)
> +{
> +	device_unregister(&host->dev);
> +}
> +
>  static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  {
>  	while (bus->parent)
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index eeacab9..3de5e51 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  }
>  #endif
>  
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 dombus, struct list_head *resources);
> +void pci_free_host_bridge(struct pci_host_bridge *host);

A later patch adds another declaration and a blank line here.  If you want
the blank line, add it here, when you're adding the first declarations in
this section.

>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 3d6befd..27ec612 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	return b;
>  }
>  
> -static void pci_release_host_bridge_dev(struct device *dev)
> -{
> -	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> -
> -	if (bridge->release_fn)
> -		bridge->release_fn(bridge);
> -
> -	pci_free_resource_list(&bridge->windows);
> -
> -	kfree(bridge);
> -}
> -
> -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
> -{
> -	struct pci_host_bridge *bridge;
> -
> -	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> -	if (!bridge)
> -		return NULL;
> -
> -	INIT_LIST_HEAD(&bridge->windows);
> -	bridge->bus = b;
> -	return bridge;
> -}
> -
>  static const unsigned char pcix_bus_speed[] = {
>  	PCI_SPEED_UNKNOWN,		/* 0 */
>  	PCI_SPEED_66MHz_PCIX,		/* 1 */
> @@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_create_root_bus(
> +		struct pci_host_bridge *bridge, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	int error;
> -	struct pci_host_bridge *bridge;
>  	struct pci_bus *b, *b2;
> -	struct resource_entry *window, *n;
> +	struct resource_entry *window;
> +	struct device *parent;
>  	struct resource *res;
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> -	u8	bus = PCI_BUSNUM(db);
>  
> +	parent = bridge->dev.parent;
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = sysdata;
>  	b->ops = ops;
> -	b->number = b->busn_res.start = bus;
> +	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), bus);
> +	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>  	if (b2) {
>  		/* If we already got to this bus through a different bridge, ignore it */
>  		dev_dbg(&b2->dev, "bus already known\n");
>  		goto err_out;
>  	}
>  
> -	bridge = pci_alloc_host_bridge(b);
> -	if (!bridge)
> -		goto err_out;
> -
> -	bridge->domain = PCI_DOMAIN(db);
> -	bridge->dev.parent = parent;
> -	bridge->dev.release = pci_release_host_bridge_dev;
> -	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> +	bridge->bus = b;
> +	b->bridge = get_device(&bridge->dev);
>  	error = pcibios_root_bridge_prepare(bridge);
> -	if (error) {
> -		kfree(bridge);
> +	if (error)
>  		goto err_out;
> -	}
>  
> -	error = device_register(&bridge->dev);
> -	if (error) {
> -		put_device(&bridge->dev);
> -		goto err_out;
> -	}
> -	b->bridge = get_device(&bridge->dev);
>  	device_enable_async_suspend(b->bridge);
>  	pci_set_bus_of_node(b);
>  
> @@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	b->dev.class = &pcibus_class;
>  	b->dev.parent = b->bridge;
> -	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
> +	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
> +			b->number);
>  	error = device_register(&b->dev);
>  	if (error)
> -		goto class_dev_reg_err;
> +		goto err_out;
>  
>  	pcibios_add_bus(b);
>  
> @@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
>  
>  	/* Add initial resources to the bus */
> -	resource_list_for_each_entry_safe(window, n, resources) {
> -		list_move_tail(&window->node, &bridge->windows);
> +	resource_list_for_each_entry(window, &bridge->windows) {
>  		res = window->res;
>  		offset = window->offset;
>  		if (res->flags & IORESOURCE_BUS)
> -			pci_bus_insert_busn_res(b, bus, res->end);
> +			pci_bus_insert_busn_res(b, b->number, res->end);
>  		else
>  			pci_bus_add_resource(b, res, 0);
>  		if (offset) {
> @@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  
> -class_dev_reg_err:
> -	put_device(&bridge->dev);
> -	device_unregister(&bridge->dev);
>  err_out:
>  	kfree(b);
>  	return NULL;
>  }
>  
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_create_root_bus(host, ops, sysdata);
> +}
> +
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
>  {
>  	struct resource *res = &b->busn_res;
> @@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_scan_root_bus(
> +		struct pci_host_bridge *host, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	struct resource_entry *window;
>  	bool found = false;
>  	struct pci_bus *b;
>  	int max;
>  
> -	resource_list_for_each_entry(window, resources)
> +	resource_list_for_each_entry(window, &host->windows)
>  		if (window->res->flags & IORESOURCE_BUS) {
>  			found = true;
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
> -	if (!b)
> +	b = __pci_create_root_bus(host, ops, sysdata);
> +	if (!b) {
> +		pci_free_host_bridge(host);
>  		return NULL;
> +	}
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			PCI_BUSNUM(db));
> -		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
> +			host->busnum);
> +		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  }
> +
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_scan_root_bus(host, ops, sysdata);
> +}
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
>  struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2b1b998..463eaa3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  
>  struct pci_host_bridge {
>  	u16	domain;
> +	u16 busnum;

Why do we need this?  host_bridge->bus->number and
host_bridge->bus->busn_res.start both already contain the same information,
and I hate to add a third place.  I know pci_create_host_bridge() doesn't
have a struct pci_bus at the point where you initialize busnum, but it does
have the resource list, which contains the bus number range.

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-09  2:34   ` Yijing Wang
                     ` (4 preceding siblings ...)
  (?)
@ 2015-03-12  3:52   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:52 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:06AM +0800, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>  drivers/pci/pci.h         |    3 +
>  drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>  include/linux/pci.h       |    1 +
>  4 files changed, 109 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>  
>  #include "pci.h"
>  
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */

Follow the normal Linux comment style:

	host->domain = domain;

	/*
	 * If we support ...
	 */

> +	pci_host_assign_domain_nr(host);
> +
> +	host->dev.parent = parent;
> +	INIT_LIST_HEAD(&host->windows);
> +	host->dev.release = pci_release_host_bridge_dev;
> +	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
> +			host->busnum);
> +
> +	error = device_register(&host->dev);
> +	if (error) {
> +		put_device(&host->dev);
> +		return NULL;
> +	}
> +
> +	resource_list_for_each_entry_safe(window, n, resources)
> +		list_move_tail(&window->node, &host->windows);
> +
> +	return host;
> +}
> +
> +void pci_free_host_bridge(struct pci_host_bridge *host)
> +{
> +	device_unregister(&host->dev);
> +}
> +
>  static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  {
>  	while (bus->parent)
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index eeacab9..3de5e51 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  }
>  #endif
>  
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 dombus, struct list_head *resources);
> +void pci_free_host_bridge(struct pci_host_bridge *host);

A later patch adds another declaration and a blank line here.  If you want
the blank line, add it here, when you're adding the first declarations in
this section.

>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 3d6befd..27ec612 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	return b;
>  }
>  
> -static void pci_release_host_bridge_dev(struct device *dev)
> -{
> -	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> -
> -	if (bridge->release_fn)
> -		bridge->release_fn(bridge);
> -
> -	pci_free_resource_list(&bridge->windows);
> -
> -	kfree(bridge);
> -}
> -
> -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
> -{
> -	struct pci_host_bridge *bridge;
> -
> -	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> -	if (!bridge)
> -		return NULL;
> -
> -	INIT_LIST_HEAD(&bridge->windows);
> -	bridge->bus = b;
> -	return bridge;
> -}
> -
>  static const unsigned char pcix_bus_speed[] = {
>  	PCI_SPEED_UNKNOWN,		/* 0 */
>  	PCI_SPEED_66MHz_PCIX,		/* 1 */
> @@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_create_root_bus(
> +		struct pci_host_bridge *bridge, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	int error;
> -	struct pci_host_bridge *bridge;
>  	struct pci_bus *b, *b2;
> -	struct resource_entry *window, *n;
> +	struct resource_entry *window;
> +	struct device *parent;
>  	struct resource *res;
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> -	u8	bus = PCI_BUSNUM(db);
>  
> +	parent = bridge->dev.parent;
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = sysdata;
>  	b->ops = ops;
> -	b->number = b->busn_res.start = bus;
> +	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), bus);
> +	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>  	if (b2) {
>  		/* If we already got to this bus through a different bridge, ignore it */
>  		dev_dbg(&b2->dev, "bus already known\n");
>  		goto err_out;
>  	}
>  
> -	bridge = pci_alloc_host_bridge(b);
> -	if (!bridge)
> -		goto err_out;
> -
> -	bridge->domain = PCI_DOMAIN(db);
> -	bridge->dev.parent = parent;
> -	bridge->dev.release = pci_release_host_bridge_dev;
> -	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> +	bridge->bus = b;
> +	b->bridge = get_device(&bridge->dev);
>  	error = pcibios_root_bridge_prepare(bridge);
> -	if (error) {
> -		kfree(bridge);
> +	if (error)
>  		goto err_out;
> -	}
>  
> -	error = device_register(&bridge->dev);
> -	if (error) {
> -		put_device(&bridge->dev);
> -		goto err_out;
> -	}
> -	b->bridge = get_device(&bridge->dev);
>  	device_enable_async_suspend(b->bridge);
>  	pci_set_bus_of_node(b);
>  
> @@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	b->dev.class = &pcibus_class;
>  	b->dev.parent = b->bridge;
> -	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
> +	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
> +			b->number);
>  	error = device_register(&b->dev);
>  	if (error)
> -		goto class_dev_reg_err;
> +		goto err_out;
>  
>  	pcibios_add_bus(b);
>  
> @@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
>  
>  	/* Add initial resources to the bus */
> -	resource_list_for_each_entry_safe(window, n, resources) {
> -		list_move_tail(&window->node, &bridge->windows);
> +	resource_list_for_each_entry(window, &bridge->windows) {
>  		res = window->res;
>  		offset = window->offset;
>  		if (res->flags & IORESOURCE_BUS)
> -			pci_bus_insert_busn_res(b, bus, res->end);
> +			pci_bus_insert_busn_res(b, b->number, res->end);
>  		else
>  			pci_bus_add_resource(b, res, 0);
>  		if (offset) {
> @@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  
> -class_dev_reg_err:
> -	put_device(&bridge->dev);
> -	device_unregister(&bridge->dev);
>  err_out:
>  	kfree(b);
>  	return NULL;
>  }
>  
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_create_root_bus(host, ops, sysdata);
> +}
> +
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
>  {
>  	struct resource *res = &b->busn_res;
> @@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_scan_root_bus(
> +		struct pci_host_bridge *host, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	struct resource_entry *window;
>  	bool found = false;
>  	struct pci_bus *b;
>  	int max;
>  
> -	resource_list_for_each_entry(window, resources)
> +	resource_list_for_each_entry(window, &host->windows)
>  		if (window->res->flags & IORESOURCE_BUS) {
>  			found = true;
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
> -	if (!b)
> +	b = __pci_create_root_bus(host, ops, sysdata);
> +	if (!b) {
> +		pci_free_host_bridge(host);
>  		return NULL;
> +	}
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			PCI_BUSNUM(db));
> -		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
> +			host->busnum);
> +		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  }
> +
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_scan_root_bus(host, ops, sysdata);
> +}
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
>  struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2b1b998..463eaa3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  
>  struct pci_host_bridge {
>  	u16	domain;
> +	u16 busnum;

Why do we need this?  host_bridge->bus->number and
host_bridge->bus->busn_res.start both already contain the same information,
and I hate to add a third place.  I know pci_create_host_bridge() doesn't
have a struct pci_bus at the point where you initialize busnum, but it does
have the resource list, which contains the bus number range.

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12  3:52     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:52 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:06AM +0800, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>  drivers/pci/pci.h         |    3 +
>  drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>  include/linux/pci.h       |    1 +
>  4 files changed, 109 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>  
>  #include "pci.h"
>  
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */

Follow the normal Linux comment style:

	host->domain = domain;

	/*
	 * If we support ...
	 */

> +	pci_host_assign_domain_nr(host);
> +
> +	host->dev.parent = parent;
> +	INIT_LIST_HEAD(&host->windows);
> +	host->dev.release = pci_release_host_bridge_dev;
> +	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
> +			host->busnum);
> +
> +	error = device_register(&host->dev);
> +	if (error) {
> +		put_device(&host->dev);
> +		return NULL;
> +	}
> +
> +	resource_list_for_each_entry_safe(window, n, resources)
> +		list_move_tail(&window->node, &host->windows);
> +
> +	return host;
> +}
> +
> +void pci_free_host_bridge(struct pci_host_bridge *host)
> +{
> +	device_unregister(&host->dev);
> +}
> +
>  static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  {
>  	while (bus->parent)
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index eeacab9..3de5e51 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  }
>  #endif
>  
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 dombus, struct list_head *resources);
> +void pci_free_host_bridge(struct pci_host_bridge *host);

A later patch adds another declaration and a blank line here.  If you want
the blank line, add it here, when you're adding the first declarations in
this section.

>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 3d6befd..27ec612 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	return b;
>  }
>  
> -static void pci_release_host_bridge_dev(struct device *dev)
> -{
> -	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> -
> -	if (bridge->release_fn)
> -		bridge->release_fn(bridge);
> -
> -	pci_free_resource_list(&bridge->windows);
> -
> -	kfree(bridge);
> -}
> -
> -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
> -{
> -	struct pci_host_bridge *bridge;
> -
> -	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> -	if (!bridge)
> -		return NULL;
> -
> -	INIT_LIST_HEAD(&bridge->windows);
> -	bridge->bus = b;
> -	return bridge;
> -}
> -
>  static const unsigned char pcix_bus_speed[] = {
>  	PCI_SPEED_UNKNOWN,		/* 0 */
>  	PCI_SPEED_66MHz_PCIX,		/* 1 */
> @@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_create_root_bus(
> +		struct pci_host_bridge *bridge, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	int error;
> -	struct pci_host_bridge *bridge;
>  	struct pci_bus *b, *b2;
> -	struct resource_entry *window, *n;
> +	struct resource_entry *window;
> +	struct device *parent;
>  	struct resource *res;
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> -	u8	bus = PCI_BUSNUM(db);
>  
> +	parent = bridge->dev.parent;
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = sysdata;
>  	b->ops = ops;
> -	b->number = b->busn_res.start = bus;
> +	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), bus);
> +	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>  	if (b2) {
>  		/* If we already got to this bus through a different bridge, ignore it */
>  		dev_dbg(&b2->dev, "bus already known\n");
>  		goto err_out;
>  	}
>  
> -	bridge = pci_alloc_host_bridge(b);
> -	if (!bridge)
> -		goto err_out;
> -
> -	bridge->domain = PCI_DOMAIN(db);
> -	bridge->dev.parent = parent;
> -	bridge->dev.release = pci_release_host_bridge_dev;
> -	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> +	bridge->bus = b;
> +	b->bridge = get_device(&bridge->dev);
>  	error = pcibios_root_bridge_prepare(bridge);
> -	if (error) {
> -		kfree(bridge);
> +	if (error)
>  		goto err_out;
> -	}
>  
> -	error = device_register(&bridge->dev);
> -	if (error) {
> -		put_device(&bridge->dev);
> -		goto err_out;
> -	}
> -	b->bridge = get_device(&bridge->dev);
>  	device_enable_async_suspend(b->bridge);
>  	pci_set_bus_of_node(b);
>  
> @@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	b->dev.class = &pcibus_class;
>  	b->dev.parent = b->bridge;
> -	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
> +	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
> +			b->number);
>  	error = device_register(&b->dev);
>  	if (error)
> -		goto class_dev_reg_err;
> +		goto err_out;
>  
>  	pcibios_add_bus(b);
>  
> @@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
>  
>  	/* Add initial resources to the bus */
> -	resource_list_for_each_entry_safe(window, n, resources) {
> -		list_move_tail(&window->node, &bridge->windows);
> +	resource_list_for_each_entry(window, &bridge->windows) {
>  		res = window->res;
>  		offset = window->offset;
>  		if (res->flags & IORESOURCE_BUS)
> -			pci_bus_insert_busn_res(b, bus, res->end);
> +			pci_bus_insert_busn_res(b, b->number, res->end);
>  		else
>  			pci_bus_add_resource(b, res, 0);
>  		if (offset) {
> @@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  
> -class_dev_reg_err:
> -	put_device(&bridge->dev);
> -	device_unregister(&bridge->dev);
>  err_out:
>  	kfree(b);
>  	return NULL;
>  }
>  
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_create_root_bus(host, ops, sysdata);
> +}
> +
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
>  {
>  	struct resource *res = &b->busn_res;
> @@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_scan_root_bus(
> +		struct pci_host_bridge *host, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	struct resource_entry *window;
>  	bool found = false;
>  	struct pci_bus *b;
>  	int max;
>  
> -	resource_list_for_each_entry(window, resources)
> +	resource_list_for_each_entry(window, &host->windows)
>  		if (window->res->flags & IORESOURCE_BUS) {
>  			found = true;
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
> -	if (!b)
> +	b = __pci_create_root_bus(host, ops, sysdata);
> +	if (!b) {
> +		pci_free_host_bridge(host);
>  		return NULL;
> +	}
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			PCI_BUSNUM(db));
> -		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
> +			host->busnum);
> +		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  }
> +
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_scan_root_bus(host, ops, sysdata);
> +}
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
>  struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2b1b998..463eaa3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  
>  struct pci_host_bridge {
>  	u16	domain;
> +	u16 busnum;

Why do we need this?  host_bridge->bus->number and
host_bridge->bus->busn_res.start both already contain the same information,
and I hate to add a third place.  I know pci_create_host_bridge() doesn't
have a struct pci_bus at the point where you initialize busnum, but it does
have the resource list, which contains the bus number range.

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> -- 
> 1.7.1
> 

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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12  3:52     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:34:06AM +0800, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>  drivers/pci/pci.h         |    3 +
>  drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>  include/linux/pci.h       |    1 +
>  4 files changed, 109 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>  
>  #include "pci.h"
>  
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */

Follow the normal Linux comment style:

	host->domain = domain;

	/*
	 * If we support ...
	 */

> +	pci_host_assign_domain_nr(host);
> +
> +	host->dev.parent = parent;
> +	INIT_LIST_HEAD(&host->windows);
> +	host->dev.release = pci_release_host_bridge_dev;
> +	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
> +			host->busnum);
> +
> +	error = device_register(&host->dev);
> +	if (error) {
> +		put_device(&host->dev);
> +		return NULL;
> +	}
> +
> +	resource_list_for_each_entry_safe(window, n, resources)
> +		list_move_tail(&window->node, &host->windows);
> +
> +	return host;
> +}
> +
> +void pci_free_host_bridge(struct pci_host_bridge *host)
> +{
> +	device_unregister(&host->dev);
> +}
> +
>  static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  {
>  	while (bus->parent)
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index eeacab9..3de5e51 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  }
>  #endif
>  
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 dombus, struct list_head *resources);
> +void pci_free_host_bridge(struct pci_host_bridge *host);

A later patch adds another declaration and a blank line here.  If you want
the blank line, add it here, when you're adding the first declarations in
this section.

>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 3d6befd..27ec612 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	return b;
>  }
>  
> -static void pci_release_host_bridge_dev(struct device *dev)
> -{
> -	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> -
> -	if (bridge->release_fn)
> -		bridge->release_fn(bridge);
> -
> -	pci_free_resource_list(&bridge->windows);
> -
> -	kfree(bridge);
> -}
> -
> -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
> -{
> -	struct pci_host_bridge *bridge;
> -
> -	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> -	if (!bridge)
> -		return NULL;
> -
> -	INIT_LIST_HEAD(&bridge->windows);
> -	bridge->bus = b;
> -	return bridge;
> -}
> -
>  static const unsigned char pcix_bus_speed[] = {
>  	PCI_SPEED_UNKNOWN,		/* 0 */
>  	PCI_SPEED_66MHz_PCIX,		/* 1 */
> @@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_create_root_bus(
> +		struct pci_host_bridge *bridge, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	int error;
> -	struct pci_host_bridge *bridge;
>  	struct pci_bus *b, *b2;
> -	struct resource_entry *window, *n;
> +	struct resource_entry *window;
> +	struct device *parent;
>  	struct resource *res;
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> -	u8	bus = PCI_BUSNUM(db);
>  
> +	parent = bridge->dev.parent;
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = sysdata;
>  	b->ops = ops;
> -	b->number = b->busn_res.start = bus;
> +	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), bus);
> +	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>  	if (b2) {
>  		/* If we already got to this bus through a different bridge, ignore it */
>  		dev_dbg(&b2->dev, "bus already known\n");
>  		goto err_out;
>  	}
>  
> -	bridge = pci_alloc_host_bridge(b);
> -	if (!bridge)
> -		goto err_out;
> -
> -	bridge->domain = PCI_DOMAIN(db);
> -	bridge->dev.parent = parent;
> -	bridge->dev.release = pci_release_host_bridge_dev;
> -	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> +	bridge->bus = b;
> +	b->bridge = get_device(&bridge->dev);
>  	error = pcibios_root_bridge_prepare(bridge);
> -	if (error) {
> -		kfree(bridge);
> +	if (error)
>  		goto err_out;
> -	}
>  
> -	error = device_register(&bridge->dev);
> -	if (error) {
> -		put_device(&bridge->dev);
> -		goto err_out;
> -	}
> -	b->bridge = get_device(&bridge->dev);
>  	device_enable_async_suspend(b->bridge);
>  	pci_set_bus_of_node(b);
>  
> @@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	b->dev.class = &pcibus_class;
>  	b->dev.parent = b->bridge;
> -	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
> +	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
> +			b->number);
>  	error = device_register(&b->dev);
>  	if (error)
> -		goto class_dev_reg_err;
> +		goto err_out;
>  
>  	pcibios_add_bus(b);
>  
> @@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
>  
>  	/* Add initial resources to the bus */
> -	resource_list_for_each_entry_safe(window, n, resources) {
> -		list_move_tail(&window->node, &bridge->windows);
> +	resource_list_for_each_entry(window, &bridge->windows) {
>  		res = window->res;
>  		offset = window->offset;
>  		if (res->flags & IORESOURCE_BUS)
> -			pci_bus_insert_busn_res(b, bus, res->end);
> +			pci_bus_insert_busn_res(b, b->number, res->end);
>  		else
>  			pci_bus_add_resource(b, res, 0);
>  		if (offset) {
> @@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  
> -class_dev_reg_err:
> -	put_device(&bridge->dev);
> -	device_unregister(&bridge->dev);
>  err_out:
>  	kfree(b);
>  	return NULL;
>  }
>  
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_create_root_bus(host, ops, sysdata);
> +}
> +
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
>  {
>  	struct resource *res = &b->busn_res;
> @@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_scan_root_bus(
> +		struct pci_host_bridge *host, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	struct resource_entry *window;
>  	bool found = false;
>  	struct pci_bus *b;
>  	int max;
>  
> -	resource_list_for_each_entry(window, resources)
> +	resource_list_for_each_entry(window, &host->windows)
>  		if (window->res->flags & IORESOURCE_BUS) {
>  			found = true;
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
> -	if (!b)
> +	b = __pci_create_root_bus(host, ops, sysdata);
> +	if (!b) {
> +		pci_free_host_bridge(host);
>  		return NULL;
> +	}
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			PCI_BUSNUM(db));
> -		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
> +			host->busnum);
> +		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  }
> +
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_scan_root_bus(host, ops, sysdata);
> +}
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
>  struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2b1b998..463eaa3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  
>  struct pci_host_bridge {
>  	u16	domain;
> +	u16 busnum;

Why do we need this?  host_bridge->bus->number and
host_bridge->bus->busn_res.start both already contain the same information,
and I hate to add a third place.  I know pci_create_host_bridge() doesn't
have a struct pci_bus at the point where you initialize busnum, but it does
have the resource list, which contains the bus number range.

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12  3:52     ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12  3:52 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:34:06AM +0800, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>  drivers/pci/pci.h         |    3 +
>  drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>  include/linux/pci.h       |    1 +
>  4 files changed, 109 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>  
>  #include "pci.h"
>  
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */

Follow the normal Linux comment style:

	host->domain = domain;

	/*
	 * If we support ...
	 */

> +	pci_host_assign_domain_nr(host);
> +
> +	host->dev.parent = parent;
> +	INIT_LIST_HEAD(&host->windows);
> +	host->dev.release = pci_release_host_bridge_dev;
> +	dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
> +			host->busnum);
> +
> +	error = device_register(&host->dev);
> +	if (error) {
> +		put_device(&host->dev);
> +		return NULL;
> +	}
> +
> +	resource_list_for_each_entry_safe(window, n, resources)
> +		list_move_tail(&window->node, &host->windows);
> +
> +	return host;
> +}
> +
> +void pci_free_host_bridge(struct pci_host_bridge *host)
> +{
> +	device_unregister(&host->dev);
> +}
> +
>  static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
>  {
>  	while (bus->parent)
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index eeacab9..3de5e51 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -323,4 +323,7 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
>  }
>  #endif
>  
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 dombus, struct list_head *resources);
> +void pci_free_host_bridge(struct pci_host_bridge *host);

A later patch adds another declaration and a blank line here.  If you want
the blank line, add it here, when you're adding the first declarations in
this section.

>  #endif /* DRIVERS_PCI_H */
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 3d6befd..27ec612 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>  	return b;
>  }
>  
> -static void pci_release_host_bridge_dev(struct device *dev)
> -{
> -	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> -
> -	if (bridge->release_fn)
> -		bridge->release_fn(bridge);
> -
> -	pci_free_resource_list(&bridge->windows);
> -
> -	kfree(bridge);
> -}
> -
> -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
> -{
> -	struct pci_host_bridge *bridge;
> -
> -	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> -	if (!bridge)
> -		return NULL;
> -
> -	INIT_LIST_HEAD(&bridge->windows);
> -	bridge->bus = b;
> -	return bridge;
> -}
> -
>  static const unsigned char pcix_bus_speed[] = {
>  	PCI_SPEED_UNKNOWN,		/* 0 */
>  	PCI_SPEED_66MHz_PCIX,		/* 1 */
> @@ -1890,54 +1865,41 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  {
>  }
>  
> -struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_create_root_bus(
> +		struct pci_host_bridge *bridge, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	int error;
> -	struct pci_host_bridge *bridge;
>  	struct pci_bus *b, *b2;
> -	struct resource_entry *window, *n;
> +	struct resource_entry *window;
> +	struct device *parent;
>  	struct resource *res;
>  	resource_size_t offset;
>  	char bus_addr[64];
>  	char *fmt;
> -	u8	bus = PCI_BUSNUM(db);
>  
> +	parent = bridge->dev.parent;
>  	b = pci_alloc_bus(NULL);
>  	if (!b)
>  		return NULL;
>  
>  	b->sysdata = sysdata;
>  	b->ops = ops;
> -	b->number = b->busn_res.start = bus;
> +	b->number = b->busn_res.start = bridge->busnum;
>  	pci_bus_assign_domain_nr(b, parent);
> -	b2 = pci_find_bus(pci_domain_nr(b), bus);
> +	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>  	if (b2) {
>  		/* If we already got to this bus through a different bridge, ignore it */
>  		dev_dbg(&b2->dev, "bus already known\n");
>  		goto err_out;
>  	}
>  
> -	bridge = pci_alloc_host_bridge(b);
> -	if (!bridge)
> -		goto err_out;
> -
> -	bridge->domain = PCI_DOMAIN(db);
> -	bridge->dev.parent = parent;
> -	bridge->dev.release = pci_release_host_bridge_dev;
> -	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> +	bridge->bus = b;
> +	b->bridge = get_device(&bridge->dev);
>  	error = pcibios_root_bridge_prepare(bridge);
> -	if (error) {
> -		kfree(bridge);
> +	if (error)
>  		goto err_out;
> -	}
>  
> -	error = device_register(&bridge->dev);
> -	if (error) {
> -		put_device(&bridge->dev);
> -		goto err_out;
> -	}
> -	b->bridge = get_device(&bridge->dev);
>  	device_enable_async_suspend(b->bridge);
>  	pci_set_bus_of_node(b);
>  
> @@ -1946,10 +1908,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	b->dev.class = &pcibus_class;
>  	b->dev.parent = b->bridge;
> -	dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
> +	dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
> +			b->number);
>  	error = device_register(&b->dev);
>  	if (error)
> -		goto class_dev_reg_err;
> +		goto err_out;
>  
>  	pcibios_add_bus(b);
>  
> @@ -1962,12 +1925,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  		printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev));
>  
>  	/* Add initial resources to the bus */
> -	resource_list_for_each_entry_safe(window, n, resources) {
> -		list_move_tail(&window->node, &bridge->windows);
> +	resource_list_for_each_entry(window, &bridge->windows) {
>  		res = window->res;
>  		offset = window->offset;
>  		if (res->flags & IORESOURCE_BUS)
> -			pci_bus_insert_busn_res(b, bus, res->end);
> +			pci_bus_insert_busn_res(b, b->number, res->end);
>  		else
>  			pci_bus_add_resource(b, res, 0);
>  		if (offset) {
> @@ -1989,14 +1951,23 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  
> -class_dev_reg_err:
> -	put_device(&bridge->dev);
> -	device_unregister(&bridge->dev);
>  err_out:
>  	kfree(b);
>  	return NULL;
>  }
>  
> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_create_root_bus(host, ops, sysdata);
> +}
> +
>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
>  {
>  	struct resource *res = &b->busn_res;
> @@ -2060,29 +2031,32 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>  			res, ret ? "can not be" : "is");
>  }
>  
> -struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> -		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +static struct pci_bus *__pci_scan_root_bus(
> +		struct pci_host_bridge *host, struct pci_ops *ops,
> +		void *sysdata)
>  {
>  	struct resource_entry *window;
>  	bool found = false;
>  	struct pci_bus *b;
>  	int max;
>  
> -	resource_list_for_each_entry(window, resources)
> +	resource_list_for_each_entry(window, &host->windows)
>  		if (window->res->flags & IORESOURCE_BUS) {
>  			found = true;
>  			break;
>  		}
>  
> -	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
> -	if (!b)
> +	b = __pci_create_root_bus(host, ops, sysdata);
> +	if (!b) {
> +		pci_free_host_bridge(host);
>  		return NULL;
> +	}
>  
>  	if (!found) {
>  		dev_info(&b->dev,
>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
> -			PCI_BUSNUM(db));
> -		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
> +			host->busnum);
> +		pci_bus_insert_busn_res(b, b->number, 255);
>  	}
>  
>  	max = pci_scan_child_bus(b);
> @@ -2092,6 +2066,18 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>  
>  	return b;
>  }
> +
> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
> +		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> +{
> +	struct pci_host_bridge *host;
> +
> +	host = pci_create_host_bridge(parent, db, resources);
> +	if (!host)
> +		return NULL;
> +
> +	return __pci_scan_root_bus(host, ops, sysdata);
> +}
>  EXPORT_SYMBOL(pci_scan_root_bus);
>  
>  struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2b1b998..463eaa3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>  
>  struct pci_host_bridge {
>  	u16	domain;
> +	u16 busnum;

Why do we need this?  host_bridge->bus->number and
host_bridge->bus->busn_res.start both already contain the same information,
and I hate to add a third place.  I know pci_create_host_bridge() doesn't
have a struct pci_bus at the point where you initialize busnum, but it does
have the resource list, which contains the bus number range.

>  	struct device dev;
>  	struct pci_bus *bus;		/* root bus */
>  	struct list_head windows;	/* resource_entry */
> -- 
> 1.7.1
> 

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-11 22:28     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 11:42       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> -static struct resource busn_resource = {
>> +struct resource busn_resource = {
>>  	.name	= "PCI busn",
>>  	.start	= 0,
>>  	.end	= 255,
>>  	.flags	= IORESOURCE_BUS,
>>  };
>> +EXPORT_SYMBOL(busn_resource);
> 
> I don't think this is a good idea.  We support multiple PCI domains, and
> each domain has its own 0-255 bus number range.  This busn_resource is
> only for domain 0 and probably should be handled in arch code instead of
> the PCI core.
> 
> Right now, I think it's possible to call pci_scan_bus_parented() or
> pci_scan_bus() several times for buses in different domains, and they would
> all share the same busn_resource, which would cause corruption.
> 
> So it's already broken, but I don't want to make it harder to fix by
> exporting this stuff.

Hi Bjorn, busn_resource may would not be shared by multi domains,

We insert bus number resource like:

pci_add_resource(&resources, &busn_resource);	
	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.

So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

Do I understand correct ?

Thanks!
Yijing.

> 
>>  
>>  /* Ugh.  Need to stop exporting this to modules. */
>>  LIST_HEAD(pci_root_buses);
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-11 22:28     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 11:42     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> -static struct resource busn_resource = {
>> +struct resource busn_resource = {
>>  	.name	= "PCI busn",
>>  	.start	= 0,
>>  	.end	= 255,
>>  	.flags	= IORESOURCE_BUS,
>>  };
>> +EXPORT_SYMBOL(busn_resource);
> 
> I don't think this is a good idea.  We support multiple PCI domains, and
> each domain has its own 0-255 bus number range.  This busn_resource is
> only for domain 0 and probably should be handled in arch code instead of
> the PCI core.
> 
> Right now, I think it's possible to call pci_scan_bus_parented() or
> pci_scan_bus() several times for buses in different domains, and they would
> all share the same busn_resource, which would cause corruption.
> 
> So it's already broken, but I don't want to make it harder to fix by
> exporting this stuff.

Hi Bjorn, busn_resource may would not be shared by multi domains,

We insert bus number resource like:

pci_add_resource(&resources, &busn_resource);	
	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.

So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

Do I understand correct ?

Thanks!
Yijing.

> 
>>  
>>  /* Ugh.  Need to stop exporting this to modules. */
>>  LIST_HEAD(pci_root_buses);
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 11:42       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> -static struct resource busn_resource = {
>> +struct resource busn_resource = {
>>  	.name	= "PCI busn",
>>  	.start	= 0,
>>  	.end	= 255,
>>  	.flags	= IORESOURCE_BUS,
>>  };
>> +EXPORT_SYMBOL(busn_resource);
> 
> I don't think this is a good idea.  We support multiple PCI domains, and
> each domain has its own 0-255 bus number range.  This busn_resource is
> only for domain 0 and probably should be handled in arch code instead of
> the PCI core.
> 
> Right now, I think it's possible to call pci_scan_bus_parented() or
> pci_scan_bus() several times for buses in different domains, and they would
> all share the same busn_resource, which would cause corruption.
> 
> So it's already broken, but I don't want to make it harder to fix by
> exporting this stuff.

Hi Bjorn, busn_resource may would not be shared by multi domains,

We insert bus number resource like:

pci_add_resource(&resources, &busn_resource);	
	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.

So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

Do I understand correct ?

Thanks!
Yijing.

> 
>>  
>>  /* Ugh.  Need to stop exporting this to modules. */
>>  LIST_HEAD(pci_root_buses);
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 11:42       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:42 UTC (permalink / raw)
  To: linux-arm-kernel

>> -static struct resource busn_resource = {
>> +struct resource busn_resource = {
>>  	.name	= "PCI busn",
>>  	.start	= 0,
>>  	.end	= 255,
>>  	.flags	= IORESOURCE_BUS,
>>  };
>> +EXPORT_SYMBOL(busn_resource);
> 
> I don't think this is a good idea.  We support multiple PCI domains, and
> each domain has its own 0-255 bus number range.  This busn_resource is
> only for domain 0 and probably should be handled in arch code instead of
> the PCI core.
> 
> Right now, I think it's possible to call pci_scan_bus_parented() or
> pci_scan_bus() several times for buses in different domains, and they would
> all share the same busn_resource, which would cause corruption.
> 
> So it's already broken, but I don't want to make it harder to fix by
> exporting this stuff.

Hi Bjorn, busn_resource may would not be shared by multi domains,

We insert bus number resource like:

pci_add_resource(&resources, &busn_resource);	
	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.

So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

Do I understand correct ?

Thanks!
Yijing.

> 
>>  
>>  /* Ugh.  Need to stop exporting this to modules. */
>>  LIST_HEAD(pci_root_buses);
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 11:42       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> -static struct resource busn_resource = {
>> +struct resource busn_resource = {
>>  	.name	= "PCI busn",
>>  	.start	= 0,
>>  	.end	= 255,
>>  	.flags	= IORESOURCE_BUS,
>>  };
>> +EXPORT_SYMBOL(busn_resource);
> 
> I don't think this is a good idea.  We support multiple PCI domains, and
> each domain has its own 0-255 bus number range.  This busn_resource is
> only for domain 0 and probably should be handled in arch code instead of
> the PCI core.
> 
> Right now, I think it's possible to call pci_scan_bus_parented() or
> pci_scan_bus() several times for buses in different domains, and they would
> all share the same busn_resource, which would cause corruption.
> 
> So it's already broken, but I don't want to make it harder to fix by
> exporting this stuff.

Hi Bjorn, busn_resource may would not be shared by multi domains,

We insert bus number resource like:

pci_add_resource(&resources, &busn_resource);	
	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here = 255
		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.

So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

Do I understand correct ?

Thanks!
Yijing.

> 
>>  
>>  /* Ugh.  Need to stop exporting this to modules. */
>>  LIST_HEAD(pci_root_buses);
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 11:42       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> -static struct resource busn_resource = {
>> +struct resource busn_resource = {
>>  	.name	= "PCI busn",
>>  	.start	= 0,
>>  	.end	= 255,
>>  	.flags	= IORESOURCE_BUS,
>>  };
>> +EXPORT_SYMBOL(busn_resource);
> 
> I don't think this is a good idea.  We support multiple PCI domains, and
> each domain has its own 0-255 bus number range.  This busn_resource is
> only for domain 0 and probably should be handled in arch code instead of
> the PCI core.
> 
> Right now, I think it's possible to call pci_scan_bus_parented() or
> pci_scan_bus() several times for buses in different domains, and they would
> all share the same busn_resource, which would cause corruption.
> 
> So it's already broken, but I don't want to make it harder to fix by
> exporting this stuff.

Hi Bjorn, busn_resource may would not be shared by multi domains,

We insert bus number resource like:

pci_add_resource(&resources, &busn_resource);	
	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.

So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

Do I understand correct ?

Thanks!
Yijing.

> 
>>  
>>  /* Ugh.  Need to stop exporting this to modules. */
>>  LIST_HEAD(pci_root_buses);
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-11 22:32     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 11:46       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-11 22:32     ` Bjorn Helgaas
                       ` (4 preceding siblings ...)
  (?)
@ 2015-03-12 11:46     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 11:46       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 11:46       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: linux-arm-kernel

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-11 22:32     ` Bjorn Helgaas
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 11:46     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Guan Xuetao, Russell King, x86,
	Geert Uytterhoeven, Benjamin Herrenschmidt, xen-devel,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Thomas Gleixner, Yinghai Lu, linux-arm-kernel, Liviu Dudau,
	Tony Luck, linux-kernel, Jiang Liu, linux-alpha, David S. Miller

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 11:46       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn=0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 11:46       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 11:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>  	struct pci_bus *b;
>> +	LIST_HEAD(resources);
>>  	struct pcifront_sd *sd = NULL;
>>  	struct pci_bus_entry *bus_entry = NULL;
>>  	int err = 0;
>> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  		err = -ENOMEM;
>>  		goto err_out;
>>  	}
>> +	pci_add_resource(&resources, &ioport_resource);
>> +	pci_add_resource(&resources, &iomem_resource);
>> +	pci_add_resource(&resources, &busn_resource);
> 
> Since I don't want to export busn_resource, you might have to allocate your
> own struct resource for it here.  And, of course, figure out the details of
> which PCI domain you're in and whether you need to share one struct
> resource across several host bridges in the same domain.

Allocate its own resource here is ok for me, as I mentioned in previous reply,
so do we still need to add additional info to figure out which domain own the bus resource ?


> 
>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> +				  &pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>>  		err = -ENOMEM;
>>  		pci_unlock_rescan_remove();
>> +		pci_free_resource_list(&resources);
>>  		goto err_out;
>>  	}
>>  
>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>  
>> -	/* pci_scan_bus_parented skips devices which do not have a have
>> +	/* pci_scan_root_bus skips devices which do not have a
>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>  
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-12  1:29     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 12:14       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 9:29, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
>> Currently, we use int type for bus number in
>> pci_create_root_bus(), pci_scan_root_bus() and
>> pci_scan_bus_legacy. Because PCI bus number
>> always <= 255, so we could change the bus number
>> argument type to u32, and combine PCI domain and
>> bus number in one. 
> 
> This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> *why* you think it's a good idea to pass a single value that contains both
> domain and bus numbers.  The obvious thing is to pass two separate values,
> and you don't say why passing a single combined value is better.

Sorry for my poor description for this patch, I combined the domain and bus, because
I think now we have too many args at pci_scan_root_bus() or other scan functions,

struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources)

Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
it will become 7.

I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,

E.g

struct pci_scan_info {
	int bus;
	struct device *parent;
	struct pci_ops *ops;
	void *sysdata;
	struct list_head *resource;
	int domain;
	struct pci_host_bridge_ops;
}

Do you like this one or keep it like now ?

pci_scan_root_bus(struct device *parent, int domain, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)


> 
> Also see whitespace mistakes below.  I get a little testy when people don't
> follow the whitespace convention of neighboring lines because if people are
> sloppy about whitespace I assume they're sloppy about the code.
> 

Sorry, I would be more careful.


>>  	int error;
>> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	resource_size_t offset;
>>  	char bus_addr[64];
>>  	char *fmt;
>> +	u8	bus = PCI_BUSNUM(db);
> 
> Whitespace botch.
> 
>>  
>>  	b = pci_alloc_bus(NULL);
>>  	if (!b)
>> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	if (!bridge)
>>  		goto err_out;
>>  
>> +	bridge->domain = PCI_DOMAIN(db);
>>  	bridge->dev.parent = parent;
>>  	bridge->dev.release = pci_release_host_bridge_dev;
>>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>>  			res, ret ? "can not be" : "is");
>>  }
>>  
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>>  	struct resource_entry *window;
>> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  			break;
>>  		}
>>  
>> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
>> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>>  	if (!b)
>>  		return NULL;
>>  
>>  	if (!found) {
>>  		dev_info(&b->dev,
>>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> -			bus);
>> -		pci_bus_insert_busn_res(b, bus, 255);
>> +			PCI_BUSNUM(db));
>> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>>  	}
>>  
>>  	max = pci_scan_child_bus(b);
>> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  }
>>  EXPORT_SYMBOL(pci_scan_root_bus);
>>  
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>>  					void *sysdata)
>>  {
>>  	LIST_HEAD(resources);
>> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>>  	pci_add_resource(&resources, &ioport_resource);
>>  	pci_add_resource(&resources, &iomem_resource);
>>  	pci_add_resource(&resources, &busn_resource);
>> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
>> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>>  	if (b) {
>>  		pci_scan_child_bus(b);
>>  	} else {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 36effb8..8b3d245 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  }
>>  
>>  struct pci_host_bridge {
>> +	u16	domain;
> 
> Please follow the existing whitespace convention, i.e., use a space, not a
> tab, between "u16 domain".
> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>>  void pcibios_scan_specific_bus(int busn);
>>  struct pci_bus *pci_find_bus(int domain, int busnr);
>>  void pci_bus_add_devices(const struct pci_bus *bus);
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
>> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
>> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>>  				    struct pci_ops *ops, void *sysdata,
>>  				    struct list_head *resources);
>>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>>  void pci_bus_release_busn_res(struct pci_bus *b);
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
>> index 3c292bc..89c6f15 100644
>> --- a/include/uapi/linux/pci.h
>> +++ b/include/uapi/linux/pci.h
>> @@ -30,6 +30,9 @@
>>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
>> +#define PCI_DOMAIN(db)		((db) >> 16)
>> +#define PCI_BUSNUM(db)		((db) & 0xffff)
>> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>>  
>>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-12  1:29     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 12:14     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 9:29, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
>> Currently, we use int type for bus number in
>> pci_create_root_bus(), pci_scan_root_bus() and
>> pci_scan_bus_legacy. Because PCI bus number
>> always <= 255, so we could change the bus number
>> argument type to u32, and combine PCI domain and
>> bus number in one. 
> 
> This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> *why* you think it's a good idea to pass a single value that contains both
> domain and bus numbers.  The obvious thing is to pass two separate values,
> and you don't say why passing a single combined value is better.

Sorry for my poor description for this patch, I combined the domain and bus, because
I think now we have too many args at pci_scan_root_bus() or other scan functions,

struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources)

Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
it will become 7.

I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,

E.g

struct pci_scan_info {
	int bus;
	struct device *parent;
	struct pci_ops *ops;
	void *sysdata;
	struct list_head *resource;
	int domain;
	struct pci_host_bridge_ops;
}

Do you like this one or keep it like now ?

pci_scan_root_bus(struct device *parent, int domain, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)


> 
> Also see whitespace mistakes below.  I get a little testy when people don't
> follow the whitespace convention of neighboring lines because if people are
> sloppy about whitespace I assume they're sloppy about the code.
> 

Sorry, I would be more careful.


>>  	int error;
>> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	resource_size_t offset;
>>  	char bus_addr[64];
>>  	char *fmt;
>> +	u8	bus = PCI_BUSNUM(db);
> 
> Whitespace botch.
> 
>>  
>>  	b = pci_alloc_bus(NULL);
>>  	if (!b)
>> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	if (!bridge)
>>  		goto err_out;
>>  
>> +	bridge->domain = PCI_DOMAIN(db);
>>  	bridge->dev.parent = parent;
>>  	bridge->dev.release = pci_release_host_bridge_dev;
>>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>>  			res, ret ? "can not be" : "is");
>>  }
>>  
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>>  	struct resource_entry *window;
>> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  			break;
>>  		}
>>  
>> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
>> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>>  	if (!b)
>>  		return NULL;
>>  
>>  	if (!found) {
>>  		dev_info(&b->dev,
>>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> -			bus);
>> -		pci_bus_insert_busn_res(b, bus, 255);
>> +			PCI_BUSNUM(db));
>> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>>  	}
>>  
>>  	max = pci_scan_child_bus(b);
>> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  }
>>  EXPORT_SYMBOL(pci_scan_root_bus);
>>  
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>>  					void *sysdata)
>>  {
>>  	LIST_HEAD(resources);
>> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>>  	pci_add_resource(&resources, &ioport_resource);
>>  	pci_add_resource(&resources, &iomem_resource);
>>  	pci_add_resource(&resources, &busn_resource);
>> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
>> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>>  	if (b) {
>>  		pci_scan_child_bus(b);
>>  	} else {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 36effb8..8b3d245 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  }
>>  
>>  struct pci_host_bridge {
>> +	u16	domain;
> 
> Please follow the existing whitespace convention, i.e., use a space, not a
> tab, between "u16 domain".
> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>>  void pcibios_scan_specific_bus(int busn);
>>  struct pci_bus *pci_find_bus(int domain, int busnr);
>>  void pci_bus_add_devices(const struct pci_bus *bus);
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
>> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
>> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>>  				    struct pci_ops *ops, void *sysdata,
>>  				    struct list_head *resources);
>>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>>  void pci_bus_release_busn_res(struct pci_bus *b);
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
>> index 3c292bc..89c6f15 100644
>> --- a/include/uapi/linux/pci.h
>> +++ b/include/uapi/linux/pci.h
>> @@ -30,6 +30,9 @@
>>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
>> +#define PCI_DOMAIN(db)		((db) >> 16)
>> +#define PCI_BUSNUM(db)		((db) & 0xffff)
>> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>>  
>>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 12:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 9:29, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
>> Currently, we use int type for bus number in
>> pci_create_root_bus(), pci_scan_root_bus() and
>> pci_scan_bus_legacy. Because PCI bus number
>> always <= 255, so we could change the bus number
>> argument type to u32, and combine PCI domain and
>> bus number in one. 
> 
> This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> *why* you think it's a good idea to pass a single value that contains both
> domain and bus numbers.  The obvious thing is to pass two separate values,
> and you don't say why passing a single combined value is better.

Sorry for my poor description for this patch, I combined the domain and bus, because
I think now we have too many args at pci_scan_root_bus() or other scan functions,

struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources)

Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
it will become 7.

I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,

E.g

struct pci_scan_info {
	int bus;
	struct device *parent;
	struct pci_ops *ops;
	void *sysdata;
	struct list_head *resource;
	int domain;
	struct pci_host_bridge_ops;
}

Do you like this one or keep it like now ?

pci_scan_root_bus(struct device *parent, int domain, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)


> 
> Also see whitespace mistakes below.  I get a little testy when people don't
> follow the whitespace convention of neighboring lines because if people are
> sloppy about whitespace I assume they're sloppy about the code.
> 

Sorry, I would be more careful.


>>  	int error;
>> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	resource_size_t offset;
>>  	char bus_addr[64];
>>  	char *fmt;
>> +	u8	bus = PCI_BUSNUM(db);
> 
> Whitespace botch.
> 
>>  
>>  	b = pci_alloc_bus(NULL);
>>  	if (!b)
>> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	if (!bridge)
>>  		goto err_out;
>>  
>> +	bridge->domain = PCI_DOMAIN(db);
>>  	bridge->dev.parent = parent;
>>  	bridge->dev.release = pci_release_host_bridge_dev;
>>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>>  			res, ret ? "can not be" : "is");
>>  }
>>  
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>>  	struct resource_entry *window;
>> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  			break;
>>  		}
>>  
>> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
>> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>>  	if (!b)
>>  		return NULL;
>>  
>>  	if (!found) {
>>  		dev_info(&b->dev,
>>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> -			bus);
>> -		pci_bus_insert_busn_res(b, bus, 255);
>> +			PCI_BUSNUM(db));
>> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>>  	}
>>  
>>  	max = pci_scan_child_bus(b);
>> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  }
>>  EXPORT_SYMBOL(pci_scan_root_bus);
>>  
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>>  					void *sysdata)
>>  {
>>  	LIST_HEAD(resources);
>> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>>  	pci_add_resource(&resources, &ioport_resource);
>>  	pci_add_resource(&resources, &iomem_resource);
>>  	pci_add_resource(&resources, &busn_resource);
>> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
>> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>>  	if (b) {
>>  		pci_scan_child_bus(b);
>>  	} else {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 36effb8..8b3d245 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  }
>>  
>>  struct pci_host_bridge {
>> +	u16	domain;
> 
> Please follow the existing whitespace convention, i.e., use a space, not a
> tab, between "u16 domain".
> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>>  void pcibios_scan_specific_bus(int busn);
>>  struct pci_bus *pci_find_bus(int domain, int busnr);
>>  void pci_bus_add_devices(const struct pci_bus *bus);
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
>> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
>> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>>  				    struct pci_ops *ops, void *sysdata,
>>  				    struct list_head *resources);
>>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>>  void pci_bus_release_busn_res(struct pci_bus *b);
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
>> index 3c292bc..89c6f15 100644
>> --- a/include/uapi/linux/pci.h
>> +++ b/include/uapi/linux/pci.h
>> @@ -30,6 +30,9 @@
>>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
>> +#define PCI_DOMAIN(db)		((db) >> 16)
>> +#define PCI_BUSNUM(db)		((db) & 0xffff)
>> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>>  
>>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 12:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:14 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/12 9:29, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
>> Currently, we use int type for bus number in
>> pci_create_root_bus(), pci_scan_root_bus() and
>> pci_scan_bus_legacy. Because PCI bus number
>> always <= 255, so we could change the bus number
>> argument type to u32, and combine PCI domain and
>> bus number in one. 
> 
> This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> *why* you think it's a good idea to pass a single value that contains both
> domain and bus numbers.  The obvious thing is to pass two separate values,
> and you don't say why passing a single combined value is better.

Sorry for my poor description for this patch, I combined the domain and bus, because
I think now we have too many args at pci_scan_root_bus() or other scan functions,

struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources)

Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
it will become 7.

I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,

E.g

struct pci_scan_info {
	int bus;
	struct device *parent;
	struct pci_ops *ops;
	void *sysdata;
	struct list_head *resource;
	int domain;
	struct pci_host_bridge_ops;
}

Do you like this one or keep it like now ?

pci_scan_root_bus(struct device *parent, int domain, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)


> 
> Also see whitespace mistakes below.  I get a little testy when people don't
> follow the whitespace convention of neighboring lines because if people are
> sloppy about whitespace I assume they're sloppy about the code.
> 

Sorry, I would be more careful.


>>  	int error;
>> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	resource_size_t offset;
>>  	char bus_addr[64];
>>  	char *fmt;
>> +	u8	bus = PCI_BUSNUM(db);
> 
> Whitespace botch.
> 
>>  
>>  	b = pci_alloc_bus(NULL);
>>  	if (!b)
>> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	if (!bridge)
>>  		goto err_out;
>>  
>> +	bridge->domain = PCI_DOMAIN(db);
>>  	bridge->dev.parent = parent;
>>  	bridge->dev.release = pci_release_host_bridge_dev;
>>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>>  			res, ret ? "can not be" : "is");
>>  }
>>  
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>>  	struct resource_entry *window;
>> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  			break;
>>  		}
>>  
>> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
>> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>>  	if (!b)
>>  		return NULL;
>>  
>>  	if (!found) {
>>  		dev_info(&b->dev,
>>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> -			bus);
>> -		pci_bus_insert_busn_res(b, bus, 255);
>> +			PCI_BUSNUM(db));
>> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>>  	}
>>  
>>  	max = pci_scan_child_bus(b);
>> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  }
>>  EXPORT_SYMBOL(pci_scan_root_bus);
>>  
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>>  					void *sysdata)
>>  {
>>  	LIST_HEAD(resources);
>> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>>  	pci_add_resource(&resources, &ioport_resource);
>>  	pci_add_resource(&resources, &iomem_resource);
>>  	pci_add_resource(&resources, &busn_resource);
>> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
>> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>>  	if (b) {
>>  		pci_scan_child_bus(b);
>>  	} else {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 36effb8..8b3d245 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  }
>>  
>>  struct pci_host_bridge {
>> +	u16	domain;
> 
> Please follow the existing whitespace convention, i.e., use a space, not a
> tab, between "u16 domain".
> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>>  void pcibios_scan_specific_bus(int busn);
>>  struct pci_bus *pci_find_bus(int domain, int busnr);
>>  void pci_bus_add_devices(const struct pci_bus *bus);
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
>> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
>> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>>  				    struct pci_ops *ops, void *sysdata,
>>  				    struct list_head *resources);
>>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>>  void pci_bus_release_busn_res(struct pci_bus *b);
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
>> index 3c292bc..89c6f15 100644
>> --- a/include/uapi/linux/pci.h
>> +++ b/include/uapi/linux/pci.h
>> @@ -30,6 +30,9 @@
>>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
>> +#define PCI_DOMAIN(db)		((db) >> 16)
>> +#define PCI_BUSNUM(db)		((db) & 0xffff)
>> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>>  
>>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 12:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 9:29, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
>> Currently, we use int type for bus number in
>> pci_create_root_bus(), pci_scan_root_bus() and
>> pci_scan_bus_legacy. Because PCI bus number
>> always <= 255, so we could change the bus number
>> argument type to u32, and combine PCI domain and
>> bus number in one. 
> 
> This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> *why* you think it's a good idea to pass a single value that contains both
> domain and bus numbers.  The obvious thing is to pass two separate values,
> and you don't say why passing a single combined value is better.

Sorry for my poor description for this patch, I combined the domain and bus, because
I think now we have too many args at pci_scan_root_bus() or other scan functions,

struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources)

Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
it will become 7.

I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,

E.g

struct pci_scan_info {
	int bus;
	struct device *parent;
	struct pci_ops *ops;
	void *sysdata;
	struct list_head *resource;
	int domain;
	struct pci_host_bridge_ops;
}

Do you like this one or keep it like now ?

pci_scan_root_bus(struct device *parent, int domain, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)


> 
> Also see whitespace mistakes below.  I get a little testy when people don't
> follow the whitespace convention of neighboring lines because if people are
> sloppy about whitespace I assume they're sloppy about the code.
> 

Sorry, I would be more careful.


>>  	int error;
>> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	resource_size_t offset;
>>  	char bus_addr[64];
>>  	char *fmt;
>> +	u8	bus = PCI_BUSNUM(db);
> 
> Whitespace botch.
> 
>>  
>>  	b = pci_alloc_bus(NULL);
>>  	if (!b)
>> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	if (!bridge)
>>  		goto err_out;
>>  
>> +	bridge->domain = PCI_DOMAIN(db);
>>  	bridge->dev.parent = parent;
>>  	bridge->dev.release = pci_release_host_bridge_dev;
>>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>>  			res, ret ? "can not be" : "is");
>>  }
>>  
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>>  	struct resource_entry *window;
>> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  			break;
>>  		}
>>  
>> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
>> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>>  	if (!b)
>>  		return NULL;
>>  
>>  	if (!found) {
>>  		dev_info(&b->dev,
>>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> -			bus);
>> -		pci_bus_insert_busn_res(b, bus, 255);
>> +			PCI_BUSNUM(db));
>> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>>  	}
>>  
>>  	max = pci_scan_child_bus(b);
>> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  }
>>  EXPORT_SYMBOL(pci_scan_root_bus);
>>  
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>>  					void *sysdata)
>>  {
>>  	LIST_HEAD(resources);
>> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>>  	pci_add_resource(&resources, &ioport_resource);
>>  	pci_add_resource(&resources, &iomem_resource);
>>  	pci_add_resource(&resources, &busn_resource);
>> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
>> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>>  	if (b) {
>>  		pci_scan_child_bus(b);
>>  	} else {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 36effb8..8b3d245 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  }
>>  
>>  struct pci_host_bridge {
>> +	u16	domain;
> 
> Please follow the existing whitespace convention, i.e., use a space, not a
> tab, between "u16 domain".
> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>>  void pcibios_scan_specific_bus(int busn);
>>  struct pci_bus *pci_find_bus(int domain, int busnr);
>>  void pci_bus_add_devices(const struct pci_bus *bus);
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
>> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
>> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>>  				    struct pci_ops *ops, void *sysdata,
>>  				    struct list_head *resources);
>>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>>  void pci_bus_release_busn_res(struct pci_bus *b);
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
>> index 3c292bc..89c6f15 100644
>> --- a/include/uapi/linux/pci.h
>> +++ b/include/uapi/linux/pci.h
>> @@ -30,6 +30,9 @@
>>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
>> +#define PCI_DOMAIN(db)		((db) >> 16)
>> +#define PCI_BUSNUM(db)		((db) & 0xffff)
>> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>>  
>>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 12:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 9:29, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
>> Currently, we use int type for bus number in
>> pci_create_root_bus(), pci_scan_root_bus() and
>> pci_scan_bus_legacy. Because PCI bus number
>> always <= 255, so we could change the bus number
>> argument type to u32, and combine PCI domain and
>> bus number in one. 
> 
> This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> *why* you think it's a good idea to pass a single value that contains both
> domain and bus numbers.  The obvious thing is to pass two separate values,
> and you don't say why passing a single combined value is better.

Sorry for my poor description for this patch, I combined the domain and bus, because
I think now we have too many args at pci_scan_root_bus() or other scan functions,

struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources)

Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
it will become 7.

I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,

E.g

struct pci_scan_info {
	int bus;
	struct device *parent;
	struct pci_ops *ops;
	void *sysdata;
	struct list_head *resource;
	int domain;
	struct pci_host_bridge_ops;
}

Do you like this one or keep it like now ?

pci_scan_root_bus(struct device *parent, int domain, int bus,
		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)


> 
> Also see whitespace mistakes below.  I get a little testy when people don't
> follow the whitespace convention of neighboring lines because if people are
> sloppy about whitespace I assume they're sloppy about the code.
> 

Sorry, I would be more careful.


>>  	int error;
>> @@ -1901,6 +1901,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	resource_size_t offset;
>>  	char bus_addr[64];
>>  	char *fmt;
>> +	u8	bus = PCI_BUSNUM(db);
> 
> Whitespace botch.
> 
>>  
>>  	b = pci_alloc_bus(NULL);
>>  	if (!b)
>> @@ -1921,6 +1922,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>>  	if (!bridge)
>>  		goto err_out;
>>  
>> +	bridge->domain = PCI_DOMAIN(db);
>>  	bridge->dev.parent = parent;
>>  	bridge->dev.release = pci_release_host_bridge_dev;
>>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>> @@ -2058,7 +2060,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>>  			res, ret ? "can not be" : "is");
>>  }
>>  
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>>  	struct resource_entry *window;
>> @@ -2072,15 +2074,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  			break;
>>  		}
>>  
>> -	b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
>> +	b = pci_create_root_bus(parent, db, ops, sysdata, resources);
>>  	if (!b)
>>  		return NULL;
>>  
>>  	if (!found) {
>>  		dev_info(&b->dev,
>>  		 "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> -			bus);
>> -		pci_bus_insert_busn_res(b, bus, 255);
>> +			PCI_BUSNUM(db));
>> +		pci_bus_insert_busn_res(b, PCI_BUSNUM(db), 255);
>>  	}
>>  
>>  	max = pci_scan_child_bus(b);
>> @@ -2092,7 +2094,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>>  }
>>  EXPORT_SYMBOL(pci_scan_root_bus);
>>  
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>> +struct pci_bus *pci_scan_bus(u32 db, struct pci_ops *ops,
>>  					void *sysdata)
>>  {
>>  	LIST_HEAD(resources);
>> @@ -2101,7 +2103,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
>>  	pci_add_resource(&resources, &ioport_resource);
>>  	pci_add_resource(&resources, &iomem_resource);
>>  	pci_add_resource(&resources, &busn_resource);
>> -	b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
>> +	b = pci_create_root_bus(NULL, db, ops, sysdata, &resources);
>>  	if (b) {
>>  		pci_scan_child_bus(b);
>>  	} else {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 36effb8..8b3d245 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  }
>>  
>>  struct pci_host_bridge {
>> +	u16	domain;
> 
> Please follow the existing whitespace convention, i.e., use a space, not a
> tab, between "u16 domain".
> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> @@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>>  void pcibios_scan_specific_bus(int busn);
>>  struct pci_bus *pci_find_bus(int domain, int busnr);
>>  void pci_bus_add_devices(const struct pci_bus *bus);
>> -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
>> -struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_bus(u32 dombus, struct pci_ops *ops, void *sysdata);
>> +struct pci_bus *pci_create_root_bus(struct device *parent, u32 dombus,
>>  				    struct pci_ops *ops, void *sysdata,
>>  				    struct list_head *resources);
>>  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
>>  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
>>  void pci_bus_release_busn_res(struct pci_bus *b);
>> -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
>> +struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>> diff --git a/include/uapi/linux/pci.h b/include/uapi/linux/pci.h
>> index 3c292bc..89c6f15 100644
>> --- a/include/uapi/linux/pci.h
>> +++ b/include/uapi/linux/pci.h
>> @@ -30,6 +30,9 @@
>>  #define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))
>>  #define PCI_SLOT(devfn)		(((devfn) >> 3) & 0x1f)
>>  #define PCI_FUNC(devfn)		((devfn) & 0x07)
>> +#define PCI_DOMAIN(db)		((db) >> 16)
>> +#define PCI_BUSNUM(db)		((db) & 0xffff)
>> +#define PCI_DOMBUS(domain, bus)		(((domain) << 16) | (bus))
>>  
>>  /* Ioctls for /proc/bus/pci/X/Y nodes. */
>>  #define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-12  1:34     ` Bjorn Helgaas
                         ` (4 preceding siblings ...)
  (?)
@ 2015-03-12 12:20       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus = NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus = NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus = NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12 12:20       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-12  1:34     ` Bjorn Helgaas
                       ` (5 preceding siblings ...)
  (?)
@ 2015-03-12 12:20     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12 12:20       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12 12:20       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Fenghua Yu,
	Michal Simek, Ralf Baechle, Paul Mackerras, Michael Ellerman,
	Sebastian Ott, Gerald Schaefer, Chris Metcalf,
	Konrad Rzeszutek Wilk, linux-mips, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, xen-devel

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12 12:20       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Chris Metcalf,
	Paul Mackerras, sparclinux, Guan Xuetao, linux-s390,
	Russell King, x86, Sebastian Ott, Geert Uytterhoeven,
	Gerald Schaefer, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Konrad Rzeszutek Wilk, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Richard Henderson, Liviu Dudau,
	Michal Simek, Tony Luck, linux-kernel, Ralf Baechle, Jiang Liu,
	linux-alpha, linuxppc-dev, David S. Miller

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12 12:20       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha at vger.kernel.org
>> CC: linux-kernel at vger.kernel.org
>> CC: linux-ia64 at vger.kernel.org
>> CC: linux-mips at linux-mips.org
>> CC: linuxppc-dev at lists.ozlabs.org
>> CC: linux-s390 at vger.kernel.org
>> CC: linux-sh at vger.kernel.org
>> CC: sparclinux at vger.kernel.org
>> CC: xen-devel at lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-12  1:34     ` Bjorn Helgaas
                       ` (4 preceding siblings ...)
  (?)
@ 2015-03-12 12:20     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Chris Metcalf,
	Paul Mackerras, sparclinux, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-12 12:20       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:20 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky

On 2015/3/12 9:34, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:04AM +0800, Yijing Wang wrote:
>> Now we could pass PCI domain combined with bus number
>> in u32 argu. Because in arm/arm64, PCI domain number
>> is assigned by pci_bus_assign_domain_nr(). So we leave
>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>> unchanged.
> 
> I'm not buying this.  If you're using this PCI_DOMBUS() thing (and I'm not
> convinced that's a good idea yet), I'm not happy with most code being
> 
>   pci_scan_root_bus(..., PCI_DOMBUS(hose->index, next_busno), ...)

Yes, it looks a little ugly. Which do you prefer, use a container structure or
put all args into function directly ?


> 
> but ARM being
> 
>   pci_scan_root_bus(..., sys->busnr, ...)
> 
> That just looks like a mistake.  Make ARM use PCI_DOMBUS(0, sys->busnr) if
> you want, but at least make it look like you did a thorough job.

For arm, I assumed the pci_host_assign_domain_nr() would update its domain,
but it may made the code obscure.

> 
>> A new function pci_host_assign_domain_nr()
>> will be introduced for arm/arm64 to assign domain number
>> in later patch.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
>> CC: Matt Turner <mattst88@gmail.com>
>> CC: Tony Luck <tony.luck@intel.com>
>> CC: Fenghua Yu <fenghua.yu@intel.com>
>> CC: Michal Simek <monstr@monstr.eu>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Chris Metcalf <cmetcalf@ezchip.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> CC: linux-alpha@vger.kernel.org
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-ia64@vger.kernel.org
>> CC: linux-mips@linux-mips.org
>> CC: linuxppc-dev@lists.ozlabs.org
>> CC: linux-s390@vger.kernel.org
>> CC: linux-sh@vger.kernel.org
>> CC: sparclinux@vger.kernel.org
>> CC: xen-devel@lists.xenproject.org
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/alpha/kernel/pci.c          |    5 +++--
>>  arch/alpha/kernel/sys_nautilus.c |    4 ++--
>>  arch/ia64/pci/pci.c              |    4 ++--
>>  arch/ia64/sn/kernel/io_init.c    |    5 +++--
>>  arch/microblaze/pci/pci-common.c |    5 +++--
>>  arch/mips/pci/pci.c              |    4 ++--
>>  arch/powerpc/kernel/pci-common.c |    5 +++--
>>  arch/s390/pci/pci.c              |    5 +++--
>>  arch/sh/drivers/pci/pci.c        |    5 +++--
>>  arch/sparc/kernel/pci.c          |    5 +++--
>>  arch/tile/kernel/pci.c           |    5 +++--
>>  arch/tile/kernel/pci_gx.c        |    5 +++--
>>  arch/x86/pci/acpi.c              |    7 ++++---
>>  arch/x86/pci/common.c            |    3 ++-
>>  drivers/pci/xen-pcifront.c       |    5 +++--
>>  15 files changed, 42 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
>> index 5c845ad..deb0a36 100644
>> --- a/arch/alpha/kernel/pci.c
>> +++ b/arch/alpha/kernel/pci.c
>> @@ -336,8 +336,9 @@ common_init_pci(void)
>>  		pci_add_resource_offset(&resources, hose->mem_space,
>>  					hose->mem_space->start);
>>  
>> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
>> -					hose, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(hose->index, next_busno),
>> +				alpha_mv.pci_ops, hose, &resources);
>>  		if (!bus)
>>  			continue;
>>  		hose->bus = bus;
>> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
>> index 700686d..be0bbeb 100644
>> --- a/arch/alpha/kernel/sys_nautilus.c
>> +++ b/arch/alpha/kernel/sys_nautilus.c
>> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>>  	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>>  
>>  	/* Scan our single hose.  */
>> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
>> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
>> +			alpha_mv.pci_ops, hose);
>>  	if (!bus)
>>  		return;
>> -
>>  	hose->bus = bus;
>>  	pcibios_claim_one_bus(bus);
>>  
>> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
>> index 48cc657..675749f 100644
>> --- a/arch/ia64/pci/pci.c
>> +++ b/arch/ia64/pci/pci.c
>> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  	 * should handle the case here, but it appears that IA64 hasn't
>>  	 * such quirk. So we just ignore the case now.
>>  	 */
>> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
>> -				   &info->resources);
>> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
>> +			&pci_root_ops, controller, &info->resources);
>>  	if (!pbus) {
>>  		pci_free_resource_list(&info->resources);
>>  		__release_pci_root_info(info);
>> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
>> index 1be65eb..7e0b7f9 100644
>> --- a/arch/ia64/sn/kernel/io_init.c
>> +++ b/arch/ia64/sn/kernel/io_init.c
>> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>>  	pci_add_resource_offset(&resources,	&res[1],
>>  			prom_bussoft_ptr->bs_legacy_mem);
>>  
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(controller->segment, busnum),
>> +			&pci_root_ops, controller, &resources);
>>   	if (bus == NULL) {
>>  		kfree(res);
>>  		kfree(controller);
>> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
>> index 6d8d173..34a32ec 100644
>> --- a/arch/microblaze/pci/pci-common.c
>> +++ b/arch/microblaze/pci/pci-common.c
>> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>>  
>>  	pcibios_setup_phb_resources(hose, &resources);
>>  
>> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
>> -				hose->ops, hose, &resources);
>> +	bus = pci_scan_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  		       hose->global_number);
>> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
>> index 9eb54b5..86f8d2b 100644
>> --- a/arch/mips/pci/pci.c
>> +++ b/arch/mips/pci/pci.c
>> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>>  	pci_add_resource_offset(&resources,
>>  				hose->mem_resource, hose->mem_offset);
>>  	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	if (!bus)
>>  		pci_free_resource_list(&resources);
>>  
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 2a525c9..a467aca 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>>  	pci_add_resource(&resources, &hose->busn);
>>  
>>  	/* Create an empty bus for the toplevel */
>> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
>> -				  hose->ops, hose, &resources);
>> +	bus = pci_create_root_bus(hose->parent,
>> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
>> +			hose->ops, hose, &resources);
>>  	if (bus == NULL) {
>>  		pr_err("Failed to create bus for PCI domain %04x\n",
>>  			hose->global_number);
>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
>> index a2a7391..20e662f 100644
>> --- a/arch/s390/pci/pci.c
>> +++ b/arch/s390/pci/pci.c
>> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>>  	if (ret)
>>  		return ret;
>>  
>> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
>> -				      zdev, &resources);
>> +	zdev->bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
>> +			zdev, &resources);
>>  	if (!zdev->bus) {
>>  		zpci_cleanup_bus_resources(zdev);
>>  		return -EIO;
>> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
>> index efc1051..116f80f 100644
>> --- a/arch/sh/drivers/pci/pci.c
>> +++ b/arch/sh/drivers/pci/pci.c
>> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>>  		pci_add_resource_offset(&resources, res, offset);
>>  	}
>>  
>> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
>> -				&resources);
>> +	bus = pci_scan_root_bus(NULL,
>> +			PCI_DOMBUS(hose->index, next_busno),
>> +			hose->pci_ops, hose, &resources);
>>  	hose->bus = bus;
>>  
>>  	need_domain_info = need_domain_info || hose->index;
>> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
>> index 9ce5afe..838fe1e 100644
>> --- a/arch/sparc/kernel/pci.c
>> +++ b/arch/sparc/kernel/pci.c
>> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
>> -				  pbm, &resources);
>> +	bus = pci_create_root_bus(parent,
>> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> +			pbm->pci_ops, pbm, &resources);
>>  	if (!bus) {
>>  		printk(KERN_ERR "Failed to create bus for %s\n",
>>  		       node->full_name);
>> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
>> index 9475a74..25b0d9b 100644
>> --- a/arch/tile/kernel/pci.c
>> +++ b/arch/tile/kernel/pci.c
>> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>>  
>>  			pci_add_resource(&resources, &ioport_resource);
>>  			pci_add_resource(&resources, &iomem_resource);
>> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
>> -						controller, &resources);
>> +			bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, 0),
>> +				controller->ops, controller, &resources);
>>  			controller->root_bus = bus;
>>  			controller->last_busno = bus->busn_res.end;
>>  		}
>> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
>> index b1df847..f6f41f3 100644
>> --- a/arch/tile/kernel/pci_gx.c
>> +++ b/arch/tile/kernel/pci_gx.c
>> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>>  					controller->mem_offset);
>>  		pci_add_resource(&resources, &controller->io_space);
>>  		controller->first_busno = next_busno;
>> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
>> -					controller, &resources);
>> +		bus = pci_scan_root_bus(NULL,
>> +				PCI_DOMBUS(controller->index, next_busno),
>> +				controller->ops, controller, &resources);
>>  		controller->root_bus = bus;
>>  		next_busno = bus->busn_res.end + 1;
>>  	}
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 6ac2738..ad0e926 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>>  		}
>>  
>>  		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
>> -				    (u8)root->secondary.end, root->mcfg_addr))
>> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
>> -						  sd, &resources);
>> +				(u8)root->secondary.end, root->mcfg_addr))
>> +			bus = pci_create_root_bus(NULL,
>> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
>> +				sd, &resources);
>>  
>>  		if (bus) {
>>  			pci_scan_child_bus(bus);
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index 0cbc723..0160280 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>>  	sd->node = x86_pci_root_bus_node(busnum);
>>  	x86_pci_root_bus_resources(busnum, &resources);
>>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
>> +			&pci_root_ops, sd, &resources);
>>  	if (!bus) {
>>  		pci_free_resource_list(&resources);
>>  		kfree(sd);
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index 9e7c28b..af6144a 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>  
>>  	pci_lock_rescan_remove();
>>  
>> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> -				  &pcifront_bus_ops, sd, &resources);
>> +	b = pci_scan_root_bus(&pdev->xdev->dev,
>> +			PCI_DOMBUS(sd->domain, bus),
>> +			&pcifront_bus_ops, sd, &resources);
>>  	if (!b) {
>>  		dev_err(&pdev->xdev->dev,
>>  			"Error creating PCI Frontend Bus!\n");
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing



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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
  2015-03-12  1:39     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 12:23       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 8b3d245..2b1b998 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>>  	return bus->domain_nr;
>>  }
>>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
>> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);
> 
> I do not think this needs to be in include/linux/pci.h.  It's called only
> from drivers/pci/host-bridge.c, so at most, it needs to be in
> drivers/pci/pci.h.
> 
> Better still would be if the definition could be moved from
> drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
> in a header file at all.

This is a good idea, thanks.

> 
>>  #else
>>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>>  					struct device *parent)
>>  {
>>  }
>> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>> +{
>> +}
>>  #endif
>>  
>>  /* some architectures require additional setup to direct VGA traffic */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
  2015-03-12  1:39     ` Bjorn Helgaas
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 12:23     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 8b3d245..2b1b998 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>>  	return bus->domain_nr;
>>  }
>>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
>> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);
> 
> I do not think this needs to be in include/linux/pci.h.  It's called only
> from drivers/pci/host-bridge.c, so at most, it needs to be in
> drivers/pci/pci.h.
> 
> Better still would be if the definition could be moved from
> drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
> in a header file at all.

This is a good idea, thanks.

> 
>>  #else
>>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>>  					struct device *parent)
>>  {
>>  }
>> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>> +{
>> +}
>>  #endif
>>  
>>  /* some architectures require additional setup to direct VGA traffic */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12 12:23       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 8b3d245..2b1b998 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>>  	return bus->domain_nr;
>>  }
>>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
>> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);
> 
> I do not think this needs to be in include/linux/pci.h.  It's called only
> from drivers/pci/host-bridge.c, so at most, it needs to be in
> drivers/pci/pci.h.
> 
> Better still would be if the definition could be moved from
> drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
> in a header file at all.

This is a good idea, thanks.

> 
>>  #else
>>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>>  					struct device *parent)
>>  {
>>  }
>> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>> +{
>> +}
>>  #endif
>>  
>>  /* some architectures require additional setup to direct VGA traffic */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12 12:23       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:23 UTC (permalink / raw)
  To: linux-arm-kernel

>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 8b3d245..2b1b998 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>>  	return bus->domain_nr;
>>  }
>>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
>> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);
> 
> I do not think this needs to be in include/linux/pci.h.  It's called only
> from drivers/pci/host-bridge.c, so at most, it needs to be in
> drivers/pci/pci.h.
> 
> Better still would be if the definition could be moved from
> drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
> in a header file at all.

This is a good idea, thanks.

> 
>>  #else
>>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>>  					struct device *parent)
>>  {
>>  }
>> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>> +{
>> +}
>>  #endif
>>  
>>  /* some architectures require additional setup to direct VGA traffic */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12 12:23       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 8b3d245..2b1b998 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>>  	return bus->domain_nr;
>>  }
>>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
>> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);
> 
> I do not think this needs to be in include/linux/pci.h.  It's called only
> from drivers/pci/host-bridge.c, so at most, it needs to be in
> drivers/pci/pci.h.
> 
> Better still would be if the definition could be moved from
> drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
> in a header file at all.

This is a good idea, thanks.

> 
>>  #else
>>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>>  					struct device *parent)
>>  {
>>  }
>> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>> +{
>> +}
>>  #endif
>>  
>>  /* some architectures require additional setup to direct VGA traffic */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain
@ 2015-03-12 12:23       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 12:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 8b3d245..2b1b998 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus)
>>  	return bus->domain_nr;
>>  }
>>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent);
>> +void pci_host_assign_domain_nr(struct pci_host_bridge *host);
> 
> I do not think this needs to be in include/linux/pci.h.  It's called only
> from drivers/pci/host-bridge.c, so at most, it needs to be in
> drivers/pci/pci.h.
> 
> Better still would be if the definition could be moved from
> drivers/pci/pci.c to drivers/pci/host-bridge.c so we wouldn't need anything
> in a header file at all.

This is a good idea, thanks.

> 
>>  #else
>>  static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,
>>  					struct device *parent)
>>  {
>>  }
>> +static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>> +{
>> +}
>>  #endif
>>  
>>  /* some architectures require additional setup to direct VGA traffic */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-12  2:55     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:03       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 10:55, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
>> Introduce pci_host_bridge_list to manage pci host
>> bridges in system, so we could detect whether
>> the host in domain:bus is alreay registered.
>> Then we could remove bus alreay exist test in
>> __pci_create_root_bus().
> 
> It's a nice idea to move this test into the core.  While you're at it, why
> don't you check for any overlap with the bus ranges of existing host
> bridges?  For example, if we're trying to create a new host bridge to
> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> as well as to [bus 40-ff].  I think your current patch will detect the
> latter conflict but not the former.

Now pci host bridge may only know its start bus number, like acpi _BBN provided,
but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
some pci scan would fail which currently scan success.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>>  drivers/pci/probe.c       |    8 +-------
>>  include/linux/pci.h       |    1 +
>>  3 files changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index 3bd45e7..0bb08ef 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -8,6 +8,9 @@
>>  
>>  #include "pci.h"
>>  
>> +static LIST_HEAD(pci_host_bridge_list);
>> +static DEFINE_MUTEX(phb_mutex);
> 
> We don't use the "phb" abbreviation in the PCI core.

OK

> 
>> +
>>  static void pci_release_host_bridge_dev(struct device *dev)
>>  {
>>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	int error;
>>  	int bus = PCI_BUSNUM(db);
>>  	int domain = PCI_DOMAIN(db);
>> -	struct pci_host_bridge *host;
>> +	struct pci_host_bridge *host, *temp;
>>  	struct resource_entry *window, *n;
>>  
>>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	 */
>>  	pci_host_assign_domain_nr(host);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
>> +		if (temp->domain == host->domain
>> +				&& temp->busnum == host->busnum) {
>> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
>> +					host->domain, host->busnum);
> 
> &host->dev hasn't been initialized yet!  And the text of the original
> message was better.

Oh, my mistake, good catch.

> 
>> +			mutex_unlock(&phb_mutex);
>> +			kfree(host);
>> +			return NULL;
>> +		}
>> +	mutex_unlock(&phb_mutex);
> 
> This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
> time can both succeed.
> 

Hmm, I need to unlock after I add the new host bridge to the gloal host bridge list, thanks.

> And it needs curly braces around the list_for_each_entry() body.

OK

> 
>> +
>>  	host->dev.parent = parent;
>>  	INIT_LIST_HEAD(&host->windows);
>>  	host->dev.release = pci_release_host_bridge_dev;
>> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	resource_list_for_each_entry_safe(window, n, resources)
>>  		list_move_tail(&window->node, &host->windows);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_add_tail(&host->list, &pci_host_bridge_list);
>> +	mutex_unlock(&phb_mutex);
>>  	return host;
>>  }
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host)
>>  {
>> +	mutex_lock(&phb_mutex);
>> +	list_del(&host->list);
>> +	mutex_unlock(&phb_mutex);
>> +
>>  	device_unregister(&host->dev);
>>  }
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 27ec612..7238fa3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>>  		void *sysdata)
>>  {
>>  	int error;
>> -	struct pci_bus *b, *b2;
>> +	struct pci_bus *b;
>>  	struct resource_entry *window;
>>  	struct device *parent;
>>  	struct resource *res;
>> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>>  	pci_bus_assign_domain_nr(b, parent);
>> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>> -	if (b2) {
>> -		/* If we already got to this bus through a different bridge, ignore it */
>> -		dev_dbg(&b2->dev, "bus already known\n");
>> -		goto err_out;
>> -	}
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 463eaa3..b621f5b 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> +	struct list_head list;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-12  2:55     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:03     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 10:55, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
>> Introduce pci_host_bridge_list to manage pci host
>> bridges in system, so we could detect whether
>> the host in domain:bus is alreay registered.
>> Then we could remove bus alreay exist test in
>> __pci_create_root_bus().
> 
> It's a nice idea to move this test into the core.  While you're at it, why
> don't you check for any overlap with the bus ranges of existing host
> bridges?  For example, if we're trying to create a new host bridge to
> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> as well as to [bus 40-ff].  I think your current patch will detect the
> latter conflict but not the former.

Now pci host bridge may only know its start bus number, like acpi _BBN provided,
but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
some pci scan would fail which currently scan success.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>>  drivers/pci/probe.c       |    8 +-------
>>  include/linux/pci.h       |    1 +
>>  3 files changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index 3bd45e7..0bb08ef 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -8,6 +8,9 @@
>>  
>>  #include "pci.h"
>>  
>> +static LIST_HEAD(pci_host_bridge_list);
>> +static DEFINE_MUTEX(phb_mutex);
> 
> We don't use the "phb" abbreviation in the PCI core.

OK

> 
>> +
>>  static void pci_release_host_bridge_dev(struct device *dev)
>>  {
>>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	int error;
>>  	int bus = PCI_BUSNUM(db);
>>  	int domain = PCI_DOMAIN(db);
>> -	struct pci_host_bridge *host;
>> +	struct pci_host_bridge *host, *temp;
>>  	struct resource_entry *window, *n;
>>  
>>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	 */
>>  	pci_host_assign_domain_nr(host);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
>> +		if (temp->domain == host->domain
>> +				&& temp->busnum == host->busnum) {
>> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
>> +					host->domain, host->busnum);
> 
> &host->dev hasn't been initialized yet!  And the text of the original
> message was better.

Oh, my mistake, good catch.

> 
>> +			mutex_unlock(&phb_mutex);
>> +			kfree(host);
>> +			return NULL;
>> +		}
>> +	mutex_unlock(&phb_mutex);
> 
> This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
> time can both succeed.
> 

Hmm, I need to unlock after I add the new host bridge to the gloal host bridge list, thanks.

> And it needs curly braces around the list_for_each_entry() body.

OK

> 
>> +
>>  	host->dev.parent = parent;
>>  	INIT_LIST_HEAD(&host->windows);
>>  	host->dev.release = pci_release_host_bridge_dev;
>> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	resource_list_for_each_entry_safe(window, n, resources)
>>  		list_move_tail(&window->node, &host->windows);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_add_tail(&host->list, &pci_host_bridge_list);
>> +	mutex_unlock(&phb_mutex);
>>  	return host;
>>  }
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host)
>>  {
>> +	mutex_lock(&phb_mutex);
>> +	list_del(&host->list);
>> +	mutex_unlock(&phb_mutex);
>> +
>>  	device_unregister(&host->dev);
>>  }
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 27ec612..7238fa3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>>  		void *sysdata)
>>  {
>>  	int error;
>> -	struct pci_bus *b, *b2;
>> +	struct pci_bus *b;
>>  	struct resource_entry *window;
>>  	struct device *parent;
>>  	struct resource *res;
>> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>>  	pci_bus_assign_domain_nr(b, parent);
>> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>> -	if (b2) {
>> -		/* If we already got to this bus through a different bridge, ignore it */
>> -		dev_dbg(&b2->dev, "bus already known\n");
>> -		goto err_out;
>> -	}
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 463eaa3..b621f5b 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> +	struct list_head list;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 13:03       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 10:55, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
>> Introduce pci_host_bridge_list to manage pci host
>> bridges in system, so we could detect whether
>> the host in domain:bus is alreay registered.
>> Then we could remove bus alreay exist test in
>> __pci_create_root_bus().
> 
> It's a nice idea to move this test into the core.  While you're at it, why
> don't you check for any overlap with the bus ranges of existing host
> bridges?  For example, if we're trying to create a new host bridge to
> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> as well as to [bus 40-ff].  I think your current patch will detect the
> latter conflict but not the former.

Now pci host bridge may only know its start bus number, like acpi _BBN provided,
but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
some pci scan would fail which currently scan success.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>>  drivers/pci/probe.c       |    8 +-------
>>  include/linux/pci.h       |    1 +
>>  3 files changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index 3bd45e7..0bb08ef 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -8,6 +8,9 @@
>>  
>>  #include "pci.h"
>>  
>> +static LIST_HEAD(pci_host_bridge_list);
>> +static DEFINE_MUTEX(phb_mutex);
> 
> We don't use the "phb" abbreviation in the PCI core.

OK

> 
>> +
>>  static void pci_release_host_bridge_dev(struct device *dev)
>>  {
>>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	int error;
>>  	int bus = PCI_BUSNUM(db);
>>  	int domain = PCI_DOMAIN(db);
>> -	struct pci_host_bridge *host;
>> +	struct pci_host_bridge *host, *temp;
>>  	struct resource_entry *window, *n;
>>  
>>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	 */
>>  	pci_host_assign_domain_nr(host);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
>> +		if (temp->domain == host->domain
>> +				&& temp->busnum == host->busnum) {
>> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
>> +					host->domain, host->busnum);
> 
> &host->dev hasn't been initialized yet!  And the text of the original
> message was better.

Oh, my mistake, good catch.

> 
>> +			mutex_unlock(&phb_mutex);
>> +			kfree(host);
>> +			return NULL;
>> +		}
>> +	mutex_unlock(&phb_mutex);
> 
> This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
> time can both succeed.
> 

Hmm, I need to unlock after I add the new host bridge to the gloal host bridge list, thanks.

> And it needs curly braces around the list_for_each_entry() body.

OK

> 
>> +
>>  	host->dev.parent = parent;
>>  	INIT_LIST_HEAD(&host->windows);
>>  	host->dev.release = pci_release_host_bridge_dev;
>> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	resource_list_for_each_entry_safe(window, n, resources)
>>  		list_move_tail(&window->node, &host->windows);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_add_tail(&host->list, &pci_host_bridge_list);
>> +	mutex_unlock(&phb_mutex);
>>  	return host;
>>  }
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host)
>>  {
>> +	mutex_lock(&phb_mutex);
>> +	list_del(&host->list);
>> +	mutex_unlock(&phb_mutex);
>> +
>>  	device_unregister(&host->dev);
>>  }
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 27ec612..7238fa3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>>  		void *sysdata)
>>  {
>>  	int error;
>> -	struct pci_bus *b, *b2;
>> +	struct pci_bus *b;
>>  	struct resource_entry *window;
>>  	struct device *parent;
>>  	struct resource *res;
>> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>>  	pci_bus_assign_domain_nr(b, parent);
>> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>> -	if (b2) {
>> -		/* If we already got to this bus through a different bridge, ignore it */
>> -		dev_dbg(&b2->dev, "bus already known\n");
>> -		goto err_out;
>> -	}
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 463eaa3..b621f5b 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> +	struct list_head list;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 13:03       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/12 10:55, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
>> Introduce pci_host_bridge_list to manage pci host
>> bridges in system, so we could detect whether
>> the host in domain:bus is alreay registered.
>> Then we could remove bus alreay exist test in
>> __pci_create_root_bus().
> 
> It's a nice idea to move this test into the core.  While you're at it, why
> don't you check for any overlap with the bus ranges of existing host
> bridges?  For example, if we're trying to create a new host bridge to
> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> as well as to [bus 40-ff].  I think your current patch will detect the
> latter conflict but not the former.

Now pci host bridge may only know its start bus number, like acpi _BBN provided,
but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
some pci scan would fail which currently scan success.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>>  drivers/pci/probe.c       |    8 +-------
>>  include/linux/pci.h       |    1 +
>>  3 files changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index 3bd45e7..0bb08ef 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -8,6 +8,9 @@
>>  
>>  #include "pci.h"
>>  
>> +static LIST_HEAD(pci_host_bridge_list);
>> +static DEFINE_MUTEX(phb_mutex);
> 
> We don't use the "phb" abbreviation in the PCI core.

OK

> 
>> +
>>  static void pci_release_host_bridge_dev(struct device *dev)
>>  {
>>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	int error;
>>  	int bus = PCI_BUSNUM(db);
>>  	int domain = PCI_DOMAIN(db);
>> -	struct pci_host_bridge *host;
>> +	struct pci_host_bridge *host, *temp;
>>  	struct resource_entry *window, *n;
>>  
>>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	 */
>>  	pci_host_assign_domain_nr(host);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
>> +		if (temp->domain == host->domain
>> +				&& temp->busnum == host->busnum) {
>> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
>> +					host->domain, host->busnum);
> 
> &host->dev hasn't been initialized yet!  And the text of the original
> message was better.

Oh, my mistake, good catch.

> 
>> +			mutex_unlock(&phb_mutex);
>> +			kfree(host);
>> +			return NULL;
>> +		}
>> +	mutex_unlock(&phb_mutex);
> 
> This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
> time can both succeed.
> 

Hmm, I need to unlock after I add the new host bridge to the gloal host bridge list, thanks.

> And it needs curly braces around the list_for_each_entry() body.

OK

> 
>> +
>>  	host->dev.parent = parent;
>>  	INIT_LIST_HEAD(&host->windows);
>>  	host->dev.release = pci_release_host_bridge_dev;
>> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	resource_list_for_each_entry_safe(window, n, resources)
>>  		list_move_tail(&window->node, &host->windows);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_add_tail(&host->list, &pci_host_bridge_list);
>> +	mutex_unlock(&phb_mutex);
>>  	return host;
>>  }
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host)
>>  {
>> +	mutex_lock(&phb_mutex);
>> +	list_del(&host->list);
>> +	mutex_unlock(&phb_mutex);
>> +
>>  	device_unregister(&host->dev);
>>  }
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 27ec612..7238fa3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>>  		void *sysdata)
>>  {
>>  	int error;
>> -	struct pci_bus *b, *b2;
>> +	struct pci_bus *b;
>>  	struct resource_entry *window;
>>  	struct device *parent;
>>  	struct resource *res;
>> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>>  	pci_bus_assign_domain_nr(b, parent);
>> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>> -	if (b2) {
>> -		/* If we already got to this bus through a different bridge, ignore it */
>> -		dev_dbg(&b2->dev, "bus already known\n");
>> -		goto err_out;
>> -	}
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 463eaa3..b621f5b 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> +	struct list_head list;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 13:03       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 10:55, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
>> Introduce pci_host_bridge_list to manage pci host
>> bridges in system, so we could detect whether
>> the host in domain:bus is alreay registered.
>> Then we could remove bus alreay exist test in
>> __pci_create_root_bus().
> 
> It's a nice idea to move this test into the core.  While you're at it, why
> don't you check for any overlap with the bus ranges of existing host
> bridges?  For example, if we're trying to create a new host bridge to
> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> as well as to [bus 40-ff].  I think your current patch will detect the
> latter conflict but not the former.

Now pci host bridge may only know its start bus number, like acpi _BBN provided,
but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
some pci scan would fail which currently scan success.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>>  drivers/pci/probe.c       |    8 +-------
>>  include/linux/pci.h       |    1 +
>>  3 files changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index 3bd45e7..0bb08ef 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -8,6 +8,9 @@
>>  
>>  #include "pci.h"
>>  
>> +static LIST_HEAD(pci_host_bridge_list);
>> +static DEFINE_MUTEX(phb_mutex);
> 
> We don't use the "phb" abbreviation in the PCI core.

OK

> 
>> +
>>  static void pci_release_host_bridge_dev(struct device *dev)
>>  {
>>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	int error;
>>  	int bus = PCI_BUSNUM(db);
>>  	int domain = PCI_DOMAIN(db);
>> -	struct pci_host_bridge *host;
>> +	struct pci_host_bridge *host, *temp;
>>  	struct resource_entry *window, *n;
>>  
>>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	 */
>>  	pci_host_assign_domain_nr(host);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
>> +		if (temp->domain = host->domain
>> +				&& temp->busnum = host->busnum) {
>> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
>> +					host->domain, host->busnum);
> 
> &host->dev hasn't been initialized yet!  And the text of the original
> message was better.

Oh, my mistake, good catch.

> 
>> +			mutex_unlock(&phb_mutex);
>> +			kfree(host);
>> +			return NULL;
>> +		}
>> +	mutex_unlock(&phb_mutex);
> 
> This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
> time can both succeed.
> 

Hmm, I need to unlock after I add the new host bridge to the gloal host bridge list, thanks.

> And it needs curly braces around the list_for_each_entry() body.

OK

> 
>> +
>>  	host->dev.parent = parent;
>>  	INIT_LIST_HEAD(&host->windows);
>>  	host->dev.release = pci_release_host_bridge_dev;
>> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	resource_list_for_each_entry_safe(window, n, resources)
>>  		list_move_tail(&window->node, &host->windows);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_add_tail(&host->list, &pci_host_bridge_list);
>> +	mutex_unlock(&phb_mutex);
>>  	return host;
>>  }
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host)
>>  {
>> +	mutex_lock(&phb_mutex);
>> +	list_del(&host->list);
>> +	mutex_unlock(&phb_mutex);
>> +
>>  	device_unregister(&host->dev);
>>  }
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 27ec612..7238fa3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>>  		void *sysdata)
>>  {
>>  	int error;
>> -	struct pci_bus *b, *b2;
>> +	struct pci_bus *b;
>>  	struct resource_entry *window;
>>  	struct device *parent;
>>  	struct resource *res;
>> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>>  	pci_bus_assign_domain_nr(b, parent);
>> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>> -	if (b2) {
>> -		/* If we already got to this bus through a different bridge, ignore it */
>> -		dev_dbg(&b2->dev, "bus already known\n");
>> -		goto err_out;
>> -	}
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 463eaa3..b621f5b 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> +	struct list_head list;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 13:03       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 10:55, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
>> Introduce pci_host_bridge_list to manage pci host
>> bridges in system, so we could detect whether
>> the host in domain:bus is alreay registered.
>> Then we could remove bus alreay exist test in
>> __pci_create_root_bus().
> 
> It's a nice idea to move this test into the core.  While you're at it, why
> don't you check for any overlap with the bus ranges of existing host
> bridges?  For example, if we're trying to create a new host bridge to
> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> as well as to [bus 40-ff].  I think your current patch will detect the
> latter conflict but not the former.

Now pci host bridge may only know its start bus number, like acpi _BBN provided,
but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
some pci scan would fail which currently scan success.

> 
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/host-bridge.c |   24 +++++++++++++++++++++++-
>>  drivers/pci/probe.c       |    8 +-------
>>  include/linux/pci.h       |    1 +
>>  3 files changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index 3bd45e7..0bb08ef 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -8,6 +8,9 @@
>>  
>>  #include "pci.h"
>>  
>> +static LIST_HEAD(pci_host_bridge_list);
>> +static DEFINE_MUTEX(phb_mutex);
> 
> We don't use the "phb" abbreviation in the PCI core.

OK

> 
>> +
>>  static void pci_release_host_bridge_dev(struct device *dev)
>>  {
>>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>> @@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	int error;
>>  	int bus = PCI_BUSNUM(db);
>>  	int domain = PCI_DOMAIN(db);
>> -	struct pci_host_bridge *host;
>> +	struct pci_host_bridge *host, *temp;
>>  	struct resource_entry *window, *n;
>>  
>>  	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> @@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	 */
>>  	pci_host_assign_domain_nr(host);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_for_each_entry(temp, &pci_host_bridge_list, list)
>> +		if (temp->domain == host->domain
>> +				&& temp->busnum == host->busnum) {
>> +			dev_dbg(&host->dev, "pci host bridge pci%04x:%02x exist\n",
>> +					host->domain, host->busnum);
> 
> &host->dev hasn't been initialized yet!  And the text of the original
> message was better.

Oh, my mistake, good catch.

> 
>> +			mutex_unlock(&phb_mutex);
>> +			kfree(host);
>> +			return NULL;
>> +		}
>> +	mutex_unlock(&phb_mutex);
> 
> This is racy.  Two CPUs adding a bridge to [bus 00-7f] at about the same
> time can both succeed.
> 

Hmm, I need to unlock after I add the new host bridge to the gloal host bridge list, thanks.

> And it needs curly braces around the list_for_each_entry() body.

OK

> 
>> +
>>  	host->dev.parent = parent;
>>  	INIT_LIST_HEAD(&host->windows);
>>  	host->dev.release = pci_release_host_bridge_dev;
>> @@ -55,11 +70,18 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  	resource_list_for_each_entry_safe(window, n, resources)
>>  		list_move_tail(&window->node, &host->windows);
>>  
>> +	mutex_lock(&phb_mutex);
>> +	list_add_tail(&host->list, &pci_host_bridge_list);
>> +	mutex_unlock(&phb_mutex);
>>  	return host;
>>  }
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host)
>>  {
>> +	mutex_lock(&phb_mutex);
>> +	list_del(&host->list);
>> +	mutex_unlock(&phb_mutex);
>> +
>>  	device_unregister(&host->dev);
>>  }
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 27ec612..7238fa3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1870,7 +1870,7 @@ static struct pci_bus *__pci_create_root_bus(
>>  		void *sysdata)
>>  {
>>  	int error;
>> -	struct pci_bus *b, *b2;
>> +	struct pci_bus *b;
>>  	struct resource_entry *window;
>>  	struct device *parent;
>>  	struct resource *res;
>> @@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus(
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>>  	pci_bus_assign_domain_nr(b, parent);
>> -	b2 = pci_find_bus(pci_domain_nr(b), b->number);
>> -	if (b2) {
>> -		/* If we already got to this bus through a different bridge, ignore it */
>> -		dev_dbg(&b2->dev, "bus already known\n");
>> -		goto err_out;
>> -	}
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 463eaa3..b621f5b 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -406,6 +406,7 @@ struct pci_host_bridge {
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> +	struct list_head list;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
  2015-03-12  3:23     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:14       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index c8e074d..59d9be3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>> +		bridge->ops->set_root_bus_speed(bridge);
> 
> Before this patch, can you do this:
> 
>   - Rename the powerpc pcibios_root_bridge_prepare() to
>     pcibios_set_root_bus_speed() and add a call to it here
> 
>   - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()
> 
> Then this patch will make a lot more sense because it will look like this,
> with the host bridge ops call right next to the matching pcibios call:
> 
>   +	if (host->ops && host->ops->prepare) {
>   +		error = host->ops->prepare(host);
>   +		...
>   +	}
> 	pcibios_root_bridge_prepare(...);
> 
>   +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>   +		bridge->ops->set_root_bus_speed(bridge);
> 	pcibios_set_root_bus_speed(...);

OK, will update.

> 
>>  	error = pcibios_root_bridge_prepare(bridge);
>>  	if (error)
>>  		goto err_out;
>> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>>  		pci_bus_insert_busn_res(b, b->number, 255);
>>  	}
>>  
>> -	max = pci_scan_child_bus(b);
>> -
>> -	if (!found)
>> -		pci_bus_update_busn_res_end(b, max);
>> +	if (host->ops && host->ops->scan_bus) {
>> +		host->ops->scan_bus(host);
>> +	} else {
>> +		max = pci_scan_child_bus(b);
>> +		if (!found)
>> +			pci_bus_update_busn_res_end(b, max);
>> +	}
> 
> I think host->ops->scan_bus() should have the same prototype as
> pci_scan_child_bus(), and it should return max, and you should do the same
> busn update as when you call pci_scan_child_bus().  So the code would look
> like this:
> 
>     if (host->ops && host->ops->scan_bus)
> 	max = host->ops->scan_bus(b);
>     else
> 	max = pci_scan_child_bus(b);
> 
>     if (!found)
> 	pci_bus_update_busn_res_end(b, max);
> 

OK, I will try to change the of scan_bus(), and make it return the max bus number like pci_scan_child_bus().

>>  
>>  	return b;
>>  }
>> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index b621f5b..e9922b1 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  	return (pdev->error_state != pci_channel_io_normal);
>>  }
>>  
>> +struct pci_host_bridge;
>> +struct pci_host_bridge_ops {
>> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
>> +	int (*prepare)(struct pci_host_bridge *host);
>> +	void (*scan_bus)(struct pci_host_bridge *);
> 
> Needs an argument name to match the style of the other ops.

Sorry, I missed it, will add it, thanks.


> 
>> +};
>> +
>>  struct pci_host_bridge {
>>  	u16	domain;
>>  	u16 busnum;
>> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>>  	struct list_head list;
>> +	struct pci_host_bridge_ops *ops;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
  2015-03-12  3:23     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:14     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index c8e074d..59d9be3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>> +		bridge->ops->set_root_bus_speed(bridge);
> 
> Before this patch, can you do this:
> 
>   - Rename the powerpc pcibios_root_bridge_prepare() to
>     pcibios_set_root_bus_speed() and add a call to it here
> 
>   - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()
> 
> Then this patch will make a lot more sense because it will look like this,
> with the host bridge ops call right next to the matching pcibios call:
> 
>   +	if (host->ops && host->ops->prepare) {
>   +		error = host->ops->prepare(host);
>   +		...
>   +	}
> 	pcibios_root_bridge_prepare(...);
> 
>   +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>   +		bridge->ops->set_root_bus_speed(bridge);
> 	pcibios_set_root_bus_speed(...);

OK, will update.

> 
>>  	error = pcibios_root_bridge_prepare(bridge);
>>  	if (error)
>>  		goto err_out;
>> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>>  		pci_bus_insert_busn_res(b, b->number, 255);
>>  	}
>>  
>> -	max = pci_scan_child_bus(b);
>> -
>> -	if (!found)
>> -		pci_bus_update_busn_res_end(b, max);
>> +	if (host->ops && host->ops->scan_bus) {
>> +		host->ops->scan_bus(host);
>> +	} else {
>> +		max = pci_scan_child_bus(b);
>> +		if (!found)
>> +			pci_bus_update_busn_res_end(b, max);
>> +	}
> 
> I think host->ops->scan_bus() should have the same prototype as
> pci_scan_child_bus(), and it should return max, and you should do the same
> busn update as when you call pci_scan_child_bus().  So the code would look
> like this:
> 
>     if (host->ops && host->ops->scan_bus)
> 	max = host->ops->scan_bus(b);
>     else
> 	max = pci_scan_child_bus(b);
> 
>     if (!found)
> 	pci_bus_update_busn_res_end(b, max);
> 

OK, I will try to change the of scan_bus(), and make it return the max bus number like pci_scan_child_bus().

>>  
>>  	return b;
>>  }
>> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index b621f5b..e9922b1 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  	return (pdev->error_state != pci_channel_io_normal);
>>  }
>>  
>> +struct pci_host_bridge;
>> +struct pci_host_bridge_ops {
>> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
>> +	int (*prepare)(struct pci_host_bridge *host);
>> +	void (*scan_bus)(struct pci_host_bridge *);
> 
> Needs an argument name to match the style of the other ops.

Sorry, I missed it, will add it, thanks.


> 
>> +};
>> +
>>  struct pci_host_bridge {
>>  	u16	domain;
>>  	u16 busnum;
>> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>>  	struct list_head list;
>> +	struct pci_host_bridge_ops *ops;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12 13:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index c8e074d..59d9be3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>> +		bridge->ops->set_root_bus_speed(bridge);
> 
> Before this patch, can you do this:
> 
>   - Rename the powerpc pcibios_root_bridge_prepare() to
>     pcibios_set_root_bus_speed() and add a call to it here
> 
>   - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()
> 
> Then this patch will make a lot more sense because it will look like this,
> with the host bridge ops call right next to the matching pcibios call:
> 
>   +	if (host->ops && host->ops->prepare) {
>   +		error = host->ops->prepare(host);
>   +		...
>   +	}
> 	pcibios_root_bridge_prepare(...);
> 
>   +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>   +		bridge->ops->set_root_bus_speed(bridge);
> 	pcibios_set_root_bus_speed(...);

OK, will update.

> 
>>  	error = pcibios_root_bridge_prepare(bridge);
>>  	if (error)
>>  		goto err_out;
>> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>>  		pci_bus_insert_busn_res(b, b->number, 255);
>>  	}
>>  
>> -	max = pci_scan_child_bus(b);
>> -
>> -	if (!found)
>> -		pci_bus_update_busn_res_end(b, max);
>> +	if (host->ops && host->ops->scan_bus) {
>> +		host->ops->scan_bus(host);
>> +	} else {
>> +		max = pci_scan_child_bus(b);
>> +		if (!found)
>> +			pci_bus_update_busn_res_end(b, max);
>> +	}
> 
> I think host->ops->scan_bus() should have the same prototype as
> pci_scan_child_bus(), and it should return max, and you should do the same
> busn update as when you call pci_scan_child_bus().  So the code would look
> like this:
> 
>     if (host->ops && host->ops->scan_bus)
> 	max = host->ops->scan_bus(b);
>     else
> 	max = pci_scan_child_bus(b);
> 
>     if (!found)
> 	pci_bus_update_busn_res_end(b, max);
> 

OK, I will try to change the of scan_bus(), and make it return the max bus number like pci_scan_child_bus().

>>  
>>  	return b;
>>  }
>> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index b621f5b..e9922b1 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  	return (pdev->error_state != pci_channel_io_normal);
>>  }
>>  
>> +struct pci_host_bridge;
>> +struct pci_host_bridge_ops {
>> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
>> +	int (*prepare)(struct pci_host_bridge *host);
>> +	void (*scan_bus)(struct pci_host_bridge *);
> 
> Needs an argument name to match the style of the other ops.

Sorry, I missed it, will add it, thanks.


> 
>> +};
>> +
>>  struct pci_host_bridge {
>>  	u16	domain;
>>  	u16 busnum;
>> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>>  	struct list_head list;
>> +	struct pci_host_bridge_ops *ops;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12 13:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:14 UTC (permalink / raw)
  To: linux-arm-kernel

>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index c8e074d..59d9be3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>> +		bridge->ops->set_root_bus_speed(bridge);
> 
> Before this patch, can you do this:
> 
>   - Rename the powerpc pcibios_root_bridge_prepare() to
>     pcibios_set_root_bus_speed() and add a call to it here
> 
>   - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()
> 
> Then this patch will make a lot more sense because it will look like this,
> with the host bridge ops call right next to the matching pcibios call:
> 
>   +	if (host->ops && host->ops->prepare) {
>   +		error = host->ops->prepare(host);
>   +		...
>   +	}
> 	pcibios_root_bridge_prepare(...);
> 
>   +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>   +		bridge->ops->set_root_bus_speed(bridge);
> 	pcibios_set_root_bus_speed(...);

OK, will update.

> 
>>  	error = pcibios_root_bridge_prepare(bridge);
>>  	if (error)
>>  		goto err_out;
>> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>>  		pci_bus_insert_busn_res(b, b->number, 255);
>>  	}
>>  
>> -	max = pci_scan_child_bus(b);
>> -
>> -	if (!found)
>> -		pci_bus_update_busn_res_end(b, max);
>> +	if (host->ops && host->ops->scan_bus) {
>> +		host->ops->scan_bus(host);
>> +	} else {
>> +		max = pci_scan_child_bus(b);
>> +		if (!found)
>> +			pci_bus_update_busn_res_end(b, max);
>> +	}
> 
> I think host->ops->scan_bus() should have the same prototype as
> pci_scan_child_bus(), and it should return max, and you should do the same
> busn update as when you call pci_scan_child_bus().  So the code would look
> like this:
> 
>     if (host->ops && host->ops->scan_bus)
> 	max = host->ops->scan_bus(b);
>     else
> 	max = pci_scan_child_bus(b);
> 
>     if (!found)
> 	pci_bus_update_busn_res_end(b, max);
> 

OK, I will try to change the of scan_bus(), and make it return the max bus number like pci_scan_child_bus().

>>  
>>  	return b;
>>  }
>> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index b621f5b..e9922b1 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  	return (pdev->error_state != pci_channel_io_normal);
>>  }
>>  
>> +struct pci_host_bridge;
>> +struct pci_host_bridge_ops {
>> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
>> +	int (*prepare)(struct pci_host_bridge *host);
>> +	void (*scan_bus)(struct pci_host_bridge *);
> 
> Needs an argument name to match the style of the other ops.

Sorry, I missed it, will add it, thanks.


> 
>> +};
>> +
>>  struct pci_host_bridge {
>>  	u16	domain;
>>  	u16 busnum;
>> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>>  	struct list_head list;
>> +	struct pci_host_bridge_ops *ops;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12 13:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index c8e074d..59d9be3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>> +		bridge->ops->set_root_bus_speed(bridge);
> 
> Before this patch, can you do this:
> 
>   - Rename the powerpc pcibios_root_bridge_prepare() to
>     pcibios_set_root_bus_speed() and add a call to it here
> 
>   - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()
> 
> Then this patch will make a lot more sense because it will look like this,
> with the host bridge ops call right next to the matching pcibios call:
> 
>   +	if (host->ops && host->ops->prepare) {
>   +		error = host->ops->prepare(host);
>   +		...
>   +	}
> 	pcibios_root_bridge_prepare(...);
> 
>   +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>   +		bridge->ops->set_root_bus_speed(bridge);
> 	pcibios_set_root_bus_speed(...);

OK, will update.

> 
>>  	error = pcibios_root_bridge_prepare(bridge);
>>  	if (error)
>>  		goto err_out;
>> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>>  		pci_bus_insert_busn_res(b, b->number, 255);
>>  	}
>>  
>> -	max = pci_scan_child_bus(b);
>> -
>> -	if (!found)
>> -		pci_bus_update_busn_res_end(b, max);
>> +	if (host->ops && host->ops->scan_bus) {
>> +		host->ops->scan_bus(host);
>> +	} else {
>> +		max = pci_scan_child_bus(b);
>> +		if (!found)
>> +			pci_bus_update_busn_res_end(b, max);
>> +	}
> 
> I think host->ops->scan_bus() should have the same prototype as
> pci_scan_child_bus(), and it should return max, and you should do the same
> busn update as when you call pci_scan_child_bus().  So the code would look
> like this:
> 
>     if (host->ops && host->ops->scan_bus)
> 	max = host->ops->scan_bus(b);
>     else
> 	max = pci_scan_child_bus(b);
> 
>     if (!found)
> 	pci_bus_update_busn_res_end(b, max);
> 

OK, I will try to change the of scan_bus(), and make it return the max bus number like pci_scan_child_bus().

>>  
>>  	return b;
>>  }
>> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index b621f5b..e9922b1 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  	return (pdev->error_state != pci_channel_io_normal);
>>  }
>>  
>> +struct pci_host_bridge;
>> +struct pci_host_bridge_ops {
>> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
>> +	int (*prepare)(struct pci_host_bridge *host);
>> +	void (*scan_bus)(struct pci_host_bridge *);
> 
> Needs an argument name to match the style of the other ops.

Sorry, I missed it, will add it, thanks.


> 
>> +};
>> +
>>  struct pci_host_bridge {
>>  	u16	domain;
>>  	u16 busnum;
>> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>>  	struct list_head list;
>> +	struct pci_host_bridge_ops *ops;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
@ 2015-03-12 13:14       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index c8e074d..59d9be3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1889,6 +1889,8 @@ static struct pci_bus *__pci_create_root_bus(
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>> +		bridge->ops->set_root_bus_speed(bridge);
> 
> Before this patch, can you do this:
> 
>   - Rename the powerpc pcibios_root_bridge_prepare() to
>     pcibios_set_root_bus_speed() and add a call to it here
> 
>   - Move the pcibios_root_bridge_prepare() call to pci_create_host_bridge()
> 
> Then this patch will make a lot more sense because it will look like this,
> with the host bridge ops call right next to the matching pcibios call:
> 
>   +	if (host->ops && host->ops->prepare) {
>   +		error = host->ops->prepare(host);
>   +		...
>   +	}
> 	pcibios_root_bridge_prepare(...);
> 
>   +	if (bridge->ops && bridge->ops->set_root_bus_speed)
>   +		bridge->ops->set_root_bus_speed(bridge);
> 	pcibios_set_root_bus_speed(...);

OK, will update.

> 
>>  	error = pcibios_root_bridge_prepare(bridge);
>>  	if (error)
>>  		goto err_out;
>> @@ -1954,7 +1956,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> @@ -2051,10 +2053,13 @@ static struct pci_bus *__pci_scan_root_bus(
>>  		pci_bus_insert_busn_res(b, b->number, 255);
>>  	}
>>  
>> -	max = pci_scan_child_bus(b);
>> -
>> -	if (!found)
>> -		pci_bus_update_busn_res_end(b, max);
>> +	if (host->ops && host->ops->scan_bus) {
>> +		host->ops->scan_bus(host);
>> +	} else {
>> +		max = pci_scan_child_bus(b);
>> +		if (!found)
>> +			pci_bus_update_busn_res_end(b, max);
>> +	}
> 
> I think host->ops->scan_bus() should have the same prototype as
> pci_scan_child_bus(), and it should return max, and you should do the same
> busn update as when you call pci_scan_child_bus().  So the code would look
> like this:
> 
>     if (host->ops && host->ops->scan_bus)
> 	max = host->ops->scan_bus(b);
>     else
> 	max = pci_scan_child_bus(b);
> 
>     if (!found)
> 	pci_bus_update_busn_res_end(b, max);
> 

OK, I will try to change the of scan_bus(), and make it return the max bus number like pci_scan_child_bus().

>>  
>>  	return b;
>>  }
>> @@ -2064,7 +2069,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  {
>>  	struct pci_host_bridge *host;
>>  
>> -	host = pci_create_host_bridge(parent, db, resources, sysdata);
>> +	host = pci_create_host_bridge(parent, db, resources, sysdata, NULL);
>>  	if (!host)
>>  		return NULL;
>>  
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index b621f5b..e9922b1 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
>>  	return (pdev->error_state != pci_channel_io_normal);
>>  }
>>  
>> +struct pci_host_bridge;
>> +struct pci_host_bridge_ops {
>> +	void (*set_root_bus_speed)(struct pci_host_bridge *host);
>> +	int (*prepare)(struct pci_host_bridge *host);
>> +	void (*scan_bus)(struct pci_host_bridge *);
> 
> Needs an argument name to match the style of the other ops.

Sorry, I missed it, will add it, thanks.


> 
>> +};
>> +
>>  struct pci_host_bridge {
>>  	u16	domain;
>>  	u16 busnum;
>> @@ -407,6 +414,7 @@ struct pci_host_bridge {
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>>  	struct list_head list;
>> +	struct pci_host_bridge_ops *ops;
>>  	void (*release_fn)(struct pci_host_bridge *);
>>  	void *release_data;
>>  };
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
  2015-03-12  3:25     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:15       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:15 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 db, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops)
> 
> Drop the "phb_" prefix.

OK.

> 
>> +{
>> +	struct pci_host_bridge *host;
>> +	struct pci_bus *bus;
>> +
>> +	host = pci_create_host_bridge(parent, db, resources,
>> +			sysdata, phb_ops);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	bus = __pci_scan_root_bus(host, ops);
>> +	if (!bus)
>> +		pci_free_host_bridge(host);
>> +
>> +	return host;
>> +}
>> +EXPORT_SYMBOL(pci_scan_host_bridge);
>> +
>> +
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index e9922b1..28eafb5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 dombus, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>>  				int busnr);
>>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
  2015-03-12  3:25     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:15     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:15 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 db, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops)
> 
> Drop the "phb_" prefix.

OK.

> 
>> +{
>> +	struct pci_host_bridge *host;
>> +	struct pci_bus *bus;
>> +
>> +	host = pci_create_host_bridge(parent, db, resources,
>> +			sysdata, phb_ops);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	bus = __pci_scan_root_bus(host, ops);
>> +	if (!bus)
>> +		pci_free_host_bridge(host);
>> +
>> +	return host;
>> +}
>> +EXPORT_SYMBOL(pci_scan_host_bridge);
>> +
>> +
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index e9922b1..28eafb5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 dombus, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>>  				int busnr);
>>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12 13:15       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:15 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 db, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops)
> 
> Drop the "phb_" prefix.

OK.

> 
>> +{
>> +	struct pci_host_bridge *host;
>> +	struct pci_bus *bus;
>> +
>> +	host = pci_create_host_bridge(parent, db, resources,
>> +			sysdata, phb_ops);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	bus = __pci_scan_root_bus(host, ops);
>> +	if (!bus)
>> +		pci_free_host_bridge(host);
>> +
>> +	return host;
>> +}
>> +EXPORT_SYMBOL(pci_scan_host_bridge);
>> +
>> +
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index e9922b1..28eafb5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 dombus, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>>  				int busnr);
>>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12 13:15       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:15 UTC (permalink / raw)
  To: linux-arm-kernel

>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 db, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops)
> 
> Drop the "phb_" prefix.

OK.

> 
>> +{
>> +	struct pci_host_bridge *host;
>> +	struct pci_bus *bus;
>> +
>> +	host = pci_create_host_bridge(parent, db, resources,
>> +			sysdata, phb_ops);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	bus = __pci_scan_root_bus(host, ops);
>> +	if (!bus)
>> +		pci_free_host_bridge(host);
>> +
>> +	return host;
>> +}
>> +EXPORT_SYMBOL(pci_scan_host_bridge);
>> +
>> +
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index e9922b1..28eafb5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 dombus, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>>  				int busnr);
>>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
>> -- 
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12 13:15       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:15 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 db, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops)
> 
> Drop the "phb_" prefix.

OK.

> 
>> +{
>> +	struct pci_host_bridge *host;
>> +	struct pci_bus *bus;
>> +
>> +	host = pci_create_host_bridge(parent, db, resources,
>> +			sysdata, phb_ops);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	bus = __pci_scan_root_bus(host, ops);
>> +	if (!bus)
>> +		pci_free_host_bridge(host);
>> +
>> +	return host;
>> +}
>> +EXPORT_SYMBOL(pci_scan_host_bridge);
>> +
>> +
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index e9922b1..28eafb5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 dombus, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>>  				int busnr);
>>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge()
@ 2015-03-12 13:15       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:15 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 db, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops)
> 
> Drop the "phb_" prefix.

OK.

> 
>> +{
>> +	struct pci_host_bridge *host;
>> +	struct pci_bus *bus;
>> +
>> +	host = pci_create_host_bridge(parent, db, resources,
>> +			sysdata, phb_ops);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	bus = __pci_scan_root_bus(host, ops);
>> +	if (!bus)
>> +		pci_free_host_bridge(host);
>> +
>> +	return host;
>> +}
>> +EXPORT_SYMBOL(pci_scan_host_bridge);
>> +
>> +
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db,
>>  		struct pci_ops *ops, void *sysdata, struct list_head *resources)
>>  {
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index e9922b1..28eafb5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -790,6 +790,10 @@ void pci_bus_release_busn_res(struct pci_bus *b);
>>  struct pci_bus *pci_scan_root_bus(struct device *parent, u32 dombus,
>>  					     struct pci_ops *ops, void *sysdata,
>>  					     struct list_head *resources);
>> +struct pci_host_bridge *pci_scan_host_bridge(struct device *parent,
>> +		u32 dombus, struct pci_ops *ops, void *sysdata,
>> +		struct list_head *resources,
>> +		struct pci_host_bridge_ops *phb_ops);
>>  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
>>  				int busnr);
>>  void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
>> -- 
>> 1.7.1
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
  2015-03-12  3:30     ` Bjorn Helgaas
                         ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 13:17       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
  2015-03-12  3:30     ` Bjorn Helgaas
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 13:17     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12 13:17       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12 13:17       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: linux-arm-kernel

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12 13:17       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: linux-arm-kernel

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12 13:17       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity
@ 2015-03-12 13:17       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, sparclinux

>> @@ -667,22 +680,21 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>>  	pbm->busn.end	= pbm->pci_last_busno;
>>  	pbm->busn.flags	= IORESOURCE_BUS;
>>  	pci_add_resource(&resources, &pbm->busn);
>> -	bus = pci_create_root_bus(parent,
>> +	host = pci_scan_host_bridge(parent,
>>  			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
>> -			pbm->pci_ops, pbm, &resources);
>> -	if (!bus) {
>> -		printk(KERN_ERR "Failed to create bus for %s\n",
>> +			pbm->pci_ops, pbm, &resources, &phb_ops);
>> +	if (!host) {
>> +		printk(KERN_ERR "Failed to create host bridge for %s\n",
>>  		       node->full_name);
>>  		pci_free_resource_list(&resources);
>>  		return NULL;
>>  	}
>>  
> 
> I would keep "bus" and set it here:
> 
> 	bus = host->bus;
> 
> That would remove some lines from your patch that really didn't change,
> which makes it easier to see what actually *is* changing, namely, you're
> removing the pci_of_scan_bus() call because it is now done inside
> pci_scan_host_bridge().
> 

Yes, keep it will make the code more clean, thanks!

>> -	pci_of_scan_bus(pbm, node, bus);
>> -	pci_bus_register_of_sysfs(bus);
>> +	pci_bus_register_of_sysfs(host->bus);
>>  
>> -	pci_claim_bus_resources(bus);
>> -	pci_bus_add_devices(bus);
>> -	return bus;
>> +	pci_claim_bus_resources(host->bus);
>> +	pci_bus_add_devices(host->bus);
>> +	return host->bus;
>>  }
>>  
>>  void pcibios_fixup_bus(struct pci_bus *pbus)
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-12  3:33     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:24       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-12  3:33     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:24     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:24       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:24       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:24 UTC (permalink / raw)
  To: linux-arm-kernel

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
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:24       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:24       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-12  3:36     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:28       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-12  3:36     ` Bjorn Helgaas
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 13:28     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:28       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:28       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:28 UTC (permalink / raw)
  To: linux-arm-kernel

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
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:28       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 13:28       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
  2015-03-12  3:43     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:29       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>> index a1dc9f2..45252dd 100644
>> --- a/drivers/pci/pci.h
>> +++ b/drivers/pci/pci.h
>> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  		void *sysdata, struct pci_host_bridge_ops *ops);
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
> 
> This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
> pci_domain_nr().  Can you drop this patch and put the generic
> pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
> pci.c?

Of course, thanks.

> 
>> +
>>  #endif /* DRIVERS_PCI_H */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12 13:29       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>> index a1dc9f2..45252dd 100644
>> --- a/drivers/pci/pci.h
>> +++ b/drivers/pci/pci.h
>> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  		void *sysdata, struct pci_host_bridge_ops *ops);
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
> 
> This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
> pci_domain_nr().  Can you drop this patch and put the generic
> pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
> pci.c?

Of course, thanks.

> 
>> +
>>  #endif /* DRIVERS_PCI_H */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12 13:29       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>> index a1dc9f2..45252dd 100644
>> --- a/drivers/pci/pci.h
>> +++ b/drivers/pci/pci.h
>> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  		void *sysdata, struct pci_host_bridge_ops *ops);
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
> 
> This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
> pci_domain_nr().  Can you drop this patch and put the generic
> pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
> pci.c?

Of course, thanks.

> 
>> +
>>  #endif /* DRIVERS_PCI_H */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12 13:29       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:29 UTC (permalink / raw)
  To: linux-arm-kernel

>> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>> index a1dc9f2..45252dd 100644
>> --- a/drivers/pci/pci.h
>> +++ b/drivers/pci/pci.h
>> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  		void *sysdata, struct pci_host_bridge_ops *ops);
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
> 
> This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
> pci_domain_nr().  Can you drop this patch and put the generic
> pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
> pci.c?

Of course, thanks.

> 
>> +
>>  #endif /* DRIVERS_PCI_H */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge()
@ 2015-03-12 13:29       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>> index a1dc9f2..45252dd 100644
>> --- a/drivers/pci/pci.h
>> +++ b/drivers/pci/pci.h
>> @@ -328,4 +328,6 @@ struct pci_host_bridge *pci_create_host_bridge(
>>  		void *sysdata, struct pci_host_bridge_ops *ops);
>>  
>>  void pci_free_host_bridge(struct pci_host_bridge *host);
>> +struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
> 
> This is only used in drivers/pci/host-bridge.c and in drivers/pci/pci.c for
> pci_domain_nr().  Can you drop this patch and put the generic
> pci_domain_nr() implementation (next patch) in host-bridge.c instead of in
> pci.c?

Of course, thanks.

> 
>> +
>>  #endif /* DRIVERS_PCI_H */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
  2015-03-12  3:48     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:32       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 11:48, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
>> Now we save the domain number in pci_host_bridge,
>> we could remove pci_bus_assign_domain_nr() and
>> clean the domain member in pci_bus.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/pci.c   |    5 -----
>>  drivers/pci/probe.c |   12 ++++--------
>>  include/linux/pci.h |    3 ---
>>  3 files changed, 4 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 2cf942b..4d8dfe4 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>>  {
>>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>>  }
>> -
>> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>> -{
>> -	bus->domain_nr = pci_assign_domain_nr(parent);
>> -}
> 
> I think you forgot to remove the empty pci_bus_assign_domain_nr()
> definition from include/linux/pci.h.

Yes, I forgot it, thanks your remind.

> 
> I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
> removed *almost* everything that uses it.  I wonder how hard it would be to
> get rid of that last little bit.

I will take time to find it, thanks!


> 
>>  #endif
>>  #endif
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 196f08a..9cd3ca2 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>>  	}
>>  }
>>  
>> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>> +static struct pci_bus *pci_alloc_bus(void)
>>  {
>>  	struct pci_bus *b;
>>  
>> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	INIT_LIST_HEAD(&b->resources);
>>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	if (parent)
>> -		b->domain_nr = parent->domain_nr;
>> -#endif
>> +
>>  	return b;
>>  }
>>  
>> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>>  	/*
>>  	 * Allocate a new bus, and inherit stuff from the parent..
>>  	 */
>> -	child = pci_alloc_bus(parent);
>> +	child = pci_alloc_bus();
>>  	if (!child)
>>  		return NULL;
>>  
>> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>>  	char *fmt;
>>  
>>  	parent = bridge->dev.parent;
>> -	b = pci_alloc_bus(NULL);
>> +	b = pci_alloc_bus();
>>  	if (!b)
>>  		return NULL;
>>  
>>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>> -	pci_bus_assign_domain_nr(b, parent);
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index dc1c710..ebc70bb 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -467,9 +467,6 @@ struct pci_bus {
>>  	unsigned char	primary;	/* number of primary bridge */
>>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	int		domain_nr;
>> -#endif
>>  
>>  	char		name[48];
>>  
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
  2015-03-12  3:48     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:32     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 11:48, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
>> Now we save the domain number in pci_host_bridge,
>> we could remove pci_bus_assign_domain_nr() and
>> clean the domain member in pci_bus.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/pci.c   |    5 -----
>>  drivers/pci/probe.c |   12 ++++--------
>>  include/linux/pci.h |    3 ---
>>  3 files changed, 4 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 2cf942b..4d8dfe4 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>>  {
>>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>>  }
>> -
>> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>> -{
>> -	bus->domain_nr = pci_assign_domain_nr(parent);
>> -}
> 
> I think you forgot to remove the empty pci_bus_assign_domain_nr()
> definition from include/linux/pci.h.

Yes, I forgot it, thanks your remind.

> 
> I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
> removed *almost* everything that uses it.  I wonder how hard it would be to
> get rid of that last little bit.

I will take time to find it, thanks!


> 
>>  #endif
>>  #endif
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 196f08a..9cd3ca2 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>>  	}
>>  }
>>  
>> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>> +static struct pci_bus *pci_alloc_bus(void)
>>  {
>>  	struct pci_bus *b;
>>  
>> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	INIT_LIST_HEAD(&b->resources);
>>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	if (parent)
>> -		b->domain_nr = parent->domain_nr;
>> -#endif
>> +
>>  	return b;
>>  }
>>  
>> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>>  	/*
>>  	 * Allocate a new bus, and inherit stuff from the parent..
>>  	 */
>> -	child = pci_alloc_bus(parent);
>> +	child = pci_alloc_bus();
>>  	if (!child)
>>  		return NULL;
>>  
>> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>>  	char *fmt;
>>  
>>  	parent = bridge->dev.parent;
>> -	b = pci_alloc_bus(NULL);
>> +	b = pci_alloc_bus();
>>  	if (!b)
>>  		return NULL;
>>  
>>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>> -	pci_bus_assign_domain_nr(b, parent);
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index dc1c710..ebc70bb 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -467,9 +467,6 @@ struct pci_bus {
>>  	unsigned char	primary;	/* number of primary bridge */
>>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	int		domain_nr;
>> -#endif
>>  
>>  	char		name[48];
>>  
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12 13:32       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 11:48, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
>> Now we save the domain number in pci_host_bridge,
>> we could remove pci_bus_assign_domain_nr() and
>> clean the domain member in pci_bus.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/pci.c   |    5 -----
>>  drivers/pci/probe.c |   12 ++++--------
>>  include/linux/pci.h |    3 ---
>>  3 files changed, 4 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 2cf942b..4d8dfe4 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>>  {
>>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>>  }
>> -
>> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>> -{
>> -	bus->domain_nr = pci_assign_domain_nr(parent);
>> -}
> 
> I think you forgot to remove the empty pci_bus_assign_domain_nr()
> definition from include/linux/pci.h.

Yes, I forgot it, thanks your remind.

> 
> I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
> removed *almost* everything that uses it.  I wonder how hard it would be to
> get rid of that last little bit.

I will take time to find it, thanks!


> 
>>  #endif
>>  #endif
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 196f08a..9cd3ca2 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>>  	}
>>  }
>>  
>> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>> +static struct pci_bus *pci_alloc_bus(void)
>>  {
>>  	struct pci_bus *b;
>>  
>> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	INIT_LIST_HEAD(&b->resources);
>>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	if (parent)
>> -		b->domain_nr = parent->domain_nr;
>> -#endif
>> +
>>  	return b;
>>  }
>>  
>> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>>  	/*
>>  	 * Allocate a new bus, and inherit stuff from the parent..
>>  	 */
>> -	child = pci_alloc_bus(parent);
>> +	child = pci_alloc_bus();
>>  	if (!child)
>>  		return NULL;
>>  
>> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>>  	char *fmt;
>>  
>>  	parent = bridge->dev.parent;
>> -	b = pci_alloc_bus(NULL);
>> +	b = pci_alloc_bus();
>>  	if (!b)
>>  		return NULL;
>>  
>>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>> -	pci_bus_assign_domain_nr(b, parent);
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index dc1c710..ebc70bb 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -467,9 +467,6 @@ struct pci_bus {
>>  	unsigned char	primary;	/* number of primary bridge */
>>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	int		domain_nr;
>> -#endif
>>  
>>  	char		name[48];
>>  
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12 13:32       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/12 11:48, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
>> Now we save the domain number in pci_host_bridge,
>> we could remove pci_bus_assign_domain_nr() and
>> clean the domain member in pci_bus.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/pci.c   |    5 -----
>>  drivers/pci/probe.c |   12 ++++--------
>>  include/linux/pci.h |    3 ---
>>  3 files changed, 4 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 2cf942b..4d8dfe4 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>>  {
>>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>>  }
>> -
>> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>> -{
>> -	bus->domain_nr = pci_assign_domain_nr(parent);
>> -}
> 
> I think you forgot to remove the empty pci_bus_assign_domain_nr()
> definition from include/linux/pci.h.

Yes, I forgot it, thanks your remind.

> 
> I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
> removed *almost* everything that uses it.  I wonder how hard it would be to
> get rid of that last little bit.

I will take time to find it, thanks!


> 
>>  #endif
>>  #endif
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 196f08a..9cd3ca2 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>>  	}
>>  }
>>  
>> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>> +static struct pci_bus *pci_alloc_bus(void)
>>  {
>>  	struct pci_bus *b;
>>  
>> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	INIT_LIST_HEAD(&b->resources);
>>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	if (parent)
>> -		b->domain_nr = parent->domain_nr;
>> -#endif
>> +
>>  	return b;
>>  }
>>  
>> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>>  	/*
>>  	 * Allocate a new bus, and inherit stuff from the parent..
>>  	 */
>> -	child = pci_alloc_bus(parent);
>> +	child = pci_alloc_bus();
>>  	if (!child)
>>  		return NULL;
>>  
>> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>>  	char *fmt;
>>  
>>  	parent = bridge->dev.parent;
>> -	b = pci_alloc_bus(NULL);
>> +	b = pci_alloc_bus();
>>  	if (!b)
>>  		return NULL;
>>  
>>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>> -	pci_bus_assign_domain_nr(b, parent);
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index dc1c710..ebc70bb 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -467,9 +467,6 @@ struct pci_bus {
>>  	unsigned char	primary;	/* number of primary bridge */
>>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	int		domain_nr;
>> -#endif
>>  
>>  	char		name[48];
>>  
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12 13:32       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 11:48, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
>> Now we save the domain number in pci_host_bridge,
>> we could remove pci_bus_assign_domain_nr() and
>> clean the domain member in pci_bus.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/pci.c   |    5 -----
>>  drivers/pci/probe.c |   12 ++++--------
>>  include/linux/pci.h |    3 ---
>>  3 files changed, 4 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 2cf942b..4d8dfe4 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>>  {
>>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>>  }
>> -
>> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>> -{
>> -	bus->domain_nr = pci_assign_domain_nr(parent);
>> -}
> 
> I think you forgot to remove the empty pci_bus_assign_domain_nr()
> definition from include/linux/pci.h.

Yes, I forgot it, thanks your remind.

> 
> I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
> removed *almost* everything that uses it.  I wonder how hard it would be to
> get rid of that last little bit.

I will take time to find it, thanks!


> 
>>  #endif
>>  #endif
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 196f08a..9cd3ca2 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>>  	}
>>  }
>>  
>> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>> +static struct pci_bus *pci_alloc_bus(void)
>>  {
>>  	struct pci_bus *b;
>>  
>> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	INIT_LIST_HEAD(&b->resources);
>>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	if (parent)
>> -		b->domain_nr = parent->domain_nr;
>> -#endif
>> +
>>  	return b;
>>  }
>>  
>> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>>  	/*
>>  	 * Allocate a new bus, and inherit stuff from the parent..
>>  	 */
>> -	child = pci_alloc_bus(parent);
>> +	child = pci_alloc_bus();
>>  	if (!child)
>>  		return NULL;
>>  
>> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>>  	char *fmt;
>>  
>>  	parent = bridge->dev.parent;
>> -	b = pci_alloc_bus(NULL);
>> +	b = pci_alloc_bus();
>>  	if (!b)
>>  		return NULL;
>>  
>>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>> -	pci_bus_assign_domain_nr(b, parent);
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index dc1c710..ebc70bb 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -467,9 +467,6 @@ struct pci_bus {
>>  	unsigned char	primary;	/* number of primary bridge */
>>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	int		domain_nr;
>> -#endif
>>  
>>  	char		name[48];
>>  
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr()
@ 2015-03-12 13:32       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/12 11:48, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:34:27AM +0800, Yijing Wang wrote:
>> Now we save the domain number in pci_host_bridge,
>> we could remove pci_bus_assign_domain_nr() and
>> clean the domain member in pci_bus.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/pci.c   |    5 -----
>>  drivers/pci/probe.c |   12 ++++--------
>>  include/linux/pci.h |    3 ---
>>  3 files changed, 4 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 2cf942b..4d8dfe4 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4581,11 +4581,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host)
>>  {
>>  	host->domain = pci_assign_domain_nr(host->dev.parent);
>>  }
>> -
>> -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>> -{
>> -	bus->domain_nr = pci_assign_domain_nr(parent);
>> -}
> 
> I think you forgot to remove the empty pci_bus_assign_domain_nr()
> definition from include/linux/pci.h.

Yes, I forgot it, thanks your remind.

> 
> I'm not sure how much value is left in CONFIG_PCI_DOMAINS_GENERIC.  You're
> removed *almost* everything that uses it.  I wonder how hard it would be to
> get rid of that last little bit.

I will take time to find it, thanks!


> 
>>  #endif
>>  #endif
>>  
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 196f08a..9cd3ca2 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -481,7 +481,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
>>  	}
>>  }
>>  
>> -static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>> +static struct pci_bus *pci_alloc_bus(void)
>>  {
>>  	struct pci_bus *b;
>>  
>> @@ -496,10 +496,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	INIT_LIST_HEAD(&b->resources);
>>  	b->max_bus_speed = PCI_SPEED_UNKNOWN;
>>  	b->cur_bus_speed = PCI_SPEED_UNKNOWN;
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	if (parent)
>> -		b->domain_nr = parent->domain_nr;
>> -#endif
>> +
>>  	return b;
>>  }
>>  
>> @@ -646,7 +643,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>>  	/*
>>  	 * Allocate a new bus, and inherit stuff from the parent..
>>  	 */
>> -	child = pci_alloc_bus(parent);
>> +	child = pci_alloc_bus();
>>  	if (!child)
>>  		return NULL;
>>  
>> @@ -1866,14 +1863,13 @@ static struct pci_bus *pci_create_root_bus(
>>  	char *fmt;
>>  
>>  	parent = bridge->dev.parent;
>> -	b = pci_alloc_bus(NULL);
>> +	b = pci_alloc_bus();
>>  	if (!b)
>>  		return NULL;
>>  
>>  	b->sysdata = dev_get_drvdata(&bridge->dev);
>>  	b->ops = ops;
>>  	b->number = b->busn_res.start = bridge->busnum;
>> -	pci_bus_assign_domain_nr(b, parent);
>>  
>>  	bridge->bus = b;
>>  	b->bridge = get_device(&bridge->dev);
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index dc1c710..ebc70bb 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -467,9 +467,6 @@ struct pci_bus {
>>  	unsigned char	primary;	/* number of primary bridge */
>>  	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>>  	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
>> -#ifdef CONFIG_PCI_DOMAINS_GENERIC
>> -	int		domain_nr;
>> -#endif
>>  
>>  	char		name[48];
>>  
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-12  3:52     ` Bjorn Helgaas
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:44       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	host->busnum = bus;
>> +	host->domain = domain;
>> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +	 * pci_host_assign_domain_nr() to assign domain
>> +	 * number instead PCI_DOMAIN(db).
>> +	 */
> 
> Follow the normal Linux comment style:
> 
> 	host->domain = domain;
> 
> 	/*
> 	 * If we support ...
> 	 */

OK.

> 
>> +	pci_host_assign_domain_nr(host);
>> +
...
>>  
>> +struct pci_host_bridge *pci_create_host_bridge(
>> +		struct device *parent, u32 dombus, struct list_head *resources);
>> +void pci_free_host_bridge(struct pci_host_bridge *host);
> 
> A later patch adds another declaration and a blank line here.  If you want
> the blank line, add it here, when you're adding the first declarations in
> this section.

OK.

> 
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 3d6befd..27ec612 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	return b;
>>  }
...
>>  struct pci_host_bridge {
>>  	u16	domain;
>> +	u16 busnum;
> 
> Why do we need this?  host_bridge->bus->number and
> host_bridge->bus->busn_res.start both already contain the same information,
> and I hate to add a third place.  I know pci_create_host_bridge() doesn't
> have a struct pci_bus at the point where you initialize busnum, but it does
> have the resource list, which contains the bus number range.

Hmm, I will try to remove it, I put it here because when call pci_create_root_bus(),
I could only pass the pci_host_bridge_ops, don't need to provide the bus number,
pci_scan_root_bus() may lack the bus number resource at that time.
But I think fix it is not a hard job, I will rework it, thanks.


> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-12  3:52     ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-12 13:44     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	host->busnum = bus;
>> +	host->domain = domain;
>> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +	 * pci_host_assign_domain_nr() to assign domain
>> +	 * number instead PCI_DOMAIN(db).
>> +	 */
> 
> Follow the normal Linux comment style:
> 
> 	host->domain = domain;
> 
> 	/*
> 	 * If we support ...
> 	 */

OK.

> 
>> +	pci_host_assign_domain_nr(host);
>> +
...
>>  
>> +struct pci_host_bridge *pci_create_host_bridge(
>> +		struct device *parent, u32 dombus, struct list_head *resources);
>> +void pci_free_host_bridge(struct pci_host_bridge *host);
> 
> A later patch adds another declaration and a blank line here.  If you want
> the blank line, add it here, when you're adding the first declarations in
> this section.

OK.

> 
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 3d6befd..27ec612 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	return b;
>>  }
...
>>  struct pci_host_bridge {
>>  	u16	domain;
>> +	u16 busnum;
> 
> Why do we need this?  host_bridge->bus->number and
> host_bridge->bus->busn_res.start both already contain the same information,
> and I hate to add a third place.  I know pci_create_host_bridge() doesn't
> have a struct pci_bus at the point where you initialize busnum, but it does
> have the resource list, which contains the bus number range.

Hmm, I will try to remove it, I put it here because when call pci_create_root_bus(),
I could only pass the pci_host_bridge_ops, don't need to provide the bus number,
pci_scan_root_bus() may lack the bus number resource at that time.
But I think fix it is not a hard job, I will rework it, thanks.


> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12 13:44       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	host->busnum = bus;
>> +	host->domain = domain;
>> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +	 * pci_host_assign_domain_nr() to assign domain
>> +	 * number instead PCI_DOMAIN(db).
>> +	 */
> 
> Follow the normal Linux comment style:
> 
> 	host->domain = domain;
> 
> 	/*
> 	 * If we support ...
> 	 */

OK.

> 
>> +	pci_host_assign_domain_nr(host);
>> +
...
>>  
>> +struct pci_host_bridge *pci_create_host_bridge(
>> +		struct device *parent, u32 dombus, struct list_head *resources);
>> +void pci_free_host_bridge(struct pci_host_bridge *host);
> 
> A later patch adds another declaration and a blank line here.  If you want
> the blank line, add it here, when you're adding the first declarations in
> this section.

OK.

> 
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 3d6befd..27ec612 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	return b;
>>  }
...
>>  struct pci_host_bridge {
>>  	u16	domain;
>> +	u16 busnum;
> 
> Why do we need this?  host_bridge->bus->number and
> host_bridge->bus->busn_res.start both already contain the same information,
> and I hate to add a third place.  I know pci_create_host_bridge() doesn't
> have a struct pci_bus at the point where you initialize busnum, but it does
> have the resource list, which contains the bus number range.

Hmm, I will try to remove it, I put it here because when call pci_create_root_bus(),
I could only pass the pci_host_bridge_ops, don't need to provide the bus number,
pci_scan_root_bus() may lack the bus number resource at that time.
But I think fix it is not a hard job, I will rework it, thanks.


> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12 13:44       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:44 UTC (permalink / raw)
  To: linux-arm-kernel

>> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	host->busnum = bus;
>> +	host->domain = domain;
>> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +	 * pci_host_assign_domain_nr() to assign domain
>> +	 * number instead PCI_DOMAIN(db).
>> +	 */
> 
> Follow the normal Linux comment style:
> 
> 	host->domain = domain;
> 
> 	/*
> 	 * If we support ...
> 	 */

OK.

> 
>> +	pci_host_assign_domain_nr(host);
>> +
...
>>  
>> +struct pci_host_bridge *pci_create_host_bridge(
>> +		struct device *parent, u32 dombus, struct list_head *resources);
>> +void pci_free_host_bridge(struct pci_host_bridge *host);
> 
> A later patch adds another declaration and a blank line here.  If you want
> the blank line, add it here, when you're adding the first declarations in
> this section.

OK.

> 
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 3d6befd..27ec612 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	return b;
>>  }
...
>>  struct pci_host_bridge {
>>  	u16	domain;
>> +	u16 busnum;
> 
> Why do we need this?  host_bridge->bus->number and
> host_bridge->bus->busn_res.start both already contain the same information,
> and I hate to add a third place.  I know pci_create_host_bridge() doesn't
> have a struct pci_bus at the point where you initialize busnum, but it does
> have the resource list, which contains the bus number range.

Hmm, I will try to remove it, I put it here because when call pci_create_root_bus(),
I could only pass the pci_host_bridge_ops, don't need to provide the bus number,
pci_scan_root_bus() may lack the bus number resource at that time.
But I think fix it is not a hard job, I will rework it, thanks.


> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12 13:44       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	host->busnum = bus;
>> +	host->domain = domain;
>> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +	 * pci_host_assign_domain_nr() to assign domain
>> +	 * number instead PCI_DOMAIN(db).
>> +	 */
> 
> Follow the normal Linux comment style:
> 
> 	host->domain = domain;
> 
> 	/*
> 	 * If we support ...
> 	 */

OK.

> 
>> +	pci_host_assign_domain_nr(host);
>> +
...
>>  
>> +struct pci_host_bridge *pci_create_host_bridge(
>> +		struct device *parent, u32 dombus, struct list_head *resources);
>> +void pci_free_host_bridge(struct pci_host_bridge *host);
> 
> A later patch adds another declaration and a blank line here.  If you want
> the blank line, add it here, when you're adding the first declarations in
> this section.

OK.

> 
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 3d6befd..27ec612 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	return b;
>>  }
...
>>  struct pci_host_bridge {
>>  	u16	domain;
>> +	u16 busnum;
> 
> Why do we need this?  host_bridge->bus->number and
> host_bridge->bus->busn_res.start both already contain the same information,
> and I hate to add a third place.  I know pci_create_host_bridge() doesn't
> have a struct pci_bus at the point where you initialize busnum, but it does
> have the resource list, which contains the bus number range.

Hmm, I will try to remove it, I put it here because when call pci_create_root_bus(),
I could only pass the pci_host_bridge_ops, don't need to provide the bus number,
pci_scan_root_bus() may lack the bus number resource at that time.
But I think fix it is not a hard job, I will rework it, thanks.


> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-12 13:44       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-12 13:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +	if (!host)
>> +		return NULL;
>> +
>> +	host->busnum = bus;
>> +	host->domain = domain;
>> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +	 * pci_host_assign_domain_nr() to assign domain
>> +	 * number instead PCI_DOMAIN(db).
>> +	 */
> 
> Follow the normal Linux comment style:
> 
> 	host->domain = domain;
> 
> 	/*
> 	 * If we support ...
> 	 */

OK.

> 
>> +	pci_host_assign_domain_nr(host);
>> +
...
>>  
>> +struct pci_host_bridge *pci_create_host_bridge(
>> +		struct device *parent, u32 dombus, struct list_head *resources);
>> +void pci_free_host_bridge(struct pci_host_bridge *host);
> 
> A later patch adds another declaration and a blank line here.  If you want
> the blank line, add it here, when you're adding the first declarations in
> this section.

OK.

> 
>>  #endif /* DRIVERS_PCI_H */
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 3d6befd..27ec612 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -503,31 +503,6 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
>>  	return b;
>>  }
...
>>  struct pci_host_bridge {
>>  	u16	domain;
>> +	u16 busnum;
> 
> Why do we need this?  host_bridge->bus->number and
> host_bridge->bus->busn_res.start both already contain the same information,
> and I hate to add a third place.  I know pci_create_host_bridge() doesn't
> have a struct pci_bus at the point where you initialize busnum, but it does
> have the resource list, which contains the bus number range.

Hmm, I will try to remove it, I put it here because when call pci_create_root_bus(),
I could only pass the pci_host_bridge_ops, don't need to provide the bus number,
pci_scan_root_bus() may lack the bus number resource at that time.
But I think fix it is not a hard job, I will rework it, thanks.


> 
>>  	struct device dev;
>>  	struct pci_bus *bus;		/* root bus */
>>  	struct list_head windows;	/* resource_entry */
>> -- 
>> 1.7.1
>>
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-12 11:42       ` Yijing Wang
  (?)
  (?)
@ 2015-03-12 19:32         ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 07:42:25PM +0800, Yijing Wang wrote:
> >> -static struct resource busn_resource = {
> >> +struct resource busn_resource = {
> >>  	.name	= "PCI busn",
> >>  	.start	= 0,
> >>  	.end	= 255,
> >>  	.flags	= IORESOURCE_BUS,
> >>  };
> >> +EXPORT_SYMBOL(busn_resource);
> > 
> > I don't think this is a good idea.  We support multiple PCI domains, and
> > each domain has its own 0-255 bus number range.  This busn_resource is
> > only for domain 0 and probably should be handled in arch code instead of
> > the PCI core.
> > 
> > Right now, I think it's possible to call pci_scan_bus_parented() or
> > pci_scan_bus() several times for buses in different domains, and they would
> > all share the same busn_resource, which would cause corruption.
> > 
> > So it's already broken, but I don't want to make it harder to fix by
> > exporting this stuff.
> 
> Hi Bjorn, busn_resource may would not be shared by multi domains,
> 
> We insert bus number resource like:
> 
> pci_add_resource(&resources, &busn_resource);	
> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
> 
> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

The intent of pci_add_resource() and passing the resulting resource list
into pci_scan_root_bus(), etc., is that the host bridge may consume any
resources described by the list.  If we pass the same resource to multiple
calls, that means the resource must be shared between the multiple host
bridges involved.  For bus numbers, that makes some sense if the platform
considers the bridges to be in the same domain, but not if they are in
different domains.

If we export busn_resource, we have no control over what domains it becomes
associated with because the domain is passed into pci_scan_root_bus() by
the caller.

Bjorn

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 19:32         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 07:42:25PM +0800, Yijing Wang wrote:
> >> -static struct resource busn_resource = {
> >> +struct resource busn_resource = {
> >>  	.name	= "PCI busn",
> >>  	.start	= 0,
> >>  	.end	= 255,
> >>  	.flags	= IORESOURCE_BUS,
> >>  };
> >> +EXPORT_SYMBOL(busn_resource);
> > 
> > I don't think this is a good idea.  We support multiple PCI domains, and
> > each domain has its own 0-255 bus number range.  This busn_resource is
> > only for domain 0 and probably should be handled in arch code instead of
> > the PCI core.
> > 
> > Right now, I think it's possible to call pci_scan_bus_parented() or
> > pci_scan_bus() several times for buses in different domains, and they would
> > all share the same busn_resource, which would cause corruption.
> > 
> > So it's already broken, but I don't want to make it harder to fix by
> > exporting this stuff.
> 
> Hi Bjorn, busn_resource may would not be shared by multi domains,
> 
> We insert bus number resource like:
> 
> pci_add_resource(&resources, &busn_resource);	
> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
> 
> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

The intent of pci_add_resource() and passing the resulting resource list
into pci_scan_root_bus(), etc., is that the host bridge may consume any
resources described by the list.  If we pass the same resource to multiple
calls, that means the resource must be shared between the multiple host
bridges involved.  For bus numbers, that makes some sense if the platform
considers the bridges to be in the same domain, but not if they are in
different domains.

If we export busn_resource, we have no control over what domains it becomes
associated with because the domain is passed into pci_scan_root_bus() by
the caller.

Bjorn

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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 19:32         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 07:42:25PM +0800, Yijing Wang wrote:
> >> -static struct resource busn_resource = {
> >> +struct resource busn_resource = {
> >>  	.name	= "PCI busn",
> >>  	.start	= 0,
> >>  	.end	= 255,
> >>  	.flags	= IORESOURCE_BUS,
> >>  };
> >> +EXPORT_SYMBOL(busn_resource);
> > 
> > I don't think this is a good idea.  We support multiple PCI domains, and
> > each domain has its own 0-255 bus number range.  This busn_resource is
> > only for domain 0 and probably should be handled in arch code instead of
> > the PCI core.
> > 
> > Right now, I think it's possible to call pci_scan_bus_parented() or
> > pci_scan_bus() several times for buses in different domains, and they would
> > all share the same busn_resource, which would cause corruption.
> > 
> > So it's already broken, but I don't want to make it harder to fix by
> > exporting this stuff.
> 
> Hi Bjorn, busn_resource may would not be shared by multi domains,
> 
> We insert bus number resource like:
> 
> pci_add_resource(&resources, &busn_resource);	
> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
> 
> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

The intent of pci_add_resource() and passing the resulting resource list
into pci_scan_root_bus(), etc., is that the host bridge may consume any
resources described by the list.  If we pass the same resource to multiple
calls, that means the resource must be shared between the multiple host
bridges involved.  For bus numbers, that makes some sense if the platform
considers the bridges to be in the same domain, but not if they are in
different domains.

If we export busn_resource, we have no control over what domains it becomes
associated with because the domain is passed into pci_scan_root_bus() by
the caller.

Bjorn

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-12 19:32         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:32 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 07:42:25PM +0800, Yijing Wang wrote:
> >> -static struct resource busn_resource = {
> >> +struct resource busn_resource = {
> >>  	.name	= "PCI busn",
> >>  	.start	= 0,
> >>  	.end	= 255,
> >>  	.flags	= IORESOURCE_BUS,
> >>  };
> >> +EXPORT_SYMBOL(busn_resource);
> > 
> > I don't think this is a good idea.  We support multiple PCI domains, and
> > each domain has its own 0-255 bus number range.  This busn_resource is
> > only for domain 0 and probably should be handled in arch code instead of
> > the PCI core.
> > 
> > Right now, I think it's possible to call pci_scan_bus_parented() or
> > pci_scan_bus() several times for buses in different domains, and they would
> > all share the same busn_resource, which would cause corruption.
> > 
> > So it's already broken, but I don't want to make it harder to fix by
> > exporting this stuff.
> 
> Hi Bjorn, busn_resource may would not be shared by multi domains,
> 
> We insert bus number resource like:
> 
> pci_add_resource(&resources, &busn_resource);	
> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here = 255
> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
> 
> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.

The intent of pci_add_resource() and passing the resulting resource list
into pci_scan_root_bus(), etc., is that the host bridge may consume any
resources described by the list.  If we pass the same resource to multiple
calls, that means the resource must be shared between the multiple host
bridges involved.  For bus numbers, that makes some sense if the platform
considers the bridges to be in the same domain, but not if they are in
different domains.

If we export busn_resource, we have no control over what domains it becomes
associated with because the domain is passed into pci_scan_root_bus() by
the caller.

Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-12 11:46       ` Yijing Wang
  (?)
  (?)
@ 2015-03-12 19:35         ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:35 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 07:46:45PM +0800, Yijing Wang wrote:
> >>  	struct pci_bus *b;
> >> +	LIST_HEAD(resources);
> >>  	struct pcifront_sd *sd = NULL;
> >>  	struct pci_bus_entry *bus_entry = NULL;
> >>  	int err = 0;
> >> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  		err = -ENOMEM;
> >>  		goto err_out;
> >>  	}
> >> +	pci_add_resource(&resources, &ioport_resource);
> >> +	pci_add_resource(&resources, &iomem_resource);
> >> +	pci_add_resource(&resources, &busn_resource);
> > 
> > Since I don't want to export busn_resource, you might have to allocate your
> > own struct resource for it here.  And, of course, figure out the details of
> > which PCI domain you're in and whether you need to share one struct
> > resource across several host bridges in the same domain.
> 
> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> so do we still need to add additional info to figure out which domain own the bus resource ?

That's up to the caller.  Only the platform knows which bridges it wants to
have in the same domain.  In principle, every host bridge could be in its
own domain, since each bridge is the root of a unique PCI hierarchy.  But
some platforms have firmware that assumes otherwise.  I have no idea what
xen assumes.

> >>  	pcifront_init_sd(sd, domain, bus, pdev);
> >>  
> >>  	pci_lock_rescan_remove();
> >>  
> >> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> -				  &pcifront_bus_ops, sd);
> >> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> +				  &pcifront_bus_ops, sd, &resources);
> >>  	if (!b) {
> >>  		dev_err(&pdev->xdev->dev,
> >>  			"Error creating PCI Frontend Bus!\n");
> >>  		err = -ENOMEM;
> >>  		pci_unlock_rescan_remove();
> >> +		pci_free_resource_list(&resources);
> >>  		goto err_out;
> >>  	}
> >>  
> >> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  
> >>  	list_add(&bus_entry->list, &pdev->root_buses);
> >>  
> >> -	/* pci_scan_bus_parented skips devices which do not have a have
> >> +	/* pci_scan_root_bus skips devices which do not have a
> >>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>  	err = pcifront_scan_bus(pdev, domain, bus, b);
> >>  
> >> -- 
> >> 1.7.1
> >>
> >> --
> >> 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
> > 
> > .
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-12 11:46       ` Yijing Wang
                         ` (4 preceding siblings ...)
  (?)
@ 2015-03-12 19:35       ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:35 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 07:46:45PM +0800, Yijing Wang wrote:
> >>  	struct pci_bus *b;
> >> +	LIST_HEAD(resources);
> >>  	struct pcifront_sd *sd = NULL;
> >>  	struct pci_bus_entry *bus_entry = NULL;
> >>  	int err = 0;
> >> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  		err = -ENOMEM;
> >>  		goto err_out;
> >>  	}
> >> +	pci_add_resource(&resources, &ioport_resource);
> >> +	pci_add_resource(&resources, &iomem_resource);
> >> +	pci_add_resource(&resources, &busn_resource);
> > 
> > Since I don't want to export busn_resource, you might have to allocate your
> > own struct resource for it here.  And, of course, figure out the details of
> > which PCI domain you're in and whether you need to share one struct
> > resource across several host bridges in the same domain.
> 
> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> so do we still need to add additional info to figure out which domain own the bus resource ?

That's up to the caller.  Only the platform knows which bridges it wants to
have in the same domain.  In principle, every host bridge could be in its
own domain, since each bridge is the root of a unique PCI hierarchy.  But
some platforms have firmware that assumes otherwise.  I have no idea what
xen assumes.

> >>  	pcifront_init_sd(sd, domain, bus, pdev);
> >>  
> >>  	pci_lock_rescan_remove();
> >>  
> >> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> -				  &pcifront_bus_ops, sd);
> >> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> +				  &pcifront_bus_ops, sd, &resources);
> >>  	if (!b) {
> >>  		dev_err(&pdev->xdev->dev,
> >>  			"Error creating PCI Frontend Bus!\n");
> >>  		err = -ENOMEM;
> >>  		pci_unlock_rescan_remove();
> >> +		pci_free_resource_list(&resources);
> >>  		goto err_out;
> >>  	}
> >>  
> >> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  
> >>  	list_add(&bus_entry->list, &pdev->root_buses);
> >>  
> >> -	/* pci_scan_bus_parented skips devices which do not have a have
> >> +	/* pci_scan_root_bus skips devices which do not have a
> >>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>  	err = pcifront_scan_bus(pdev, domain, bus, b);
> >>  
> >> -- 
> >> 1.7.1
> >>
> >> --
> >> 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
> > 
> > .
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 19:35         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:35 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 07:46:45PM +0800, Yijing Wang wrote:
> >>  	struct pci_bus *b;
> >> +	LIST_HEAD(resources);
> >>  	struct pcifront_sd *sd = NULL;
> >>  	struct pci_bus_entry *bus_entry = NULL;
> >>  	int err = 0;
> >> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  		err = -ENOMEM;
> >>  		goto err_out;
> >>  	}
> >> +	pci_add_resource(&resources, &ioport_resource);
> >> +	pci_add_resource(&resources, &iomem_resource);
> >> +	pci_add_resource(&resources, &busn_resource);
> > 
> > Since I don't want to export busn_resource, you might have to allocate your
> > own struct resource for it here.  And, of course, figure out the details of
> > which PCI domain you're in and whether you need to share one struct
> > resource across several host bridges in the same domain.
> 
> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> so do we still need to add additional info to figure out which domain own the bus resource ?

That's up to the caller.  Only the platform knows which bridges it wants to
have in the same domain.  In principle, every host bridge could be in its
own domain, since each bridge is the root of a unique PCI hierarchy.  But
some platforms have firmware that assumes otherwise.  I have no idea what
xen assumes.

> >>  	pcifront_init_sd(sd, domain, bus, pdev);
> >>  
> >>  	pci_lock_rescan_remove();
> >>  
> >> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> -				  &pcifront_bus_ops, sd);
> >> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> +				  &pcifront_bus_ops, sd, &resources);
> >>  	if (!b) {
> >>  		dev_err(&pdev->xdev->dev,
> >>  			"Error creating PCI Frontend Bus!\n");
> >>  		err = -ENOMEM;
> >>  		pci_unlock_rescan_remove();
> >> +		pci_free_resource_list(&resources);
> >>  		goto err_out;
> >>  	}
> >>  
> >> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  
> >>  	list_add(&bus_entry->list, &pdev->root_buses);
> >>  
> >> -	/* pci_scan_bus_parented skips devices which do not have a have
> >> +	/* pci_scan_root_bus skips devices which do not have a
> >>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>  	err = pcifront_scan_bus(pdev, domain, bus, b);
> >>  
> >> -- 
> >> 1.7.1
> >>
> >> --
> >> 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
> > 
> > .
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> --
> 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

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 19:35         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 07:46:45PM +0800, Yijing Wang wrote:
> >>  	struct pci_bus *b;
> >> +	LIST_HEAD(resources);
> >>  	struct pcifront_sd *sd = NULL;
> >>  	struct pci_bus_entry *bus_entry = NULL;
> >>  	int err = 0;
> >> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  		err = -ENOMEM;
> >>  		goto err_out;
> >>  	}
> >> +	pci_add_resource(&resources, &ioport_resource);
> >> +	pci_add_resource(&resources, &iomem_resource);
> >> +	pci_add_resource(&resources, &busn_resource);
> > 
> > Since I don't want to export busn_resource, you might have to allocate your
> > own struct resource for it here.  And, of course, figure out the details of
> > which PCI domain you're in and whether you need to share one struct
> > resource across several host bridges in the same domain.
> 
> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> so do we still need to add additional info to figure out which domain own the bus resource ?

That's up to the caller.  Only the platform knows which bridges it wants to
have in the same domain.  In principle, every host bridge could be in its
own domain, since each bridge is the root of a unique PCI hierarchy.  But
some platforms have firmware that assumes otherwise.  I have no idea what
xen assumes.

> >>  	pcifront_init_sd(sd, domain, bus, pdev);
> >>  
> >>  	pci_lock_rescan_remove();
> >>  
> >> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> -				  &pcifront_bus_ops, sd);
> >> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> +				  &pcifront_bus_ops, sd, &resources);
> >>  	if (!b) {
> >>  		dev_err(&pdev->xdev->dev,
> >>  			"Error creating PCI Frontend Bus!\n");
> >>  		err = -ENOMEM;
> >>  		pci_unlock_rescan_remove();
> >> +		pci_free_resource_list(&resources);
> >>  		goto err_out;
> >>  	}
> >>  
> >> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  
> >>  	list_add(&bus_entry->list, &pdev->root_buses);
> >>  
> >> -	/* pci_scan_bus_parented skips devices which do not have a have
> >> +	/* pci_scan_root_bus skips devices which do not have a
> >>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>  	err = pcifront_scan_bus(pdev, domain, bus, b);
> >>  
> >> -- 
> >> 1.7.1
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> >> the body of a message to majordomo at vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> > .
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-12 11:46       ` Yijing Wang
                         ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 19:35       ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:35 UTC (permalink / raw)
  To: Yijing Wang
  Cc: linux-ia64, linux-pci, Guan Xuetao, Russell King, x86,
	Geert Uytterhoeven, Benjamin Herrenschmidt, xen-devel,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Thomas Gleixner, Yinghai Lu, linux-arm-kernel, Liviu Dudau,
	Tony Luck, linux-kernel, Jiang Liu, linux-alpha, David S. Miller

On Thu, Mar 12, 2015 at 07:46:45PM +0800, Yijing Wang wrote:
> >>  	struct pci_bus *b;
> >> +	LIST_HEAD(resources);
> >>  	struct pcifront_sd *sd = NULL;
> >>  	struct pci_bus_entry *bus_entry = NULL;
> >>  	int err = 0;
> >> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  		err = -ENOMEM;
> >>  		goto err_out;
> >>  	}
> >> +	pci_add_resource(&resources, &ioport_resource);
> >> +	pci_add_resource(&resources, &iomem_resource);
> >> +	pci_add_resource(&resources, &busn_resource);
> > 
> > Since I don't want to export busn_resource, you might have to allocate your
> > own struct resource for it here.  And, of course, figure out the details of
> > which PCI domain you're in and whether you need to share one struct
> > resource across several host bridges in the same domain.
> 
> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> so do we still need to add additional info to figure out which domain own the bus resource ?

That's up to the caller.  Only the platform knows which bridges it wants to
have in the same domain.  In principle, every host bridge could be in its
own domain, since each bridge is the root of a unique PCI hierarchy.  But
some platforms have firmware that assumes otherwise.  I have no idea what
xen assumes.

> >>  	pcifront_init_sd(sd, domain, bus, pdev);
> >>  
> >>  	pci_lock_rescan_remove();
> >>  
> >> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> -				  &pcifront_bus_ops, sd);
> >> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> +				  &pcifront_bus_ops, sd, &resources);
> >>  	if (!b) {
> >>  		dev_err(&pdev->xdev->dev,
> >>  			"Error creating PCI Frontend Bus!\n");
> >>  		err = -ENOMEM;
> >>  		pci_unlock_rescan_remove();
> >> +		pci_free_resource_list(&resources);
> >>  		goto err_out;
> >>  	}
> >>  
> >> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  
> >>  	list_add(&bus_entry->list, &pdev->root_buses);
> >>  
> >> -	/* pci_scan_bus_parented skips devices which do not have a have
> >> +	/* pci_scan_root_bus skips devices which do not have a
> >>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>  	err = pcifront_scan_bus(pdev, domain, bus, b);
> >>  
> >> -- 
> >> 1.7.1
> >>
> >> --
> >> 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
> > 
> > .
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-12 19:35         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:35 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 07:46:45PM +0800, Yijing Wang wrote:
> >>  	struct pci_bus *b;
> >> +	LIST_HEAD(resources);
> >>  	struct pcifront_sd *sd = NULL;
> >>  	struct pci_bus_entry *bus_entry = NULL;
> >>  	int err = 0;
> >> @@ -470,17 +472,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  		err = -ENOMEM;
> >>  		goto err_out;
> >>  	}
> >> +	pci_add_resource(&resources, &ioport_resource);
> >> +	pci_add_resource(&resources, &iomem_resource);
> >> +	pci_add_resource(&resources, &busn_resource);
> > 
> > Since I don't want to export busn_resource, you might have to allocate your
> > own struct resource for it here.  And, of course, figure out the details of
> > which PCI domain you're in and whether you need to share one struct
> > resource across several host bridges in the same domain.
> 
> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> so do we still need to add additional info to figure out which domain own the bus resource ?

That's up to the caller.  Only the platform knows which bridges it wants to
have in the same domain.  In principle, every host bridge could be in its
own domain, since each bridge is the root of a unique PCI hierarchy.  But
some platforms have firmware that assumes otherwise.  I have no idea what
xen assumes.

> >>  	pcifront_init_sd(sd, domain, bus, pdev);
> >>  
> >>  	pci_lock_rescan_remove();
> >>  
> >> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> -				  &pcifront_bus_ops, sd);
> >> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> +				  &pcifront_bus_ops, sd, &resources);
> >>  	if (!b) {
> >>  		dev_err(&pdev->xdev->dev,
> >>  			"Error creating PCI Frontend Bus!\n");
> >>  		err = -ENOMEM;
> >>  		pci_unlock_rescan_remove();
> >> +		pci_free_resource_list(&resources);
> >>  		goto err_out;
> >>  	}
> >>  
> >> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>  
> >>  	list_add(&bus_entry->list, &pdev->root_buses);
> >>  
> >> -	/* pci_scan_bus_parented skips devices which do not have a have
> >> +	/* pci_scan_root_bus skips devices which do not have a
> >>  	* devfn=0. The pcifront_scan_bus enumerates all devfn. */
> >>  	err = pcifront_scan_bus(pdev, domain, bus, b);
> >>  
> >> -- 
> >> 1.7.1
> >>
> >> --
> >> 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
> > 
> > .
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> --
> 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

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-12 12:14       ` Yijing Wang
  (?)
  (?)
@ 2015-03-12 19:49         ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:49 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 08:14:40PM +0800, Yijing Wang wrote:
> On 2015/3/12 9:29, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> >> Currently, we use int type for bus number in
> >> pci_create_root_bus(), pci_scan_root_bus() and
> >> pci_scan_bus_legacy. Because PCI bus number
> >> always <= 255, so we could change the bus number
> >> argument type to u32, and combine PCI domain and
> >> bus number in one. 
> > 
> > This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> > and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> > *why* you think it's a good idea to pass a single value that contains both
> > domain and bus numbers.  The obvious thing is to pass two separate values,
> > and you don't say why passing a single combined value is better.
> 
> Sorry for my poor description for this patch, I combined the domain and bus, because
> I think now we have too many args at pci_scan_root_bus() or other scan functions,
> 
> struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> 
> Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
> it will become 7.
> 
> I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,
> 
> E.g
> 
> struct pci_scan_info {
> 	int bus;
> 	struct device *parent;
> 	struct pci_ops *ops;
> 	void *sysdata;
> 	struct list_head *resource;
> 	int domain;
> 	struct pci_host_bridge_ops;
> }
> 
> Do you like this one or keep it like now ?
> 
> pci_scan_root_bus(struct device *parent, int domain, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)

I don't think reducing the number of arguments is a good argument for
squashing some of them together.

I don't really want to add a structure like that because it adds management
complexity for all the callers because it contains per-bridge things (bus,
parent, domain, resource, sysdata).  Things like struct pci_ops and struct
pci_host_bridge_ops are much simpler because drivers can statically
allocate a single copy and use it for multiple devices.

I think it might make sense to put the struct pci_ops pointer inside struct
pci_host_bridge_ops.  That would get rid of one of the arguments.

You might also be able to get rid of the "bus" argument, since the caller
should be passing an IORESOURCE_BUS resource in the resource list, and
"bus" should be the same as res->start.

Bjorn

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-12 12:14       ` Yijing Wang
                         ` (3 preceding siblings ...)
  (?)
@ 2015-03-12 19:49       ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:49 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 08:14:40PM +0800, Yijing Wang wrote:
> On 2015/3/12 9:29, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> >> Currently, we use int type for bus number in
> >> pci_create_root_bus(), pci_scan_root_bus() and
> >> pci_scan_bus_legacy. Because PCI bus number
> >> always <= 255, so we could change the bus number
> >> argument type to u32, and combine PCI domain and
> >> bus number in one. 
> > 
> > This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> > and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> > *why* you think it's a good idea to pass a single value that contains both
> > domain and bus numbers.  The obvious thing is to pass two separate values,
> > and you don't say why passing a single combined value is better.
> 
> Sorry for my poor description for this patch, I combined the domain and bus, because
> I think now we have too many args at pci_scan_root_bus() or other scan functions,
> 
> struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> 
> Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
> it will become 7.
> 
> I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,
> 
> E.g
> 
> struct pci_scan_info {
> 	int bus;
> 	struct device *parent;
> 	struct pci_ops *ops;
> 	void *sysdata;
> 	struct list_head *resource;
> 	int domain;
> 	struct pci_host_bridge_ops;
> }
> 
> Do you like this one or keep it like now ?
> 
> pci_scan_root_bus(struct device *parent, int domain, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)

I don't think reducing the number of arguments is a good argument for
squashing some of them together.

I don't really want to add a structure like that because it adds management
complexity for all the callers because it contains per-bridge things (bus,
parent, domain, resource, sysdata).  Things like struct pci_ops and struct
pci_host_bridge_ops are much simpler because drivers can statically
allocate a single copy and use it for multiple devices.

I think it might make sense to put the struct pci_ops pointer inside struct
pci_host_bridge_ops.  That would get rid of one of the arguments.

You might also be able to get rid of the "bus" argument, since the caller
should be passing an IORESOURCE_BUS resource in the resource list, and
"bus" should be the same as res->start.

Bjorn

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 19:49         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:49 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 08:14:40PM +0800, Yijing Wang wrote:
> On 2015/3/12 9:29, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> >> Currently, we use int type for bus number in
> >> pci_create_root_bus(), pci_scan_root_bus() and
> >> pci_scan_bus_legacy. Because PCI bus number
> >> always <= 255, so we could change the bus number
> >> argument type to u32, and combine PCI domain and
> >> bus number in one. 
> > 
> > This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> > and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> > *why* you think it's a good idea to pass a single value that contains both
> > domain and bus numbers.  The obvious thing is to pass two separate values,
> > and you don't say why passing a single combined value is better.
> 
> Sorry for my poor description for this patch, I combined the domain and bus, because
> I think now we have too many args at pci_scan_root_bus() or other scan functions,
> 
> struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> 
> Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
> it will become 7.
> 
> I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,
> 
> E.g
> 
> struct pci_scan_info {
> 	int bus;
> 	struct device *parent;
> 	struct pci_ops *ops;
> 	void *sysdata;
> 	struct list_head *resource;
> 	int domain;
> 	struct pci_host_bridge_ops;
> }
> 
> Do you like this one or keep it like now ?
> 
> pci_scan_root_bus(struct device *parent, int domain, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)

I don't think reducing the number of arguments is a good argument for
squashing some of them together.

I don't really want to add a structure like that because it adds management
complexity for all the callers because it contains per-bridge things (bus,
parent, domain, resource, sysdata).  Things like struct pci_ops and struct
pci_host_bridge_ops are much simpler because drivers can statically
allocate a single copy and use it for multiple devices.

I think it might make sense to put the struct pci_ops pointer inside struct
pci_host_bridge_ops.  That would get rid of one of the arguments.

You might also be able to get rid of the "bus" argument, since the caller
should be passing an IORESOURCE_BUS resource in the resource list, and
"bus" should be the same as res->start.

Bjorn

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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 19:49         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 08:14:40PM +0800, Yijing Wang wrote:
> On 2015/3/12 9:29, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> >> Currently, we use int type for bus number in
> >> pci_create_root_bus(), pci_scan_root_bus() and
> >> pci_scan_bus_legacy. Because PCI bus number
> >> always <= 255, so we could change the bus number
> >> argument type to u32, and combine PCI domain and
> >> bus number in one. 
> > 
> > This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> > and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> > *why* you think it's a good idea to pass a single value that contains both
> > domain and bus numbers.  The obvious thing is to pass two separate values,
> > and you don't say why passing a single combined value is better.
> 
> Sorry for my poor description for this patch, I combined the domain and bus, because
> I think now we have too many args at pci_scan_root_bus() or other scan functions,
> 
> struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> 
> Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
> it will become 7.
> 
> I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,
> 
> E.g
> 
> struct pci_scan_info {
> 	int bus;
> 	struct device *parent;
> 	struct pci_ops *ops;
> 	void *sysdata;
> 	struct list_head *resource;
> 	int domain;
> 	struct pci_host_bridge_ops;
> }
> 
> Do you like this one or keep it like now ?
> 
> pci_scan_root_bus(struct device *parent, int domain, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)

I don't think reducing the number of arguments is a good argument for
squashing some of them together.

I don't really want to add a structure like that because it adds management
complexity for all the callers because it contains per-bridge things (bus,
parent, domain, resource, sysdata).  Things like struct pci_ops and struct
pci_host_bridge_ops are much simpler because drivers can statically
allocate a single copy and use it for multiple devices.

I think it might make sense to put the struct pci_ops pointer inside struct
pci_host_bridge_ops.  That would get rid of one of the arguments.

You might also be able to get rid of the "bus" argument, since the caller
should be passing an IORESOURCE_BUS resource in the resource list, and
"bus" should be the same as res->start.

Bjorn

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-12 19:49         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:49 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 08:14:40PM +0800, Yijing Wang wrote:
> On 2015/3/12 9:29, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:03AM +0800, Yijing Wang wrote:
> >> Currently, we use int type for bus number in
> >> pci_create_root_bus(), pci_scan_root_bus() and
> >> pci_scan_bus_legacy. Because PCI bus number
> >> always <= 255, so we could change the bus number
> >> argument type to u32, and combine PCI domain and
> >> bus number in one. 
> > 
> > This makes no sense.  Or rather, it only states the obvious: an 8-bit value
> > and a 16-bit value will both fit in a 32-bit value.  But it doesn't say
> > *why* you think it's a good idea to pass a single value that contains both
> > domain and bus numbers.  The obvious thing is to pass two separate values,
> > and you don't say why passing a single combined value is better.
> 
> Sorry for my poor description for this patch, I combined the domain and bus, because
> I think now we have too many args at pci_scan_root_bus() or other scan functions,
> 
> struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources)
> 
> Now we have five args yet, plus the new introduced domain and pci_host_bridge_ops,
> it will become 7.
> 
> I thought introduced a new structure which contain the necessary info to scan root bus/ host bridge,
> 
> E.g
> 
> struct pci_scan_info {
> 	int bus;
> 	struct device *parent;
> 	struct pci_ops *ops;
> 	void *sysdata;
> 	struct list_head *resource;
> 	int domain;
> 	struct pci_host_bridge_ops;
> }
> 
> Do you like this one or keep it like now ?
> 
> pci_scan_root_bus(struct device *parent, int domain, int bus,
> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)

I don't think reducing the number of arguments is a good argument for
squashing some of them together.

I don't really want to add a structure like that because it adds management
complexity for all the callers because it contains per-bridge things (bus,
parent, domain, resource, sysdata).  Things like struct pci_ops and struct
pci_host_bridge_ops are much simpler because drivers can statically
allocate a single copy and use it for multiple devices.

I think it might make sense to put the struct pci_ops pointer inside struct
pci_host_bridge_ops.  That would get rid of one of the arguments.

You might also be able to get rid of the "bus" argument, since the caller
should be passing an IORESOURCE_BUS resource in the resource list, and
"bus" should be the same as res->start.

Bjorn

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-12 13:03       ` Yijing Wang
  (?)
  (?)
@ 2015-03-12 19:56         ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:56 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 09:03:12PM +0800, Yijing Wang wrote:
> On 2015/3/12 10:55, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> >> Introduce pci_host_bridge_list to manage pci host
> >> bridges in system, so we could detect whether
> >> the host in domain:bus is alreay registered.
> >> Then we could remove bus alreay exist test in
> >> __pci_create_root_bus().
> > 
> > It's a nice idea to move this test into the core.  While you're at it, why
> > don't you check for any overlap with the bus ranges of existing host
> > bridges?  For example, if we're trying to create a new host bridge to
> > [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> > as well as to [bus 40-ff].  I think your current patch will detect the
> > latter conflict but not the former.
> 
> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
> some pci scan would fail which currently scan success.

_BBN is not the correct source for the bridge's bus number range.  There's
a comment in acpi_pci_root_add() that explains why:

  * We need both the start and end of the downstream bus range
  * to interpret _CBA (MMCONFIG base address), so it really is
  * supposed to be in _CRS.  If we don't find it there, all we
  * can do is assume [_BBN-0xFF] or [0-0xFF].

A platform SHOULD know the start and and end bus number.  If it doesn't I
think it's the platform's responsibility to carve up the bus number range.
Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
we discover another bridge that leads to bus 80.

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-12 13:03       ` Yijing Wang
                         ` (4 preceding siblings ...)
  (?)
@ 2015-03-12 19:56       ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:56 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 09:03:12PM +0800, Yijing Wang wrote:
> On 2015/3/12 10:55, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> >> Introduce pci_host_bridge_list to manage pci host
> >> bridges in system, so we could detect whether
> >> the host in domain:bus is alreay registered.
> >> Then we could remove bus alreay exist test in
> >> __pci_create_root_bus().
> > 
> > It's a nice idea to move this test into the core.  While you're at it, why
> > don't you check for any overlap with the bus ranges of existing host
> > bridges?  For example, if we're trying to create a new host bridge to
> > [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> > as well as to [bus 40-ff].  I think your current patch will detect the
> > latter conflict but not the former.
> 
> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
> some pci scan would fail which currently scan success.

_BBN is not the correct source for the bridge's bus number range.  There's
a comment in acpi_pci_root_add() that explains why:

  * We need both the start and end of the downstream bus range
  * to interpret _CBA (MMCONFIG base address), so it really is
  * supposed to be in _CRS.  If we don't find it there, all we
  * can do is assume [_BBN-0xFF] or [0-0xFF].

A platform SHOULD know the start and and end bus number.  If it doesn't I
think it's the platform's responsibility to carve up the bus number range.
Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
we discover another bridge that leads to bus 80.

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 19:56         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:56 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 09:03:12PM +0800, Yijing Wang wrote:
> On 2015/3/12 10:55, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> >> Introduce pci_host_bridge_list to manage pci host
> >> bridges in system, so we could detect whether
> >> the host in domain:bus is alreay registered.
> >> Then we could remove bus alreay exist test in
> >> __pci_create_root_bus().
> > 
> > It's a nice idea to move this test into the core.  While you're at it, why
> > don't you check for any overlap with the bus ranges of existing host
> > bridges?  For example, if we're trying to create a new host bridge to
> > [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> > as well as to [bus 40-ff].  I think your current patch will detect the
> > latter conflict but not the former.
> 
> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
> some pci scan would fail which currently scan success.

_BBN is not the correct source for the bridge's bus number range.  There's
a comment in acpi_pci_root_add() that explains why:

  * We need both the start and end of the downstream bus range
  * to interpret _CBA (MMCONFIG base address), so it really is
  * supposed to be in _CRS.  If we don't find it there, all we
  * can do is assume [_BBN-0xFF] or [0-0xFF].

A platform SHOULD know the start and and end bus number.  If it doesn't I
think it's the platform's responsibility to carve up the bus number range.
Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
we discover another bridge that leads to bus 80.

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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 19:56         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 09:03:12PM +0800, Yijing Wang wrote:
> On 2015/3/12 10:55, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> >> Introduce pci_host_bridge_list to manage pci host
> >> bridges in system, so we could detect whether
> >> the host in domain:bus is alreay registered.
> >> Then we could remove bus alreay exist test in
> >> __pci_create_root_bus().
> > 
> > It's a nice idea to move this test into the core.  While you're at it, why
> > don't you check for any overlap with the bus ranges of existing host
> > bridges?  For example, if we're trying to create a new host bridge to
> > [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> > as well as to [bus 40-ff].  I think your current patch will detect the
> > latter conflict but not the former.
> 
> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
> some pci scan would fail which currently scan success.

_BBN is not the correct source for the bridge's bus number range.  There's
a comment in acpi_pci_root_add() that explains why:

  * We need both the start and end of the downstream bus range
  * to interpret _CBA (MMCONFIG base address), so it really is
  * supposed to be in _CRS.  If we don't find it there, all we
  * can do is assume [_BBN-0xFF] or [0-0xFF].

A platform SHOULD know the start and and end bus number.  If it doesn't I
think it's the platform's responsibility to carve up the bus number range.
Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
we discover another bridge that leads to bus 80.

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-12 19:56         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 19:56 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 09:03:12PM +0800, Yijing Wang wrote:
> On 2015/3/12 10:55, Bjorn Helgaas wrote:
> > On Mon, Mar 09, 2015 at 10:34:07AM +0800, Yijing Wang wrote:
> >> Introduce pci_host_bridge_list to manage pci host
> >> bridges in system, so we could detect whether
> >> the host in domain:bus is alreay registered.
> >> Then we could remove bus alreay exist test in
> >> __pci_create_root_bus().
> > 
> > It's a nice idea to move this test into the core.  While you're at it, why
> > don't you check for any overlap with the bus ranges of existing host
> > bridges?  For example, if we're trying to create a new host bridge to
> > [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
> > as well as to [bus 40-ff].  I think your current patch will detect the
> > latter conflict but not the former.
> 
> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
> some pci scan would fail which currently scan success.

_BBN is not the correct source for the bridge's bus number range.  There's
a comment in acpi_pci_root_add() that explains why:

  * We need both the start and end of the downstream bus range
  * to interpret _CBA (MMCONFIG base address), so it really is
  * supposed to be in _CRS.  If we don't find it there, all we
  * can do is assume [_BBN-0xFF] or [0-0xFF].

A platform SHOULD know the start and and end bus number.  If it doesn't I
think it's the platform's responsibility to carve up the bus number range.
Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
we discover another bridge that leads to bus 80.

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-12 13:28       ` Yijing Wang
  (?)
  (?)
@ 2015-03-12 20:00         ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 20:00 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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.

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
  2015-03-12 13:28       ` Yijing Wang
                         ` (4 preceding siblings ...)
  (?)
@ 2015-03-12 20:00       ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 20:00 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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.

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 20:00         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 20:00 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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.

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

* [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 20:00         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 20:00 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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

* Re: [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr()
@ 2015-03-12 20:00         ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 20:00 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, Fengguang Wu

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.

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-09  2:33 ` Yijing Wang
  (?)
  (?)
@ 2015-03-12 21:23   ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 21:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> ...
> Yijing Wang (29):
>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>   sparc/PCI: Claim bus resources before pci_bus_add_devices()

I put the above patches plus a cleanup patch on my pci/enumeration branch.
Please rebase your next revision to that.  If there's anything else
non-controversial that we can pull in to chip away at this, let me know.

>   PCI: Export busn_resource to drivers/pci
>   PCI: Remove deprecated pci_scan_bus_parented()
>   PCI: Combine PCI domain and bus number in u32 arg
>   PCI: Pass PCI domain number combined with root bus number
>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>   PCI: Introduce pci_host_bridge_list to manage host bridges
>   PCI: Save sysdata in pci_host_bridge drvdata
>   PCI: Introduce pci_host_bridge_ops to support host specific
>     operations
>   PCI: Introduce new scan function pci_scan_host_bridge()
>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>   PCI: Remove weak pcibios_root_bridge_prepare()
>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>   PCI: Introduce pci_bus_child_max_busnr()
>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>   PCI/designware: Use pci_scan_root_bus() for simplicity
>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>   PCI: Export find_pci_host_bridge() and rename to
>     pci_find_host_bridge()
>   PCI: Remove platform specific pci_domain_nr()
>   PCI: Remove pci_bus_assign_domain_nr()

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-09  2:33 ` Yijing Wang
                   ` (59 preceding siblings ...)
  (?)
@ 2015-03-12 21:23 ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 21:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> ...
> Yijing Wang (29):
>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>   sparc/PCI: Claim bus resources before pci_bus_add_devices()

I put the above patches plus a cleanup patch on my pci/enumeration branch.
Please rebase your next revision to that.  If there's anything else
non-controversial that we can pull in to chip away at this, let me know.

>   PCI: Export busn_resource to drivers/pci
>   PCI: Remove deprecated pci_scan_bus_parented()
>   PCI: Combine PCI domain and bus number in u32 arg
>   PCI: Pass PCI domain number combined with root bus number
>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>   PCI: Introduce pci_host_bridge_list to manage host bridges
>   PCI: Save sysdata in pci_host_bridge drvdata
>   PCI: Introduce pci_host_bridge_ops to support host specific
>     operations
>   PCI: Introduce new scan function pci_scan_host_bridge()
>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>   PCI: Remove weak pcibios_root_bridge_prepare()
>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>   PCI: Introduce pci_bus_child_max_busnr()
>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>   PCI/designware: Use pci_scan_root_bus() for simplicity
>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>   PCI: Export find_pci_host_bridge() and rename to
>     pci_find_host_bridge()
>   PCI: Remove platform specific pci_domain_nr()
>   PCI: Remove pci_bus_assign_domain_nr()

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-12 21:23   ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 21:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> ...
> Yijing Wang (29):
>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>   sparc/PCI: Claim bus resources before pci_bus_add_devices()

I put the above patches plus a cleanup patch on my pci/enumeration branch.
Please rebase your next revision to that.  If there's anything else
non-controversial that we can pull in to chip away at this, let me know.

>   PCI: Export busn_resource to drivers/pci
>   PCI: Remove deprecated pci_scan_bus_parented()
>   PCI: Combine PCI domain and bus number in u32 arg
>   PCI: Pass PCI domain number combined with root bus number
>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>   PCI: Introduce pci_host_bridge_list to manage host bridges
>   PCI: Save sysdata in pci_host_bridge drvdata
>   PCI: Introduce pci_host_bridge_ops to support host specific
>     operations
>   PCI: Introduce new scan function pci_scan_host_bridge()
>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>   PCI: Remove weak pcibios_root_bridge_prepare()
>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>   PCI: Introduce pci_bus_child_max_busnr()
>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>   PCI/designware: Use pci_scan_root_bus() for simplicity
>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>   PCI: Export find_pci_host_bridge() and rename to
>     pci_find_host_bridge()
>   PCI: Remove platform specific pci_domain_nr()
>   PCI: Remove pci_bus_assign_domain_nr()

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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-12 21:23   ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> ...
> Yijing Wang (29):
>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>   sparc/PCI: Claim bus resources before pci_bus_add_devices()

I put the above patches plus a cleanup patch on my pci/enumeration branch.
Please rebase your next revision to that.  If there's anything else
non-controversial that we can pull in to chip away at this, let me know.

>   PCI: Export busn_resource to drivers/pci
>   PCI: Remove deprecated pci_scan_bus_parented()
>   PCI: Combine PCI domain and bus number in u32 arg
>   PCI: Pass PCI domain number combined with root bus number
>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>   PCI: Introduce pci_host_bridge_list to manage host bridges
>   PCI: Save sysdata in pci_host_bridge drvdata
>   PCI: Introduce pci_host_bridge_ops to support host specific
>     operations
>   PCI: Introduce new scan function pci_scan_host_bridge()
>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>   PCI: Remove weak pcibios_root_bridge_prepare()
>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>   PCI: Introduce pci_bus_child_max_busnr()
>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>   PCI/designware: Use pci_scan_root_bus() for simplicity
>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>   PCI: Export find_pci_host_bridge() and rename to
>     pci_find_host_bridge()
>   PCI: Remove platform specific pci_domain_nr()
>   PCI: Remove pci_bus_assign_domain_nr()

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-12 21:23   ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-12 21:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> ...
> Yijing Wang (29):
>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>   sparc/PCI: Claim bus resources before pci_bus_add_devices()

I put the above patches plus a cleanup patch on my pci/enumeration branch.
Please rebase your next revision to that.  If there's anything else
non-controversial that we can pull in to chip away at this, let me know.

>   PCI: Export busn_resource to drivers/pci
>   PCI: Remove deprecated pci_scan_bus_parented()
>   PCI: Combine PCI domain and bus number in u32 arg
>   PCI: Pass PCI domain number combined with root bus number
>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>   PCI: Introduce pci_host_bridge_list to manage host bridges
>   PCI: Save sysdata in pci_host_bridge drvdata
>   PCI: Introduce pci_host_bridge_ops to support host specific
>     operations
>   PCI: Introduce new scan function pci_scan_host_bridge()
>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>   PCI: Remove weak pcibios_root_bridge_prepare()
>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>   PCI: Introduce pci_bus_child_max_busnr()
>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>   PCI/designware: Use pci_scan_root_bus() for simplicity
>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>   PCI: Export find_pci_host_bridge() and rename to
>     pci_find_host_bridge()
>   PCI: Remove platform specific pci_domain_nr()
>   PCI: Remove pci_bus_assign_domain_nr()

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-12 19:32         ` Bjorn Helgaas
                             ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  1:57           ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  1:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Hi Bjorn, busn_resource may would not be shared by multi domains,
>>
>> We insert bus number resource like:
>>
>> pci_add_resource(&resources, &busn_resource);	
>> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
>> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
>> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
>>
>> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.
> 
> The intent of pci_add_resource() and passing the resulting resource list
> into pci_scan_root_bus(), etc., is that the host bridge may consume any
> resources described by the list.  If we pass the same resource to multiple
> calls, that means the resource must be shared between the multiple host
> bridges involved.  For bus numbers, that makes some sense if the platform
> considers the bridges to be in the same domain, but not if they are in
> different domains.
> 
> If we export busn_resource, we have no control over what domains it becomes
> associated with because the domain is passed into pci_scan_root_bus() by
> the caller.

Agree, I will drop this patch, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
  2015-03-12 19:32         ` Bjorn Helgaas
                           ` (3 preceding siblings ...)
  (?)
@ 2015-03-13  1:57         ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  1:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Hi Bjorn, busn_resource may would not be shared by multi domains,
>>
>> We insert bus number resource like:
>>
>> pci_add_resource(&resources, &busn_resource);	
>> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
>> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
>> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
>>
>> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.
> 
> The intent of pci_add_resource() and passing the resulting resource list
> into pci_scan_root_bus(), etc., is that the host bridge may consume any
> resources described by the list.  If we pass the same resource to multiple
> calls, that means the resource must be shared between the multiple host
> bridges involved.  For bus numbers, that makes some sense if the platform
> considers the bridges to be in the same domain, but not if they are in
> different domains.
> 
> If we export busn_resource, we have no control over what domains it becomes
> associated with because the domain is passed into pci_scan_root_bus() by
> the caller.

Agree, I will drop this patch, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-13  1:57           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  1:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Hi Bjorn, busn_resource may would not be shared by multi domains,
>>
>> We insert bus number resource like:
>>
>> pci_add_resource(&resources, &busn_resource);	
>> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
>> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
>> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
>>
>> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.
> 
> The intent of pci_add_resource() and passing the resulting resource list
> into pci_scan_root_bus(), etc., is that the host bridge may consume any
> resources described by the list.  If we pass the same resource to multiple
> calls, that means the resource must be shared between the multiple host
> bridges involved.  For bus numbers, that makes some sense if the platform
> considers the bridges to be in the same domain, but not if they are in
> different domains.
> 
> If we export busn_resource, we have no control over what domains it becomes
> associated with because the domain is passed into pci_scan_root_bus() by
> the caller.

Agree, I will drop this patch, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-13  1:57           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  1:57 UTC (permalink / raw)
  To: linux-arm-kernel

>> Hi Bjorn, busn_resource may would not be shared by multi domains,
>>
>> We insert bus number resource like:
>>
>> pci_add_resource(&resources, &busn_resource);	
>> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
>> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
>> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
>>
>> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.
> 
> The intent of pci_add_resource() and passing the resulting resource list
> into pci_scan_root_bus(), etc., is that the host bridge may consume any
> resources described by the list.  If we pass the same resource to multiple
> calls, that means the resource must be shared between the multiple host
> bridges involved.  For bus numbers, that makes some sense if the platform
> considers the bridges to be in the same domain, but not if they are in
> different domains.
> 
> If we export busn_resource, we have no control over what domains it becomes
> associated with because the domain is passed into pci_scan_root_bus() by
> the caller.

Agree, I will drop this patch, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-13  1:57           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  1:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Hi Bjorn, busn_resource may would not be shared by multi domains,
>>
>> We insert bus number resource like:
>>
>> pci_add_resource(&resources, &busn_resource);	
>> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here = 255
>> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
>> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
>>
>> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.
> 
> The intent of pci_add_resource() and passing the resulting resource list
> into pci_scan_root_bus(), etc., is that the host bridge may consume any
> resources described by the list.  If we pass the same resource to multiple
> calls, that means the resource must be shared between the multiple host
> bridges involved.  For bus numbers, that makes some sense if the platform
> considers the bridges to be in the same domain, but not if they are in
> different domains.
> 
> If we export busn_resource, we have no control over what domains it becomes
> associated with because the domain is passed into pci_scan_root_bus() by
> the caller.

Agree, I will drop this patch, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci
@ 2015-03-13  1:57           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  1:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Hi Bjorn, busn_resource may would not be shared by multi domains,
>>
>> We insert bus number resource like:
>>
>> pci_add_resource(&resources, &busn_resource);	
>> 	pci_bus_insert_busn_res(root_bus, start, bus_max);	//start is the root bus number provided by arch pci host driver, bus max here == 255
>> 		get_pci_domain_busn_res(domain)	//for root bus	//try to get a domain specific pci_domain_busn_res, if not exist, create it.
>> 			request_resource_conflict(domain_specific_busn_res, res)   //request busn res(start, bus_max) from the pci_domain_busn_res.
>>
>> So every domain has its own pci_domain_busn_res , different domain would not share the same bus number resource.
> 
> The intent of pci_add_resource() and passing the resulting resource list
> into pci_scan_root_bus(), etc., is that the host bridge may consume any
> resources described by the list.  If we pass the same resource to multiple
> calls, that means the resource must be shared between the multiple host
> bridges involved.  For bus numbers, that makes some sense if the platform
> considers the bridges to be in the same domain, but not if they are in
> different domains.
> 
> If we export busn_resource, we have no control over what domains it becomes
> associated with because the domain is passed into pci_scan_root_bus() by
> the caller.

Agree, I will drop this patch, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-12 19:35         ` Bjorn Helgaas
                             ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  2:36           ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  2:36 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>>> +	pci_add_resource(&resources, &ioport_resource);
>>>> +	pci_add_resource(&resources, &iomem_resource);
>>>> +	pci_add_resource(&resources, &busn_resource);
>>>
>>> Since I don't want to export busn_resource, you might have to allocate your
>>> own struct resource for it here.  And, of course, figure out the details of
>>> which PCI domain you're in and whether you need to share one struct
>>> resource across several host bridges in the same domain.
>>
>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> so do we still need to add additional info to figure out which domain own the bus resource ?
> 
> That's up to the caller.  Only the platform knows which bridges it wants to
> have in the same domain.  In principle, every host bridge could be in its
> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> some platforms have firmware that assumes otherwise.  I have no idea what
> xen assumes.

I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
before, and in which busn_resource is always shared for different host bridges(same domain or not),
I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.

Something like:

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..a69e529 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };

 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);

        pci_lock_rescan_remove();

-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {

Bjorn, what do you think about ?

Thanks!
Yijing.


> 
>>>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>>>  
>>>>  	pci_lock_rescan_remove();
>>>>  
>>>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>> -				  &pcifront_bus_ops, sd);
>>>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>> +				  &pcifront_bus_ops, sd, &resources);
>>>>  	if (!b) {
>>>>  		dev_err(&pdev->xdev->dev,
>>>>  			"Error creating PCI Frontend Bus!\n");
>>>>  		err = -ENOMEM;
>>>>  		pci_unlock_rescan_remove();
>>>> +		pci_free_resource_list(&resources);
>>>>  		goto err_out;
>>>>  	}
>>>>  
>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>  
>>>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>>>  
>>>> -	/* pci_scan_bus_parented skips devices which do not have a have
>>>> +	/* pci_scan_root_bus skips devices which do not have a
>>>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>  
>>>> -- 
>>>> 1.7.1
>>>>
>>>> --
>>>> 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
>>>
>>> .
>>>
>>
>>
>> -- 
>> Thanks!
>> Yijing
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13  2:36           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  2:36 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>>> +	pci_add_resource(&resources, &ioport_resource);
>>>> +	pci_add_resource(&resources, &iomem_resource);
>>>> +	pci_add_resource(&resources, &busn_resource);
>>>
>>> Since I don't want to export busn_resource, you might have to allocate your
>>> own struct resource for it here.  And, of course, figure out the details of
>>> which PCI domain you're in and whether you need to share one struct
>>> resource across several host bridges in the same domain.
>>
>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> so do we still need to add additional info to figure out which domain own the bus resource ?
> 
> That's up to the caller.  Only the platform knows which bridges it wants to
> have in the same domain.  In principle, every host bridge could be in its
> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> some platforms have firmware that assumes otherwise.  I have no idea what
> xen assumes.

I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
before, and in which busn_resource is always shared for different host bridges(same domain or not),
I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.

Something like:

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..a69e529 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };

 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);

        pci_lock_rescan_remove();

-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {

Bjorn, what do you think about ?

Thanks!
Yijing.


> 
>>>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>>>  
>>>>  	pci_lock_rescan_remove();
>>>>  
>>>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>> -				  &pcifront_bus_ops, sd);
>>>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>> +				  &pcifront_bus_ops, sd, &resources);
>>>>  	if (!b) {
>>>>  		dev_err(&pdev->xdev->dev,
>>>>  			"Error creating PCI Frontend Bus!\n");
>>>>  		err = -ENOMEM;
>>>>  		pci_unlock_rescan_remove();
>>>> +		pci_free_resource_list(&resources);
>>>>  		goto err_out;
>>>>  	}
>>>>  
>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>  
>>>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>>>  
>>>> -	/* pci_scan_bus_parented skips devices which do not have a have
>>>> +	/* pci_scan_root_bus skips devices which do not have a
>>>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>  
>>>> -- 
>>>> 1.7.1
>>>>
>>>> --
>>>> 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
>>>
>>> .
>>>
>>
>>
>> -- 
>> Thanks!
>> Yijing
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13  2:36           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  2:36 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>>> +	pci_add_resource(&resources, &ioport_resource);
>>>> +	pci_add_resource(&resources, &iomem_resource);
>>>> +	pci_add_resource(&resources, &busn_resource);
>>>
>>> Since I don't want to export busn_resource, you might have to allocate your
>>> own struct resource for it here.  And, of course, figure out the details of
>>> which PCI domain you're in and whether you need to share one struct
>>> resource across several host bridges in the same domain.
>>
>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> so do we still need to add additional info to figure out which domain own the bus resource ?
> 
> That's up to the caller.  Only the platform knows which bridges it wants to
> have in the same domain.  In principle, every host bridge could be in its
> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> some platforms have firmware that assumes otherwise.  I have no idea what
> xen assumes.

I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
before, and in which busn_resource is always shared for different host bridges(same domain or not),
I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.

Something like:

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..a69e529 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };

 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);

        pci_lock_rescan_remove();

-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {

Bjorn, what do you think about ?

Thanks!
Yijing.


> 
>>>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>>>  
>>>>  	pci_lock_rescan_remove();
>>>>  
>>>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>> -				  &pcifront_bus_ops, sd);
>>>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>> +				  &pcifront_bus_ops, sd, &resources);
>>>>  	if (!b) {
>>>>  		dev_err(&pdev->xdev->dev,
>>>>  			"Error creating PCI Frontend Bus!\n");
>>>>  		err = -ENOMEM;
>>>>  		pci_unlock_rescan_remove();
>>>> +		pci_free_resource_list(&resources);
>>>>  		goto err_out;
>>>>  	}
>>>>  
>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>  
>>>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>>>  
>>>> -	/* pci_scan_bus_parented skips devices which do not have a have
>>>> +	/* pci_scan_root_bus skips devices which do not have a
>>>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>  
>>>> -- 
>>>> 1.7.1
>>>>
>>>> --
>>>> 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
>>>
>>> .
>>>
>>
>>
>> -- 
>> Thanks!
>> Yijing
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13  2:36           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  2:36 UTC (permalink / raw)
  To: linux-arm-kernel

>>>> +	pci_add_resource(&resources, &ioport_resource);
>>>> +	pci_add_resource(&resources, &iomem_resource);
>>>> +	pci_add_resource(&resources, &busn_resource);
>>>
>>> Since I don't want to export busn_resource, you might have to allocate your
>>> own struct resource for it here.  And, of course, figure out the details of
>>> which PCI domain you're in and whether you need to share one struct
>>> resource across several host bridges in the same domain.
>>
>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> so do we still need to add additional info to figure out which domain own the bus resource ?
> 
> That's up to the caller.  Only the platform knows which bridges it wants to
> have in the same domain.  In principle, every host bridge could be in its
> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> some platforms have firmware that assumes otherwise.  I have no idea what
> xen assumes.

I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
before, and in which busn_resource is always shared for different host bridges(same domain or not),
I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.

Something like:

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..a69e529 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };

 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);

        pci_lock_rescan_remove();

-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {

Bjorn, what do you think about ?

Thanks!
Yijing.


> 
>>>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>>>  
>>>>  	pci_lock_rescan_remove();
>>>>  
>>>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>> -				  &pcifront_bus_ops, sd);
>>>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>> +				  &pcifront_bus_ops, sd, &resources);
>>>>  	if (!b) {
>>>>  		dev_err(&pdev->xdev->dev,
>>>>  			"Error creating PCI Frontend Bus!\n");
>>>>  		err = -ENOMEM;
>>>>  		pci_unlock_rescan_remove();
>>>> +		pci_free_resource_list(&resources);
>>>>  		goto err_out;
>>>>  	}
>>>>  
>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>  
>>>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>>>  
>>>> -	/* pci_scan_bus_parented skips devices which do not have a have
>>>> +	/* pci_scan_root_bus skips devices which do not have a
>>>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>  
>>>> -- 
>>>> 1.7.1
>>>>
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>>>> the body of a message to majordomo at vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>> .
>>>
>>
>>
>> -- 
>> Thanks!
>> Yijing
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-12 19:35         ` Bjorn Helgaas
                           ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  2:36         ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  2:36 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-ia64, linux-pci, Guan Xuetao, Russell King, x86,
	Geert Uytterhoeven, Benjamin Herrenschmidt, xen-devel,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Thomas Gleixner, Yinghai Lu, linux-arm-kernel, Liviu Dudau,
	Tony Luck, linux-kernel, Jiang Liu, linux-alpha, David S. Miller

>>>> +	pci_add_resource(&resources, &ioport_resource);
>>>> +	pci_add_resource(&resources, &iomem_resource);
>>>> +	pci_add_resource(&resources, &busn_resource);
>>>
>>> Since I don't want to export busn_resource, you might have to allocate your
>>> own struct resource for it here.  And, of course, figure out the details of
>>> which PCI domain you're in and whether you need to share one struct
>>> resource across several host bridges in the same domain.
>>
>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> so do we still need to add additional info to figure out which domain own the bus resource ?
> 
> That's up to the caller.  Only the platform knows which bridges it wants to
> have in the same domain.  In principle, every host bridge could be in its
> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> some platforms have firmware that assumes otherwise.  I have no idea what
> xen assumes.

I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
before, and in which busn_resource is always shared for different host bridges(same domain or not),
I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.

Something like:

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..a69e529 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };

 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);

        pci_lock_rescan_remove();

-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {

Bjorn, what do you think about ?

Thanks!
Yijing.


> 
>>>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>>>  
>>>>  	pci_lock_rescan_remove();
>>>>  
>>>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>> -				  &pcifront_bus_ops, sd);
>>>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>> +				  &pcifront_bus_ops, sd, &resources);
>>>>  	if (!b) {
>>>>  		dev_err(&pdev->xdev->dev,
>>>>  			"Error creating PCI Frontend Bus!\n");
>>>>  		err = -ENOMEM;
>>>>  		pci_unlock_rescan_remove();
>>>> +		pci_free_resource_list(&resources);
>>>>  		goto err_out;
>>>>  	}
>>>>  
>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>  
>>>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>>>  
>>>> -	/* pci_scan_bus_parented skips devices which do not have a have
>>>> +	/* pci_scan_root_bus skips devices which do not have a
>>>>  	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>  
>>>> -- 
>>>> 1.7.1
>>>>
>>>> --
>>>> 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
>>>
>>> .
>>>
>>
>>
>> -- 
>> Thanks!
>> Yijing
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13  2:36           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  2:36 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

>>>> +	pci_add_resource(&resources, &ioport_resource);
>>>> +	pci_add_resource(&resources, &iomem_resource);
>>>> +	pci_add_resource(&resources, &busn_resource);
>>>
>>> Since I don't want to export busn_resource, you might have to allocate your
>>> own struct resource for it here.  And, of course, figure out the details of
>>> which PCI domain you're in and whether you need to share one struct
>>> resource across several host bridges in the same domain.
>>
>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> so do we still need to add additional info to figure out which domain own the bus resource ?
> 
> That's up to the caller.  Only the platform knows which bridges it wants to
> have in the same domain.  In principle, every host bridge could be in its
> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> some platforms have firmware that assumes otherwise.  I have no idea what
> xen assumes.

I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
before, and in which busn_resource is always shared for different host bridges(same domain or not),
I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.

Something like:

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index b1ffebe..a69e529 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };

 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);

        pci_lock_rescan_remove();

-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {

Bjorn, what do you think about ?

Thanks!
Yijing.


> 
>>>>  	pcifront_init_sd(sd, domain, bus, pdev);
>>>>  
>>>>  	pci_lock_rescan_remove();
>>>>  
>>>> -	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>> -				  &pcifront_bus_ops, sd);
>>>> +	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>> +				  &pcifront_bus_ops, sd, &resources);
>>>>  	if (!b) {
>>>>  		dev_err(&pdev->xdev->dev,
>>>>  			"Error creating PCI Frontend Bus!\n");
>>>>  		err = -ENOMEM;
>>>>  		pci_unlock_rescan_remove();
>>>> +		pci_free_resource_list(&resources);
>>>>  		goto err_out;
>>>>  	}
>>>>  
>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>  
>>>>  	list_add(&bus_entry->list, &pdev->root_buses);
>>>>  
>>>> -	/* pci_scan_bus_parented skips devices which do not have a have
>>>> +	/* pci_scan_root_bus skips devices which do not have a
>>>>  	* devfn=0. The pcifront_scan_bus enumerates all devfn. */
>>>>  	err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>  
>>>> -- 
>>>> 1.7.1
>>>>
>>>> --
>>>> 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
>>>
>>> .
>>>
>>
>>
>> -- 
>> Thanks!
>> Yijing
>>
>> --
>> 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
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-12 19:49         ` Bjorn Helgaas
                             ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  3:19           ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:19 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> struct pci_scan_info {
>> 	int bus;
>> 	struct device *parent;
>> 	struct pci_ops *ops;
>> 	void *sysdata;
>> 	struct list_head *resource;
>> 	int domain;
>> 	struct pci_host_bridge_ops;
>> }
>>
>> Do you like this one or keep it like now ?
>>
>> pci_scan_root_bus(struct device *parent, int domain, int bus,
>> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)
> 
> I don't think reducing the number of arguments is a good argument for
> squashing some of them together.
> 
> I don't really want to add a structure like that because it adds management
> complexity for all the callers because it contains per-bridge things (bus,
> parent, domain, resource, sysdata).  Things like struct pci_ops and struct
> pci_host_bridge_ops are much simpler because drivers can statically
> allocate a single copy and use it for multiple devices.
> 
> I think it might make sense to put the struct pci_ops pointer inside struct
> pci_host_bridge_ops.  That would get rid of one of the arguments.
> 
> You might also be able to get rid of the "bus" argument, since the caller
> should be passing an IORESOURCE_BUS resource in the resource list, and
> "bus" should be the same as res->start.

I think this make sense, I will try to find a better solution.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
  2015-03-12 19:49         ` Bjorn Helgaas
                           ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  3:19         ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:19 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> struct pci_scan_info {
>> 	int bus;
>> 	struct device *parent;
>> 	struct pci_ops *ops;
>> 	void *sysdata;
>> 	struct list_head *resource;
>> 	int domain;
>> 	struct pci_host_bridge_ops;
>> }
>>
>> Do you like this one or keep it like now ?
>>
>> pci_scan_root_bus(struct device *parent, int domain, int bus,
>> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)
> 
> I don't think reducing the number of arguments is a good argument for
> squashing some of them together.
> 
> I don't really want to add a structure like that because it adds management
> complexity for all the callers because it contains per-bridge things (bus,
> parent, domain, resource, sysdata).  Things like struct pci_ops and struct
> pci_host_bridge_ops are much simpler because drivers can statically
> allocate a single copy and use it for multiple devices.
> 
> I think it might make sense to put the struct pci_ops pointer inside struct
> pci_host_bridge_ops.  That would get rid of one of the arguments.
> 
> You might also be able to get rid of the "bus" argument, since the caller
> should be passing an IORESOURCE_BUS resource in the resource list, and
> "bus" should be the same as res->start.

I think this make sense, I will try to find a better solution.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-13  3:19           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:19 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> struct pci_scan_info {
>> 	int bus;
>> 	struct device *parent;
>> 	struct pci_ops *ops;
>> 	void *sysdata;
>> 	struct list_head *resource;
>> 	int domain;
>> 	struct pci_host_bridge_ops;
>> }
>>
>> Do you like this one or keep it like now ?
>>
>> pci_scan_root_bus(struct device *parent, int domain, int bus,
>> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)
> 
> I don't think reducing the number of arguments is a good argument for
> squashing some of them together.
> 
> I don't really want to add a structure like that because it adds management
> complexity for all the callers because it contains per-bridge things (bus,
> parent, domain, resource, sysdata).  Things like struct pci_ops and struct
> pci_host_bridge_ops are much simpler because drivers can statically
> allocate a single copy and use it for multiple devices.
> 
> I think it might make sense to put the struct pci_ops pointer inside struct
> pci_host_bridge_ops.  That would get rid of one of the arguments.
> 
> You might also be able to get rid of the "bus" argument, since the caller
> should be passing an IORESOURCE_BUS resource in the resource list, and
> "bus" should be the same as res->start.

I think this make sense, I will try to find a better solution.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-13  3:19           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

>> struct pci_scan_info {
>> 	int bus;
>> 	struct device *parent;
>> 	struct pci_ops *ops;
>> 	void *sysdata;
>> 	struct list_head *resource;
>> 	int domain;
>> 	struct pci_host_bridge_ops;
>> }
>>
>> Do you like this one or keep it like now ?
>>
>> pci_scan_root_bus(struct device *parent, int domain, int bus,
>> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)
> 
> I don't think reducing the number of arguments is a good argument for
> squashing some of them together.
> 
> I don't really want to add a structure like that because it adds management
> complexity for all the callers because it contains per-bridge things (bus,
> parent, domain, resource, sysdata).  Things like struct pci_ops and struct
> pci_host_bridge_ops are much simpler because drivers can statically
> allocate a single copy and use it for multiple devices.
> 
> I think it might make sense to put the struct pci_ops pointer inside struct
> pci_host_bridge_ops.  That would get rid of one of the arguments.
> 
> You might also be able to get rid of the "bus" argument, since the caller
> should be passing an IORESOURCE_BUS resource in the resource list, and
> "bus" should be the same as res->start.

I think this make sense, I will try to find a better solution.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-13  3:19           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:19 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> struct pci_scan_info {
>> 	int bus;
>> 	struct device *parent;
>> 	struct pci_ops *ops;
>> 	void *sysdata;
>> 	struct list_head *resource;
>> 	int domain;
>> 	struct pci_host_bridge_ops;
>> }
>>
>> Do you like this one or keep it like now ?
>>
>> pci_scan_root_bus(struct device *parent, int domain, int bus,
>> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)
> 
> I don't think reducing the number of arguments is a good argument for
> squashing some of them together.
> 
> I don't really want to add a structure like that because it adds management
> complexity for all the callers because it contains per-bridge things (bus,
> parent, domain, resource, sysdata).  Things like struct pci_ops and struct
> pci_host_bridge_ops are much simpler because drivers can statically
> allocate a single copy and use it for multiple devices.
> 
> I think it might make sense to put the struct pci_ops pointer inside struct
> pci_host_bridge_ops.  That would get rid of one of the arguments.
> 
> You might also be able to get rid of the "bus" argument, since the caller
> should be passing an IORESOURCE_BUS resource in the resource list, and
> "bus" should be the same as res->start.

I think this make sense, I will try to find a better solution.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg
@ 2015-03-13  3:19           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:19 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> struct pci_scan_info {
>> 	int bus;
>> 	struct device *parent;
>> 	struct pci_ops *ops;
>> 	void *sysdata;
>> 	struct list_head *resource;
>> 	int domain;
>> 	struct pci_host_bridge_ops;
>> }
>>
>> Do you like this one or keep it like now ?
>>
>> pci_scan_root_bus(struct device *parent, int domain, int bus,
>> 		struct pci_ops *ops, void *sysdata, struct list_head *resources, struct pci_host_bridge_ops *ops)
> 
> I don't think reducing the number of arguments is a good argument for
> squashing some of them together.
> 
> I don't really want to add a structure like that because it adds management
> complexity for all the callers because it contains per-bridge things (bus,
> parent, domain, resource, sysdata).  Things like struct pci_ops and struct
> pci_host_bridge_ops are much simpler because drivers can statically
> allocate a single copy and use it for multiple devices.
> 
> I think it might make sense to put the struct pci_ops pointer inside struct
> pci_host_bridge_ops.  That would get rid of one of the arguments.
> 
> You might also be able to get rid of the "bus" argument, since the caller
> should be passing an IORESOURCE_BUS resource in the resource list, and
> "bus" should be the same as res->start.

I think this make sense, I will try to find a better solution.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-12 19:56         ` Bjorn Helgaas
                             ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  3:28           ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>> It's a nice idea to move this test into the core.  While you're at it, why
>>> don't you check for any overlap with the bus ranges of existing host
>>> bridges?  For example, if we're trying to create a new host bridge to
>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>> latter conflict but not the former.
>>
>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>> some pci scan would fail which currently scan success.
> 
> _BBN is not the correct source for the bridge's bus number range.  There's
> a comment in acpi_pci_root_add() that explains why:
> 
>   * We need both the start and end of the downstream bus range
>   * to interpret _CBA (MMCONFIG base address), so it really is
>   * supposed to be in _CRS.  If we don't find it there, all we
>   * can do is assume [_BBN-0xFF] or [0-0xFF].
> 
> A platform SHOULD know the start and and end bus number.  If it doesn't I
> think it's the platform's responsibility to carve up the bus number range.
> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
> we discover another bridge that leads to bus 80.

Currently, if platform does not know the end bus number (not provide the bus resource),
we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
and I think this is reasonable. I consider to introduce a flag to identify the bus resource
which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
to provide the bus resource, and we could process the bus resource end according the bus resource flag.
Also then we could reduce the bus argument which is the same as busn_res->start.
I would try to provide draft patch, then we could discuss it more clearly.

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-12 19:56         ` Bjorn Helgaas
                           ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  3:28         ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>> It's a nice idea to move this test into the core.  While you're at it, why
>>> don't you check for any overlap with the bus ranges of existing host
>>> bridges?  For example, if we're trying to create a new host bridge to
>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>> latter conflict but not the former.
>>
>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>> some pci scan would fail which currently scan success.
> 
> _BBN is not the correct source for the bridge's bus number range.  There's
> a comment in acpi_pci_root_add() that explains why:
> 
>   * We need both the start and end of the downstream bus range
>   * to interpret _CBA (MMCONFIG base address), so it really is
>   * supposed to be in _CRS.  If we don't find it there, all we
>   * can do is assume [_BBN-0xFF] or [0-0xFF].
> 
> A platform SHOULD know the start and and end bus number.  If it doesn't I
> think it's the platform's responsibility to carve up the bus number range.
> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
> we discover another bridge that leads to bus 80.

Currently, if platform does not know the end bus number (not provide the bus resource),
we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
and I think this is reasonable. I consider to introduce a flag to identify the bus resource
which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
to provide the bus resource, and we could process the bus resource end according the bus resource flag.
Also then we could reduce the bus argument which is the same as busn_res->start.
I would try to provide draft patch, then we could discuss it more clearly.

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13  3:28           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>> It's a nice idea to move this test into the core.  While you're at it, why
>>> don't you check for any overlap with the bus ranges of existing host
>>> bridges?  For example, if we're trying to create a new host bridge to
>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>> latter conflict but not the former.
>>
>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>> some pci scan would fail which currently scan success.
> 
> _BBN is not the correct source for the bridge's bus number range.  There's
> a comment in acpi_pci_root_add() that explains why:
> 
>   * We need both the start and end of the downstream bus range
>   * to interpret _CBA (MMCONFIG base address), so it really is
>   * supposed to be in _CRS.  If we don't find it there, all we
>   * can do is assume [_BBN-0xFF] or [0-0xFF].
> 
> A platform SHOULD know the start and and end bus number.  If it doesn't I
> think it's the platform's responsibility to carve up the bus number range.
> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
> we discover another bridge that leads to bus 80.

Currently, if platform does not know the end bus number (not provide the bus resource),
we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
and I think this is reasonable. I consider to introduce a flag to identify the bus resource
which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
to provide the bus resource, and we could process the bus resource end according the bus resource flag.
Also then we could reduce the bus argument which is the same as busn_res->start.
I would try to provide draft patch, then we could discuss it more clearly.

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13  3:28           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:28 UTC (permalink / raw)
  To: linux-arm-kernel

>>> It's a nice idea to move this test into the core.  While you're at it, why
>>> don't you check for any overlap with the bus ranges of existing host
>>> bridges?  For example, if we're trying to create a new host bridge to
>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>> latter conflict but not the former.
>>
>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>> some pci scan would fail which currently scan success.
> 
> _BBN is not the correct source for the bridge's bus number range.  There's
> a comment in acpi_pci_root_add() that explains why:
> 
>   * We need both the start and end of the downstream bus range
>   * to interpret _CBA (MMCONFIG base address), so it really is
>   * supposed to be in _CRS.  If we don't find it there, all we
>   * can do is assume [_BBN-0xFF] or [0-0xFF].
> 
> A platform SHOULD know the start and and end bus number.  If it doesn't I
> think it's the platform's responsibility to carve up the bus number range.
> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
> we discover another bridge that leads to bus 80.

Currently, if platform does not know the end bus number (not provide the bus resource),
we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
and I think this is reasonable. I consider to introduce a flag to identify the bus resource
which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
to provide the bus resource, and we could process the bus resource end according the bus resource flag.
Also then we could reduce the bus argument which is the same as busn_res->start.
I would try to provide draft patch, then we could discuss it more clearly.

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13  3:28           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>> It's a nice idea to move this test into the core.  While you're at it, why
>>> don't you check for any overlap with the bus ranges of existing host
>>> bridges?  For example, if we're trying to create a new host bridge to
>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>> latter conflict but not the former.
>>
>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>> some pci scan would fail which currently scan success.
> 
> _BBN is not the correct source for the bridge's bus number range.  There's
> a comment in acpi_pci_root_add() that explains why:
> 
>   * We need both the start and end of the downstream bus range
>   * to interpret _CBA (MMCONFIG base address), so it really is
>   * supposed to be in _CRS.  If we don't find it there, all we
>   * can do is assume [_BBN-0xFF] or [0-0xFF].
> 
> A platform SHOULD know the start and and end bus number.  If it doesn't I
> think it's the platform's responsibility to carve up the bus number range.
> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
> we discover another bridge that leads to bus 80.

Currently, if platform does not know the end bus number (not provide the bus resource),
we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
and I think this is reasonable. I consider to introduce a flag to identify the bus resource
which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
to provide the bus resource, and we could process the bus resource end according the bus resource flag.
Also then we could reduce the bus argument which is the same as busn_res->start.
I would try to provide draft patch, then we could discuss it more clearly.

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13  3:28           ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>>> It's a nice idea to move this test into the core.  While you're at it, why
>>> don't you check for any overlap with the bus ranges of existing host
>>> bridges?  For example, if we're trying to create a new host bridge to
>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>> latter conflict but not the former.
>>
>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>> some pci scan would fail which currently scan success.
> 
> _BBN is not the correct source for the bridge's bus number range.  There's
> a comment in acpi_pci_root_add() that explains why:
> 
>   * We need both the start and end of the downstream bus range
>   * to interpret _CBA (MMCONFIG base address), so it really is
>   * supposed to be in _CRS.  If we don't find it there, all we
>   * can do is assume [_BBN-0xFF] or [0-0xFF].
> 
> A platform SHOULD know the start and and end bus number.  If it doesn't I
> think it's the platform's responsibility to carve up the bus number range.
> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
> we discover another bridge that leads to bus 80.

Currently, if platform does not know the end bus number (not provide the bus resource),
we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
and I think this is reasonable. I consider to introduce a flag to identify the bus resource
which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
to provide the bus resource, and we could process the bus resource end according the bus resource flag.
Also then we could reduce the bus argument which is the same as busn_res->start.
I would try to provide draft patch, then we could discuss it more clearly.

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-12 21:23   ` Bjorn Helgaas
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-13  3:29     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 5:23, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> ...
>> Yijing Wang (29):
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.
> 

Nice, so we could rebase the rest series easier, thanks!

>>   PCI: Export busn_resource to drivers/pci
>>   PCI: Remove deprecated pci_scan_bus_parented()
>>   PCI: Combine PCI domain and bus number in u32 arg
>>   PCI: Pass PCI domain number combined with root bus number
>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>   PCI: Save sysdata in pci_host_bridge drvdata
>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>     operations
>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>   PCI: Introduce pci_bus_child_max_busnr()
>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>   PCI: Export find_pci_host_bridge() and rename to
>>     pci_find_host_bridge()
>>   PCI: Remove platform specific pci_domain_nr()
>>   PCI: Remove pci_bus_assign_domain_nr()
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13  3:29     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 5:23, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> ...
>> Yijing Wang (29):
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.
> 

Nice, so we could rebase the rest series easier, thanks!

>>   PCI: Export busn_resource to drivers/pci
>>   PCI: Remove deprecated pci_scan_bus_parented()
>>   PCI: Combine PCI domain and bus number in u32 arg
>>   PCI: Pass PCI domain number combined with root bus number
>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>   PCI: Save sysdata in pci_host_bridge drvdata
>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>     operations
>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>   PCI: Introduce pci_bus_child_max_busnr()
>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>   PCI: Export find_pci_host_bridge() and rename to
>>     pci_find_host_bridge()
>>   PCI: Remove platform specific pci_domain_nr()
>>   PCI: Remove pci_bus_assign_domain_nr()
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13  3:29     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 5:23, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> ...
>> Yijing Wang (29):
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.
> 

Nice, so we could rebase the rest series easier, thanks!

>>   PCI: Export busn_resource to drivers/pci
>>   PCI: Remove deprecated pci_scan_bus_parented()
>>   PCI: Combine PCI domain and bus number in u32 arg
>>   PCI: Pass PCI domain number combined with root bus number
>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>   PCI: Save sysdata in pci_host_bridge drvdata
>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>     operations
>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>   PCI: Introduce pci_bus_child_max_busnr()
>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>   PCI: Export find_pci_host_bridge() and rename to
>>     pci_find_host_bridge()
>>   PCI: Remove platform specific pci_domain_nr()
>>   PCI: Remove pci_bus_assign_domain_nr()
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13  3:29     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:29 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/13 5:23, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> ...
>> Yijing Wang (29):
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.
> 

Nice, so we could rebase the rest series easier, thanks!

>>   PCI: Export busn_resource to drivers/pci
>>   PCI: Remove deprecated pci_scan_bus_parented()
>>   PCI: Combine PCI domain and bus number in u32 arg
>>   PCI: Pass PCI domain number combined with root bus number
>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>   PCI: Save sysdata in pci_host_bridge drvdata
>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>     operations
>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>   PCI: Introduce pci_bus_child_max_busnr()
>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>   PCI: Export find_pci_host_bridge() and rename to
>>     pci_find_host_bridge()
>>   PCI: Remove platform specific pci_domain_nr()
>>   PCI: Remove pci_bus_assign_domain_nr()
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13  3:29     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-13  3:29 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 5:23, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> ...
>> Yijing Wang (29):
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.
> 

Nice, so we could rebase the rest series easier, thanks!

>>   PCI: Export busn_resource to drivers/pci
>>   PCI: Remove deprecated pci_scan_bus_parented()
>>   PCI: Combine PCI domain and bus number in u32 arg
>>   PCI: Pass PCI domain number combined with root bus number
>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>   PCI: Save sysdata in pci_host_bridge drvdata
>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>     operations
>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>   PCI: Introduce pci_bus_child_max_busnr()
>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>   PCI: Export find_pci_host_bridge() and rename to
>>     pci_find_host_bridge()
>>   PCI: Remove platform specific pci_domain_nr()
>>   PCI: Remove pci_bus_assign_domain_nr()
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-12 21:23   ` Bjorn Helgaas
  (?)
@ 2015-03-13 11:31     ` Liviu Dudau
  -1 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-13 11:31 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm-kernel, Russell King, x86,
	Thomas Gleixner, Benjamin Herrenschmidt, Rusty Russell,
	Tony Luck, linux-ia64, David S. Miller, Guan Xuetao, linux-alpha,
	linux-m68k, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> > ...
> > Yijing Wang (29):
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.

Hi Bjorn and Yijing,

Sorry for not providing feedback earlier on this series (or any previous ones),
I'm just crawling out from under a rock of doing graphics drivers :)

The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
the users of that function from drivers/pci/host. If Yijing is going to refresh
the series it is probably worth starting with adding back the call into pcie-xilinx.c
and pci-versatile.c.

Will try to review (and test) the rest of the series soon.

Best regards,
Liviu

> 
> >   PCI: Export busn_resource to drivers/pci
> >   PCI: Remove deprecated pci_scan_bus_parented()
> >   PCI: Combine PCI domain and bus number in u32 arg
> >   PCI: Pass PCI domain number combined with root bus number
> >   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >   PCI: Introduce pci_host_bridge_list to manage host bridges
> >   PCI: Save sysdata in pci_host_bridge drvdata
> >   PCI: Introduce pci_host_bridge_ops to support host specific
> >     operations
> >   PCI: Introduce new scan function pci_scan_host_bridge()
> >   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >   PCI: Remove weak pcibios_root_bridge_prepare()
> >   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >   PCI: Introduce pci_bus_child_max_busnr()
> >   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >   PCI/designware: Use pci_scan_root_bus() for simplicity
> >   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >   PCI: Export find_pci_host_bridge() and rename to
> >     pci_find_host_bridge()
> >   PCI: Remove platform specific pci_domain_nr()
> >   PCI: Remove pci_bus_assign_domain_nr()
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-12 21:23   ` Bjorn Helgaas
                     ` (3 preceding siblings ...)
  (?)
@ 2015-03-13 11:31   ` Liviu Dudau
  -1 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-13 11:31 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm-kernel, Russell King, x86,
	Thomas Gleixner, Benjamin Herrenschmidt, Rusty Russell,
	Tony Luck, linux-ia64, David S. Miller, Guan Xuetao, linux-alpha,
	linux-m68k, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> > ...
> > Yijing Wang (29):
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.

Hi Bjorn and Yijing,

Sorry for not providing feedback earlier on this series (or any previous ones),
I'm just crawling out from under a rock of doing graphics drivers :)

The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
the users of that function from drivers/pci/host. If Yijing is going to refresh
the series it is probably worth starting with adding back the call into pcie-xilinx.c
and pci-versatile.c.

Will try to review (and test) the rest of the series soon.

Best regards,
Liviu

> 
> >   PCI: Export busn_resource to drivers/pci
> >   PCI: Remove deprecated pci_scan_bus_parented()
> >   PCI: Combine PCI domain and bus number in u32 arg
> >   PCI: Pass PCI domain number combined with root bus number
> >   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >   PCI: Introduce pci_host_bridge_list to manage host bridges
> >   PCI: Save sysdata in pci_host_bridge drvdata
> >   PCI: Introduce pci_host_bridge_ops to support host specific
> >     operations
> >   PCI: Introduce new scan function pci_scan_host_bridge()
> >   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >   PCI: Remove weak pcibios_root_bridge_prepare()
> >   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >   PCI: Introduce pci_bus_child_max_busnr()
> >   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >   PCI/designware: Use pci_scan_root_bus() for simplicity
> >   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >   PCI: Export find_pci_host_bridge() and rename to
> >     pci_find_host_bridge()
> >   PCI: Remove platform specific pci_domain_nr()
> >   PCI: Remove pci_bus_assign_domain_nr()
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13 11:31     ` Liviu Dudau
  0 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-13 11:31 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm-kernel, Russell King, x86,
	Thomas Gleixner, Benjamin Herrenschmidt, Rusty Russell,
	Tony Luck, linux-ia64, David S. Miller, Guan Xuetao, linux-alpha,
	linux-m68k, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> > ...
> > Yijing Wang (29):
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.

Hi Bjorn and Yijing,

Sorry for not providing feedback earlier on this series (or any previous ones),
I'm just crawling out from under a rock of doing graphics drivers :)

The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
the users of that function from drivers/pci/host. If Yijing is going to refresh
the series it is probably worth starting with adding back the call into pcie-xilinx.c
and pci-versatile.c.

Will try to review (and test) the rest of the series soon.

Best regards,
Liviu

> 
> >   PCI: Export busn_resource to drivers/pci
> >   PCI: Remove deprecated pci_scan_bus_parented()
> >   PCI: Combine PCI domain and bus number in u32 arg
> >   PCI: Pass PCI domain number combined with root bus number
> >   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >   PCI: Introduce pci_host_bridge_list to manage host bridges
> >   PCI: Save sysdata in pci_host_bridge drvdata
> >   PCI: Introduce pci_host_bridge_ops to support host specific
> >     operations
> >   PCI: Introduce new scan function pci_scan_host_bridge()
> >   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >   PCI: Remove weak pcibios_root_bridge_prepare()
> >   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >   PCI: Introduce pci_bus_child_max_busnr()
> >   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >   PCI/designware: Use pci_scan_root_bus() for simplicity
> >   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >   PCI: Export find_pci_host_bridge() and rename to
> >     pci_find_host_bridge()
> >   PCI: Remove platform specific pci_domain_nr()
> >   PCI: Remove pci_bus_assign_domain_nr()
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13 11:31     ` Liviu Dudau
  0 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-13 11:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> > ...
> > Yijing Wang (29):
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> 
> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> Please rebase your next revision to that.  If there's anything else
> non-controversial that we can pull in to chip away at this, let me know.

Hi Bjorn and Yijing,

Sorry for not providing feedback earlier on this series (or any previous ones),
I'm just crawling out from under a rock of doing graphics drivers :)

The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
the users of that function from drivers/pci/host. If Yijing is going to refresh
the series it is probably worth starting with adding back the call into pcie-xilinx.c
and pci-versatile.c.

Will try to review (and test) the rest of the series soon.

Best regards,
Liviu

> 
> >   PCI: Export busn_resource to drivers/pci
> >   PCI: Remove deprecated pci_scan_bus_parented()
> >   PCI: Combine PCI domain and bus number in u32 arg
> >   PCI: Pass PCI domain number combined with root bus number
> >   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >   PCI: Introduce pci_host_bridge_list to manage host bridges
> >   PCI: Save sysdata in pci_host_bridge drvdata
> >   PCI: Introduce pci_host_bridge_ops to support host specific
> >     operations
> >   PCI: Introduce new scan function pci_scan_host_bridge()
> >   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >   PCI: Remove weak pcibios_root_bridge_prepare()
> >   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >   PCI: Introduce pci_bus_child_max_busnr()
> >   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >   PCI/designware: Use pci_scan_root_bus() for simplicity
> >   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >   PCI: Export find_pci_host_bridge() and rename to
> >     pci_find_host_bridge()
> >   PCI: Remove platform specific pci_domain_nr()
> >   PCI: Remove pci_bus_assign_domain_nr()
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13  2:36           ` Yijing Wang
                               ` (2 preceding siblings ...)
  (?)
@ 2015-03-13 13:24             ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> 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
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13  2:36           ` Yijing Wang
                             ` (3 preceding siblings ...)
  (?)
@ 2015-03-13 13:24           ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> 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
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 13:24             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> 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
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> 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

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 13:24             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>>>>> the body of a message to majordomo at vger.kernel.org
>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>>> the body of a message to majordomo at vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13  2:36           ` Yijing Wang
                             ` (4 preceding siblings ...)
  (?)
@ 2015-03-13 13:24           ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: Yijing Wang
  Cc: linux-ia64, linux-pci, Guan Xuetao, Russell King, x86,
	Geert Uytterhoeven, Benjamin Herrenschmidt, xen-devel,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Thomas Gleixner, Yinghai Lu, linux-arm, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, David S. Miller

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> 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
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 13:24             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn=0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> 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
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 13:24             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 13:24 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	Konrad Rzeszutek Wilk, xen-devel

On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>>> +  pci_add_resource(&resources, &ioport_resource);
>>>>> +  pci_add_resource(&resources, &iomem_resource);
>>>>> +  pci_add_resource(&resources, &busn_resource);
>>>>
>>>> Since I don't want to export busn_resource, you might have to allocate your
>>>> own struct resource for it here.  And, of course, figure out the details of
>>>> which PCI domain you're in and whether you need to share one struct
>>>> resource across several host bridges in the same domain.
>>>
>>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>>> so do we still need to add additional info to figure out which domain own the bus resource ?
>>
>> That's up to the caller.  Only the platform knows which bridges it wants to
>> have in the same domain.  In principle, every host bridge could be in its
>> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> some platforms have firmware that assumes otherwise.  I have no idea what
>> xen assumes.
>
> I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> before, and in which busn_resource is always shared for different host bridges(same domain or not),
> I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>
> Something like:
>
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index b1ffebe..a69e529 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                                  unsigned int domain, unsigned int bus)
>  {
>         struct pci_bus *b;
> +       LIST_HEAD(resources);
>         struct pcifront_sd *sd = NULL;
>         struct pci_bus_entry *bus_entry = NULL;
>         int err = 0;
> +       static struct resource busn_res = {
> +               .start = 0,
> +               .end = 255,
> +               .flags = IORESOURCE_BUS,
> +       };
>
>  #ifndef CONFIG_PCI_DOMAINS
>         if (domain != 0) {
> @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>                 err = -ENOMEM;
>                 goto err_out;
>         }
> +       pci_add_resource(&resources, &ioport_resource);
> +       pci_add_resource(&resources, &iomem_resource);
> +       pci_add_resource(&resources, &busn_res);
>         pcifront_init_sd(sd, domain, bus, pdev);
>
>         pci_lock_rescan_remove();
>
> -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> -                                 &pcifront_bus_ops, sd);
> +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> +                                 &pcifront_bus_ops, sd, &resources);
>         if (!b) {
>
> Bjorn, what do you think about ?

That seems OK to me.  Probably still wrong, but no worse than it was before.

>>>>>    pcifront_init_sd(sd, domain, bus, pdev);
>>>>>
>>>>>    pci_lock_rescan_remove();
>>>>>
>>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>>>>> -                            &pcifront_bus_ops, sd);
>>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>>>>> +                            &pcifront_bus_ops, sd, &resources);
>>>>>    if (!b) {
>>>>>            dev_err(&pdev->xdev->dev,
>>>>>                    "Error creating PCI Frontend Bus!\n");
>>>>>            err = -ENOMEM;
>>>>>            pci_unlock_rescan_remove();
>>>>> +          pci_free_resource_list(&resources);
>>>>>            goto err_out;
>>>>>    }
>>>>>
>>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>>>>>
>>>>>    list_add(&bus_entry->list, &pdev->root_buses);
>>>>>
>>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
>>>>> +  /* pci_scan_root_bus skips devices which do not have a
>>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
>>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
>>>>>
>>>>> --
>>>>> 1.7.1
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Thanks!
>>> Yijing
>>>
>>> --
>>> 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
>>
>> .
>>
>
>
> --
> Thanks!
> Yijing
>
> --
> 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13 13:24             ` Bjorn Helgaas
  (?)
  (?)
@ 2015-03-13 14:01               ` Konrad Rzeszutek Wilk
  -1 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-13 14:01 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >>>>
> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >>>> own struct resource for it here.  And, of course, figure out the details of
> >>>> which PCI domain you're in and whether you need to share one struct
> >>>> resource across several host bridges in the same domain.
> >>>
> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >>
> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> have in the same domain.  In principle, every host bridge could be in its
> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> xen assumes.
> >
> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >
> > Something like:
> >
> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> > index b1ffebe..a69e529 100644
> > --- a/drivers/pci/xen-pcifront.c
> > +++ b/drivers/pci/xen-pcifront.c
> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                                  unsigned int domain, unsigned int bus)
> >  {
> >         struct pci_bus *b;
> > +       LIST_HEAD(resources);
> >         struct pcifront_sd *sd = NULL;
> >         struct pci_bus_entry *bus_entry = NULL;
> >         int err = 0;
> > +       static struct resource busn_res = {
> > +               .start = 0,
> > +               .end = 255,
> > +               .flags = IORESOURCE_BUS,
> > +       };
> >
> >  #ifndef CONFIG_PCI_DOMAINS
> >         if (domain != 0) {
> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                 err = -ENOMEM;
> >                 goto err_out;
> >         }
> > +       pci_add_resource(&resources, &ioport_resource);
> > +       pci_add_resource(&resources, &iomem_resource);
> > +       pci_add_resource(&resources, &busn_res);
> >         pcifront_init_sd(sd, domain, bus, pdev);
> >
> >         pci_lock_rescan_remove();
> >
> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> > -                                 &pcifront_bus_ops, sd);
> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> > +                                 &pcifront_bus_ops, sd, &resources);
> >         if (!b) {
> >
> > Bjorn, what do you think about ?
> 
> That seems OK to me.  Probably still wrong, but no worse than it was before.

Interesting. The mechanism for PCI passthrough can either synthesize
and PCI bus number starting at zero (so first device is always 0:0:0.0)
or it can replicate the backend PCI topology. That means you
could have segment values passed in, so: ab:ff:00.1). I've to admin
I hadn't tried the 'physical' replication on an machine with
domains (err, segments).

Is there an git tree with this so I can just try it out?

Thanks.
> 
> >>>>>    pcifront_init_sd(sd, domain, bus, pdev);
> >>>>>
> >>>>>    pci_lock_rescan_remove();
> >>>>>
> >>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >>>>> -                            &pcifront_bus_ops, sd);
> >>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >>>>> +                            &pcifront_bus_ops, sd, &resources);
> >>>>>    if (!b) {
> >>>>>            dev_err(&pdev->xdev->dev,
> >>>>>                    "Error creating PCI Frontend Bus!\n");
> >>>>>            err = -ENOMEM;
> >>>>>            pci_unlock_rescan_remove();
> >>>>> +          pci_free_resource_list(&resources);
> >>>>>            goto err_out;
> >>>>>    }
> >>>>>
> >>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>>>>
> >>>>>    list_add(&bus_entry->list, &pdev->root_buses);
> >>>>>
> >>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
> >>>>> +  /* pci_scan_root_bus skips devices which do not have a
> >>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
> >>>>>
> >>>>> --
> >>>>> 1.7.1
> >>>>>
> >>>>> --
> >>>>> 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
> >>>>
> >>>> .
> >>>>
> >>>
> >>>
> >>> --
> >>> Thanks!
> >>> Yijing
> >>>
> >>> --
> >>> 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
> >>
> >> .
> >>
> >
> >
> > --
> > Thanks!
> > Yijing
> >
> > --
> > 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 14:01               ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-13 14:01 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >>>>
> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >>>> own struct resource for it here.  And, of course, figure out the details of
> >>>> which PCI domain you're in and whether you need to share one struct
> >>>> resource across several host bridges in the same domain.
> >>>
> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >>
> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> have in the same domain.  In principle, every host bridge could be in its
> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> xen assumes.
> >
> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >
> > Something like:
> >
> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> > index b1ffebe..a69e529 100644
> > --- a/drivers/pci/xen-pcifront.c
> > +++ b/drivers/pci/xen-pcifront.c
> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                                  unsigned int domain, unsigned int bus)
> >  {
> >         struct pci_bus *b;
> > +       LIST_HEAD(resources);
> >         struct pcifront_sd *sd = NULL;
> >         struct pci_bus_entry *bus_entry = NULL;
> >         int err = 0;
> > +       static struct resource busn_res = {
> > +               .start = 0,
> > +               .end = 255,
> > +               .flags = IORESOURCE_BUS,
> > +       };
> >
> >  #ifndef CONFIG_PCI_DOMAINS
> >         if (domain != 0) {
> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                 err = -ENOMEM;
> >                 goto err_out;
> >         }
> > +       pci_add_resource(&resources, &ioport_resource);
> > +       pci_add_resource(&resources, &iomem_resource);
> > +       pci_add_resource(&resources, &busn_res);
> >         pcifront_init_sd(sd, domain, bus, pdev);
> >
> >         pci_lock_rescan_remove();
> >
> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> > -                                 &pcifront_bus_ops, sd);
> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> > +                                 &pcifront_bus_ops, sd, &resources);
> >         if (!b) {
> >
> > Bjorn, what do you think about ?
> 
> That seems OK to me.  Probably still wrong, but no worse than it was before.

Interesting. The mechanism for PCI passthrough can either synthesize
and PCI bus number starting at zero (so first device is always 0:0:0.0)
or it can replicate the backend PCI topology. That means you
could have segment values passed in, so: ab:ff:00.1). I've to admin
I hadn't tried the 'physical' replication on an machine with
domains (err, segments).

Is there an git tree with this so I can just try it out?

Thanks.
> 
> >>>>>    pcifront_init_sd(sd, domain, bus, pdev);
> >>>>>
> >>>>>    pci_lock_rescan_remove();
> >>>>>
> >>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >>>>> -                            &pcifront_bus_ops, sd);
> >>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >>>>> +                            &pcifront_bus_ops, sd, &resources);
> >>>>>    if (!b) {
> >>>>>            dev_err(&pdev->xdev->dev,
> >>>>>                    "Error creating PCI Frontend Bus!\n");
> >>>>>            err = -ENOMEM;
> >>>>>            pci_unlock_rescan_remove();
> >>>>> +          pci_free_resource_list(&resources);
> >>>>>            goto err_out;
> >>>>>    }
> >>>>>
> >>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>>>>
> >>>>>    list_add(&bus_entry->list, &pdev->root_buses);
> >>>>>
> >>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
> >>>>> +  /* pci_scan_root_bus skips devices which do not have a
> >>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
> >>>>>
> >>>>> --
> >>>>> 1.7.1
> >>>>>
> >>>>> --
> >>>>> 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
> >>>>
> >>>> .
> >>>>
> >>>
> >>>
> >>> --
> >>> Thanks!
> >>> Yijing
> >>>
> >>> --
> >>> 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
> >>
> >> .
> >>
> >
> >
> > --
> > Thanks!
> > Yijing
> >
> > --
> > 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

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 14:01               ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-13 14:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >>>>
> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >>>> own struct resource for it here.  And, of course, figure out the details of
> >>>> which PCI domain you're in and whether you need to share one struct
> >>>> resource across several host bridges in the same domain.
> >>>
> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >>
> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> have in the same domain.  In principle, every host bridge could be in its
> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> xen assumes.
> >
> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >
> > Something like:
> >
> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> > index b1ffebe..a69e529 100644
> > --- a/drivers/pci/xen-pcifront.c
> > +++ b/drivers/pci/xen-pcifront.c
> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                                  unsigned int domain, unsigned int bus)
> >  {
> >         struct pci_bus *b;
> > +       LIST_HEAD(resources);
> >         struct pcifront_sd *sd = NULL;
> >         struct pci_bus_entry *bus_entry = NULL;
> >         int err = 0;
> > +       static struct resource busn_res = {
> > +               .start = 0,
> > +               .end = 255,
> > +               .flags = IORESOURCE_BUS,
> > +       };
> >
> >  #ifndef CONFIG_PCI_DOMAINS
> >         if (domain != 0) {
> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                 err = -ENOMEM;
> >                 goto err_out;
> >         }
> > +       pci_add_resource(&resources, &ioport_resource);
> > +       pci_add_resource(&resources, &iomem_resource);
> > +       pci_add_resource(&resources, &busn_res);
> >         pcifront_init_sd(sd, domain, bus, pdev);
> >
> >         pci_lock_rescan_remove();
> >
> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> > -                                 &pcifront_bus_ops, sd);
> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> > +                                 &pcifront_bus_ops, sd, &resources);
> >         if (!b) {
> >
> > Bjorn, what do you think about ?
> 
> That seems OK to me.  Probably still wrong, but no worse than it was before.

Interesting. The mechanism for PCI passthrough can either synthesize
and PCI bus number starting at zero (so first device is always 0:0:0.0)
or it can replicate the backend PCI topology. That means you
could have segment values passed in, so: ab:ff:00.1). I've to admin
I hadn't tried the 'physical' replication on an machine with
domains (err, segments).

Is there an git tree with this so I can just try it out?

Thanks.
> 
> >>>>>    pcifront_init_sd(sd, domain, bus, pdev);
> >>>>>
> >>>>>    pci_lock_rescan_remove();
> >>>>>
> >>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >>>>> -                            &pcifront_bus_ops, sd);
> >>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >>>>> +                            &pcifront_bus_ops, sd, &resources);
> >>>>>    if (!b) {
> >>>>>            dev_err(&pdev->xdev->dev,
> >>>>>                    "Error creating PCI Frontend Bus!\n");
> >>>>>            err = -ENOMEM;
> >>>>>            pci_unlock_rescan_remove();
> >>>>> +          pci_free_resource_list(&resources);
> >>>>>            goto err_out;
> >>>>>    }
> >>>>>
> >>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>>>>
> >>>>>    list_add(&bus_entry->list, &pdev->root_buses);
> >>>>>
> >>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
> >>>>> +  /* pci_scan_root_bus skips devices which do not have a
> >>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
> >>>>>
> >>>>> --
> >>>>> 1.7.1
> >>>>>
> >>>>> --
> >>>>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> >>>>> the body of a message to majordomo at vger.kernel.org
> >>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >>>>
> >>>> .
> >>>>
> >>>
> >>>
> >>> --
> >>> Thanks!
> >>> Yijing
> >>>
> >>> --
> >>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> >>> the body of a message to majordomo at vger.kernel.org
> >>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >>
> >> .
> >>
> >
> >
> > --
> > Thanks!
> > Yijing
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> > the body of a message to majordomo at vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13 13:24             ` Bjorn Helgaas
                               ` (4 preceding siblings ...)
  (?)
@ 2015-03-13 14:01             ` Konrad Rzeszutek Wilk
  -1 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-13 14:01 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-m68k, linux-ia64, linux-pci, Yijing Wang, Guan Xuetao,
	Russell King, x86, Geert Uytterhoeven, Benjamin Herrenschmidt,
	xen-devel, Arnd Bergmann, Marc Zyngier, Rusty Russell,
	Thomas Gleixner, Yinghai Lu, linux-arm, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, Davi

On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >>>>
> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >>>> own struct resource for it here.  And, of course, figure out the details of
> >>>> which PCI domain you're in and whether you need to share one struct
> >>>> resource across several host bridges in the same domain.
> >>>
> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >>
> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> have in the same domain.  In principle, every host bridge could be in its
> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> xen assumes.
> >
> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >
> > Something like:
> >
> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> > index b1ffebe..a69e529 100644
> > --- a/drivers/pci/xen-pcifront.c
> > +++ b/drivers/pci/xen-pcifront.c
> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                                  unsigned int domain, unsigned int bus)
> >  {
> >         struct pci_bus *b;
> > +       LIST_HEAD(resources);
> >         struct pcifront_sd *sd = NULL;
> >         struct pci_bus_entry *bus_entry = NULL;
> >         int err = 0;
> > +       static struct resource busn_res = {
> > +               .start = 0,
> > +               .end = 255,
> > +               .flags = IORESOURCE_BUS,
> > +       };
> >
> >  #ifndef CONFIG_PCI_DOMAINS
> >         if (domain != 0) {
> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                 err = -ENOMEM;
> >                 goto err_out;
> >         }
> > +       pci_add_resource(&resources, &ioport_resource);
> > +       pci_add_resource(&resources, &iomem_resource);
> > +       pci_add_resource(&resources, &busn_res);
> >         pcifront_init_sd(sd, domain, bus, pdev);
> >
> >         pci_lock_rescan_remove();
> >
> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> > -                                 &pcifront_bus_ops, sd);
> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> > +                                 &pcifront_bus_ops, sd, &resources);
> >         if (!b) {
> >
> > Bjorn, what do you think about ?
> 
> That seems OK to me.  Probably still wrong, but no worse than it was before.

Interesting. The mechanism for PCI passthrough can either synthesize
and PCI bus number starting at zero (so first device is always 0:0:0.0)
or it can replicate the backend PCI topology. That means you
could have segment values passed in, so: ab:ff:00.1). I've to admin
I hadn't tried the 'physical' replication on an machine with
domains (err, segments).

Is there an git tree with this so I can just try it out?

Thanks.
> 
> >>>>>    pcifront_init_sd(sd, domain, bus, pdev);
> >>>>>
> >>>>>    pci_lock_rescan_remove();
> >>>>>
> >>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >>>>> -                            &pcifront_bus_ops, sd);
> >>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >>>>> +                            &pcifront_bus_ops, sd, &resources);
> >>>>>    if (!b) {
> >>>>>            dev_err(&pdev->xdev->dev,
> >>>>>                    "Error creating PCI Frontend Bus!\n");
> >>>>>            err = -ENOMEM;
> >>>>>            pci_unlock_rescan_remove();
> >>>>> +          pci_free_resource_list(&resources);
> >>>>>            goto err_out;
> >>>>>    }
> >>>>>
> >>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>>>>
> >>>>>    list_add(&bus_entry->list, &pdev->root_buses);
> >>>>>
> >>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
> >>>>> +  /* pci_scan_root_bus skips devices which do not have a
> >>>>>    * devfn==0. The pcifront_scan_bus enumerates all devfn. */
> >>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
> >>>>>
> >>>>> --
> >>>>> 1.7.1
> >>>>>
> >>>>> --
> >>>>> 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
> >>>>
> >>>> .
> >>>>
> >>>
> >>>
> >>> --
> >>> Thanks!
> >>> Yijing
> >>>
> >>> --
> >>> 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
> >>
> >> .
> >>
> >
> >
> > --
> > Thanks!
> > Yijing
> >
> > --
> > 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 14:01               ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-13 14:01 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >>>>
> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >>>> own struct resource for it here.  And, of course, figure out the details of
> >>>> which PCI domain you're in and whether you need to share one struct
> >>>> resource across several host bridges in the same domain.
> >>>
> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >>
> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> have in the same domain.  In principle, every host bridge could be in its
> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> xen assumes.
> >
> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >
> > Something like:
> >
> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> > index b1ffebe..a69e529 100644
> > --- a/drivers/pci/xen-pcifront.c
> > +++ b/drivers/pci/xen-pcifront.c
> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                                  unsigned int domain, unsigned int bus)
> >  {
> >         struct pci_bus *b;
> > +       LIST_HEAD(resources);
> >         struct pcifront_sd *sd = NULL;
> >         struct pci_bus_entry *bus_entry = NULL;
> >         int err = 0;
> > +       static struct resource busn_res = {
> > +               .start = 0,
> > +               .end = 255,
> > +               .flags = IORESOURCE_BUS,
> > +       };
> >
> >  #ifndef CONFIG_PCI_DOMAINS
> >         if (domain != 0) {
> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >                 err = -ENOMEM;
> >                 goto err_out;
> >         }
> > +       pci_add_resource(&resources, &ioport_resource);
> > +       pci_add_resource(&resources, &iomem_resource);
> > +       pci_add_resource(&resources, &busn_res);
> >         pcifront_init_sd(sd, domain, bus, pdev);
> >
> >         pci_lock_rescan_remove();
> >
> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> > -                                 &pcifront_bus_ops, sd);
> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> > +                                 &pcifront_bus_ops, sd, &resources);
> >         if (!b) {
> >
> > Bjorn, what do you think about ?
> 
> That seems OK to me.  Probably still wrong, but no worse than it was before.

Interesting. The mechanism for PCI passthrough can either synthesize
and PCI bus number starting at zero (so first device is always 0:0:0.0)
or it can replicate the backend PCI topology. That means you
could have segment values passed in, so: ab:ff:00.1). I've to admin
I hadn't tried the 'physical' replication on an machine with
domains (err, segments).

Is there an git tree with this so I can just try it out?

Thanks.
> 
> >>>>>    pcifront_init_sd(sd, domain, bus, pdev);
> >>>>>
> >>>>>    pci_lock_rescan_remove();
> >>>>>
> >>>>> -  b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >>>>> -                            &pcifront_bus_ops, sd);
> >>>>> +  b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >>>>> +                            &pcifront_bus_ops, sd, &resources);
> >>>>>    if (!b) {
> >>>>>            dev_err(&pdev->xdev->dev,
> >>>>>                    "Error creating PCI Frontend Bus!\n");
> >>>>>            err = -ENOMEM;
> >>>>>            pci_unlock_rescan_remove();
> >>>>> +          pci_free_resource_list(&resources);
> >>>>>            goto err_out;
> >>>>>    }
> >>>>>
> >>>>> @@ -488,7 +494,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >>>>>
> >>>>>    list_add(&bus_entry->list, &pdev->root_buses);
> >>>>>
> >>>>> -  /* pci_scan_bus_parented skips devices which do not have a have
> >>>>> +  /* pci_scan_root_bus skips devices which do not have a
> >>>>>    * devfn=0. The pcifront_scan_bus enumerates all devfn. */
> >>>>>    err = pcifront_scan_bus(pdev, domain, bus, b);
> >>>>>
> >>>>> --
> >>>>> 1.7.1
> >>>>>
> >>>>> --
> >>>>> 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
> >>>>
> >>>> .
> >>>>
> >>>
> >>>
> >>> --
> >>> Thanks!
> >>> Yijing
> >>>
> >>> --
> >>> 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
> >>
> >> .
> >>
> >
> >
> > --
> > Thanks!
> > Yijing
> >
> > --
> > 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

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13 14:01               ` Konrad Rzeszutek Wilk
  (?)
  (?)
@ 2015-03-13 14:26                 ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:26 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
>> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> >>>>> +  pci_add_resource(&resources, &ioport_resource);
>> >>>>> +  pci_add_resource(&resources, &iomem_resource);
>> >>>>> +  pci_add_resource(&resources, &busn_resource);
>> >>>>
>> >>>> Since I don't want to export busn_resource, you might have to allocate your
>> >>>> own struct resource for it here.  And, of course, figure out the details of
>> >>>> which PCI domain you're in and whether you need to share one struct
>> >>>> resource across several host bridges in the same domain.
>> >>>
>> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
>> >>
>> >> That's up to the caller.  Only the platform knows which bridges it wants to
>> >> have in the same domain.  In principle, every host bridge could be in its
>> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> >> some platforms have firmware that assumes otherwise.  I have no idea what
>> >> xen assumes.
>> >
>> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
>> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
>> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>> >
>> > Something like:
>> >
>> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> > index b1ffebe..a69e529 100644
>> > --- a/drivers/pci/xen-pcifront.c
>> > +++ b/drivers/pci/xen-pcifront.c
>> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                                  unsigned int domain, unsigned int bus)
>> >  {
>> >         struct pci_bus *b;
>> > +       LIST_HEAD(resources);
>> >         struct pcifront_sd *sd = NULL;
>> >         struct pci_bus_entry *bus_entry = NULL;
>> >         int err = 0;
>> > +       static struct resource busn_res = {
>> > +               .start = 0,
>> > +               .end = 255,
>> > +               .flags = IORESOURCE_BUS,
>> > +       };
>> >
>> >  #ifndef CONFIG_PCI_DOMAINS
>> >         if (domain != 0) {
>> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                 err = -ENOMEM;
>> >                 goto err_out;
>> >         }
>> > +       pci_add_resource(&resources, &ioport_resource);
>> > +       pci_add_resource(&resources, &iomem_resource);
>> > +       pci_add_resource(&resources, &busn_res);
>> >         pcifront_init_sd(sd, domain, bus, pdev);
>> >
>> >         pci_lock_rescan_remove();
>> >
>> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> > -                                 &pcifront_bus_ops, sd);
>> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> > +                                 &pcifront_bus_ops, sd, &resources);
>> >         if (!b) {
>> >
>> > Bjorn, what do you think about ?
>>
>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>
> Interesting. The mechanism for PCI passthrough can either synthesize
> and PCI bus number starting at zero (so first device is always 0:0:0.0)
> or it can replicate the backend PCI topology. That means you
> could have segment values passed in, so: ab:ff:00.1). I've to admin
> I hadn't tried the 'physical' replication on an machine with
> domains (err, segments).
>
> Is there an git tree with this so I can just try it out?

git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/enumeration-yw6 has similar code (it exports the single
busn_resource and makes xen use it).  That should be functionally
identical to what v4.0-rc1 does.

Yijing hasn't posted the static busn_res proposal above yet, so I
don't have a branch with that in it.

Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 14:26                 ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:26 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
>> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> >>>>> +  pci_add_resource(&resources, &ioport_resource);
>> >>>>> +  pci_add_resource(&resources, &iomem_resource);
>> >>>>> +  pci_add_resource(&resources, &busn_resource);
>> >>>>
>> >>>> Since I don't want to export busn_resource, you might have to allocate your
>> >>>> own struct resource for it here.  And, of course, figure out the details of
>> >>>> which PCI domain you're in and whether you need to share one struct
>> >>>> resource across several host bridges in the same domain.
>> >>>
>> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
>> >>
>> >> That's up to the caller.  Only the platform knows which bridges it wants to
>> >> have in the same domain.  In principle, every host bridge could be in its
>> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> >> some platforms have firmware that assumes otherwise.  I have no idea what
>> >> xen assumes.
>> >
>> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
>> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
>> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>> >
>> > Something like:
>> >
>> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> > index b1ffebe..a69e529 100644
>> > --- a/drivers/pci/xen-pcifront.c
>> > +++ b/drivers/pci/xen-pcifront.c
>> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                                  unsigned int domain, unsigned int bus)
>> >  {
>> >         struct pci_bus *b;
>> > +       LIST_HEAD(resources);
>> >         struct pcifront_sd *sd = NULL;
>> >         struct pci_bus_entry *bus_entry = NULL;
>> >         int err = 0;
>> > +       static struct resource busn_res = {
>> > +               .start = 0,
>> > +               .end = 255,
>> > +               .flags = IORESOURCE_BUS,
>> > +       };
>> >
>> >  #ifndef CONFIG_PCI_DOMAINS
>> >         if (domain != 0) {
>> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                 err = -ENOMEM;
>> >                 goto err_out;
>> >         }
>> > +       pci_add_resource(&resources, &ioport_resource);
>> > +       pci_add_resource(&resources, &iomem_resource);
>> > +       pci_add_resource(&resources, &busn_res);
>> >         pcifront_init_sd(sd, domain, bus, pdev);
>> >
>> >         pci_lock_rescan_remove();
>> >
>> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> > -                                 &pcifront_bus_ops, sd);
>> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> > +                                 &pcifront_bus_ops, sd, &resources);
>> >         if (!b) {
>> >
>> > Bjorn, what do you think about ?
>>
>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>
> Interesting. The mechanism for PCI passthrough can either synthesize
> and PCI bus number starting at zero (so first device is always 0:0:0.0)
> or it can replicate the backend PCI topology. That means you
> could have segment values passed in, so: ab:ff:00.1). I've to admin
> I hadn't tried the 'physical' replication on an machine with
> domains (err, segments).
>
> Is there an git tree with this so I can just try it out?

git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/enumeration-yw6 has similar code (it exports the single
busn_resource and makes xen use it).  That should be functionally
identical to what v4.0-rc1 does.

Yijing hasn't posted the static busn_res proposal above yet, so I
don't have a branch with that in it.

Bjorn

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 14:26                 ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
>> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> >>>>> +  pci_add_resource(&resources, &ioport_resource);
>> >>>>> +  pci_add_resource(&resources, &iomem_resource);
>> >>>>> +  pci_add_resource(&resources, &busn_resource);
>> >>>>
>> >>>> Since I don't want to export busn_resource, you might have to allocate your
>> >>>> own struct resource for it here.  And, of course, figure out the details of
>> >>>> which PCI domain you're in and whether you need to share one struct
>> >>>> resource across several host bridges in the same domain.
>> >>>
>> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
>> >>
>> >> That's up to the caller.  Only the platform knows which bridges it wants to
>> >> have in the same domain.  In principle, every host bridge could be in its
>> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> >> some platforms have firmware that assumes otherwise.  I have no idea what
>> >> xen assumes.
>> >
>> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
>> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
>> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>> >
>> > Something like:
>> >
>> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> > index b1ffebe..a69e529 100644
>> > --- a/drivers/pci/xen-pcifront.c
>> > +++ b/drivers/pci/xen-pcifront.c
>> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                                  unsigned int domain, unsigned int bus)
>> >  {
>> >         struct pci_bus *b;
>> > +       LIST_HEAD(resources);
>> >         struct pcifront_sd *sd = NULL;
>> >         struct pci_bus_entry *bus_entry = NULL;
>> >         int err = 0;
>> > +       static struct resource busn_res = {
>> > +               .start = 0,
>> > +               .end = 255,
>> > +               .flags = IORESOURCE_BUS,
>> > +       };
>> >
>> >  #ifndef CONFIG_PCI_DOMAINS
>> >         if (domain != 0) {
>> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                 err = -ENOMEM;
>> >                 goto err_out;
>> >         }
>> > +       pci_add_resource(&resources, &ioport_resource);
>> > +       pci_add_resource(&resources, &iomem_resource);
>> > +       pci_add_resource(&resources, &busn_res);
>> >         pcifront_init_sd(sd, domain, bus, pdev);
>> >
>> >         pci_lock_rescan_remove();
>> >
>> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> > -                                 &pcifront_bus_ops, sd);
>> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> > +                                 &pcifront_bus_ops, sd, &resources);
>> >         if (!b) {
>> >
>> > Bjorn, what do you think about ?
>>
>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>
> Interesting. The mechanism for PCI passthrough can either synthesize
> and PCI bus number starting at zero (so first device is always 0:0:0.0)
> or it can replicate the backend PCI topology. That means you
> could have segment values passed in, so: ab:ff:00.1). I've to admin
> I hadn't tried the 'physical' replication on an machine with
> domains (err, segments).
>
> Is there an git tree with this so I can just try it out?

git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/enumeration-yw6 has similar code (it exports the single
busn_resource and makes xen use it).  That should be functionally
identical to what v4.0-rc1 does.

Yijing hasn't posted the static busn_res proposal above yet, so I
don't have a branch with that in it.

Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13 14:01               ` Konrad Rzeszutek Wilk
                                 ` (3 preceding siblings ...)
  (?)
@ 2015-03-13 14:26               ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:26 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: linux-m68k, linux-ia64, linux-pci, Yijing Wang, Guan Xuetao,
	Russell King, x86, Geert Uytterhoeven, Benjamin Herrenschmidt,
	xen-devel, Arnd Bergmann, Marc Zyngier, Rusty Russell,
	Thomas Gleixner, Yinghai Lu, linux-arm, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, Davi

On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
>> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> >>>>> +  pci_add_resource(&resources, &ioport_resource);
>> >>>>> +  pci_add_resource(&resources, &iomem_resource);
>> >>>>> +  pci_add_resource(&resources, &busn_resource);
>> >>>>
>> >>>> Since I don't want to export busn_resource, you might have to allocate your
>> >>>> own struct resource for it here.  And, of course, figure out the details of
>> >>>> which PCI domain you're in and whether you need to share one struct
>> >>>> resource across several host bridges in the same domain.
>> >>>
>> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
>> >>
>> >> That's up to the caller.  Only the platform knows which bridges it wants to
>> >> have in the same domain.  In principle, every host bridge could be in its
>> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> >> some platforms have firmware that assumes otherwise.  I have no idea what
>> >> xen assumes.
>> >
>> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
>> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
>> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>> >
>> > Something like:
>> >
>> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> > index b1ffebe..a69e529 100644
>> > --- a/drivers/pci/xen-pcifront.c
>> > +++ b/drivers/pci/xen-pcifront.c
>> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                                  unsigned int domain, unsigned int bus)
>> >  {
>> >         struct pci_bus *b;
>> > +       LIST_HEAD(resources);
>> >         struct pcifront_sd *sd = NULL;
>> >         struct pci_bus_entry *bus_entry = NULL;
>> >         int err = 0;
>> > +       static struct resource busn_res = {
>> > +               .start = 0,
>> > +               .end = 255,
>> > +               .flags = IORESOURCE_BUS,
>> > +       };
>> >
>> >  #ifndef CONFIG_PCI_DOMAINS
>> >         if (domain != 0) {
>> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                 err = -ENOMEM;
>> >                 goto err_out;
>> >         }
>> > +       pci_add_resource(&resources, &ioport_resource);
>> > +       pci_add_resource(&resources, &iomem_resource);
>> > +       pci_add_resource(&resources, &busn_res);
>> >         pcifront_init_sd(sd, domain, bus, pdev);
>> >
>> >         pci_lock_rescan_remove();
>> >
>> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> > -                                 &pcifront_bus_ops, sd);
>> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> > +                                 &pcifront_bus_ops, sd, &resources);
>> >         if (!b) {
>> >
>> > Bjorn, what do you think about ?
>>
>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>
> Interesting. The mechanism for PCI passthrough can either synthesize
> and PCI bus number starting at zero (so first device is always 0:0:0.0)
> or it can replicate the backend PCI topology. That means you
> could have segment values passed in, so: ab:ff:00.1). I've to admin
> I hadn't tried the 'physical' replication on an machine with
> domains (err, segments).
>
> Is there an git tree with this so I can just try it out?

git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/enumeration-yw6 has similar code (it exports the single
busn_resource and makes xen use it).  That should be functionally
identical to what v4.0-rc1 does.

Yijing hasn't posted the static busn_res proposal above yet, so I
don't have a branch with that in it.

Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-13 14:26                 ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:26 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
>> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> >>>>> +  pci_add_resource(&resources, &ioport_resource);
>> >>>>> +  pci_add_resource(&resources, &iomem_resource);
>> >>>>> +  pci_add_resource(&resources, &busn_resource);
>> >>>>
>> >>>> Since I don't want to export busn_resource, you might have to allocate your
>> >>>> own struct resource for it here.  And, of course, figure out the details of
>> >>>> which PCI domain you're in and whether you need to share one struct
>> >>>> resource across several host bridges in the same domain.
>> >>>
>> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
>> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
>> >>
>> >> That's up to the caller.  Only the platform knows which bridges it wants to
>> >> have in the same domain.  In principle, every host bridge could be in its
>> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
>> >> some platforms have firmware that assumes otherwise.  I have no idea what
>> >> xen assumes.
>> >
>> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
>> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
>> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
>> >
>> > Something like:
>> >
>> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> > index b1ffebe..a69e529 100644
>> > --- a/drivers/pci/xen-pcifront.c
>> > +++ b/drivers/pci/xen-pcifront.c
>> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                                  unsigned int domain, unsigned int bus)
>> >  {
>> >         struct pci_bus *b;
>> > +       LIST_HEAD(resources);
>> >         struct pcifront_sd *sd = NULL;
>> >         struct pci_bus_entry *bus_entry = NULL;
>> >         int err = 0;
>> > +       static struct resource busn_res = {
>> > +               .start = 0,
>> > +               .end = 255,
>> > +               .flags = IORESOURCE_BUS,
>> > +       };
>> >
>> >  #ifndef CONFIG_PCI_DOMAINS
>> >         if (domain != 0) {
>> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>> >                 err = -ENOMEM;
>> >                 goto err_out;
>> >         }
>> > +       pci_add_resource(&resources, &ioport_resource);
>> > +       pci_add_resource(&resources, &iomem_resource);
>> > +       pci_add_resource(&resources, &busn_res);
>> >         pcifront_init_sd(sd, domain, bus, pdev);
>> >
>> >         pci_lock_rescan_remove();
>> >
>> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
>> > -                                 &pcifront_bus_ops, sd);
>> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
>> > +                                 &pcifront_bus_ops, sd, &resources);
>> >         if (!b) {
>> >
>> > Bjorn, what do you think about ?
>>
>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>
> Interesting. The mechanism for PCI passthrough can either synthesize
> and PCI bus number starting at zero (so first device is always 0:0:0.0)
> or it can replicate the backend PCI topology. That means you
> could have segment values passed in, so: ab:ff:00.1). I've to admin
> I hadn't tried the 'physical' replication on an machine with
> domains (err, segments).
>
> Is there an git tree with this so I can just try it out?

git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/enumeration-yw6 has similar code (it exports the single
busn_resource and makes xen use it).  That should be functionally
identical to what v4.0-rc1 does.

Yijing hasn't posted the static busn_res proposal above yet, so I
don't have a branch with that in it.

Bjorn

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-13  3:28           ` Yijing Wang
  (?)
  (?)
@ 2015-03-13 14:33             ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:33 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 10:28 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>> It's a nice idea to move this test into the core.  While you're at it, why
>>>> don't you check for any overlap with the bus ranges of existing host
>>>> bridges?  For example, if we're trying to create a new host bridge to
>>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>>> latter conflict but not the former.
>>>
>>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>>> some pci scan would fail which currently scan success.
>>
>> _BBN is not the correct source for the bridge's bus number range.  There's
>> a comment in acpi_pci_root_add() that explains why:
>>
>>   * We need both the start and end of the downstream bus range
>>   * to interpret _CBA (MMCONFIG base address), so it really is
>>   * supposed to be in _CRS.  If we don't find it there, all we
>>   * can do is assume [_BBN-0xFF] or [0-0xFF].
>>
>> A platform SHOULD know the start and and end bus number.  If it doesn't I
>> think it's the platform's responsibility to carve up the bus number range.
>> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
>> we discover another bridge that leads to bus 80.
>
> Currently, if platform does not know the end bus number (not provide the bus resource),
> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
> Also then we could reduce the bus argument which is the same as busn_res->start.
> I would try to provide draft patch, then we could discuss it more clearly.

Without having seen a patch, my inclination is to avoid a flag because
flags change the behavior of the code you call, which makes that code
harder to follow.  Maybe we could require these platforms to
explicitly update the ending bus number after scanning the bus.

Bjorn

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13 14:33             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:33 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 10:28 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>> It's a nice idea to move this test into the core.  While you're at it, why
>>>> don't you check for any overlap with the bus ranges of existing host
>>>> bridges?  For example, if we're trying to create a new host bridge to
>>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>>> latter conflict but not the former.
>>>
>>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>>> some pci scan would fail which currently scan success.
>>
>> _BBN is not the correct source for the bridge's bus number range.  There's
>> a comment in acpi_pci_root_add() that explains why:
>>
>>   * We need both the start and end of the downstream bus range
>>   * to interpret _CBA (MMCONFIG base address), so it really is
>>   * supposed to be in _CRS.  If we don't find it there, all we
>>   * can do is assume [_BBN-0xFF] or [0-0xFF].
>>
>> A platform SHOULD know the start and and end bus number.  If it doesn't I
>> think it's the platform's responsibility to carve up the bus number range.
>> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
>> we discover another bridge that leads to bus 80.
>
> Currently, if platform does not know the end bus number (not provide the bus resource),
> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
> Also then we could reduce the bus argument which is the same as busn_res->start.
> I would try to provide draft patch, then we could discuss it more clearly.

Without having seen a patch, my inclination is to avoid a flag because
flags change the behavior of the code you call, which makes that code
harder to follow.  Maybe we could require these platforms to
explicitly update the ending bus number after scanning the bus.

Bjorn

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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13 14:33             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 12, 2015 at 10:28 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>> It's a nice idea to move this test into the core.  While you're at it, why
>>>> don't you check for any overlap with the bus ranges of existing host
>>>> bridges?  For example, if we're trying to create a new host bridge to
>>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>>> latter conflict but not the former.
>>>
>>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>>> some pci scan would fail which currently scan success.
>>
>> _BBN is not the correct source for the bridge's bus number range.  There's
>> a comment in acpi_pci_root_add() that explains why:
>>
>>   * We need both the start and end of the downstream bus range
>>   * to interpret _CBA (MMCONFIG base address), so it really is
>>   * supposed to be in _CRS.  If we don't find it there, all we
>>   * can do is assume [_BBN-0xFF] or [0-0xFF].
>>
>> A platform SHOULD know the start and and end bus number.  If it doesn't I
>> think it's the platform's responsibility to carve up the bus number range.
>> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
>> we discover another bridge that leads to bus 80.
>
> Currently, if platform does not know the end bus number (not provide the bus resource),
> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
> Also then we could reduce the bus argument which is the same as busn_res->start.
> I would try to provide draft patch, then we could discuss it more clearly.

Without having seen a patch, my inclination is to avoid a flag because
flags change the behavior of the code you call, which makes that code
harder to follow.  Maybe we could require these platforms to
explicitly update the ending bus number after scanning the bus.

Bjorn

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-13 14:33             ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:33 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

On Thu, Mar 12, 2015 at 10:28 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>>>> It's a nice idea to move this test into the core.  While you're at it, why
>>>> don't you check for any overlap with the bus ranges of existing host
>>>> bridges?  For example, if we're trying to create a new host bridge to
>>>> [bus 40-7f], it should conflict with existing bridges to [bus 00-7f]
>>>> as well as to [bus 40-ff].  I think your current patch will detect the
>>>> latter conflict but not the former.
>>>
>>> Now pci host bridge may only know its start bus number, like acpi _BBN provided,
>>> but does not limit the end bus number, Eg. two pci roots report _BBN 0x0 and 0x80,
>>> so we have two bus number resource (0, 0xff) and (0x80, 0xff), if we check it strictly,
>>> some pci scan would fail which currently scan success.
>>
>> _BBN is not the correct source for the bridge's bus number range.  There's
>> a comment in acpi_pci_root_add() that explains why:
>>
>>   * We need both the start and end of the downstream bus range
>>   * to interpret _CBA (MMCONFIG base address), so it really is
>>   * supposed to be in _CRS.  If we don't find it there, all we
>>   * can do is assume [_BBN-0xFF] or [0-0xFF].
>>
>> A platform SHOULD know the start and and end bus number.  If it doesn't I
>> think it's the platform's responsibility to carve up the bus number range.
>> Maybe this can be done by trimming the range of the [bus 00-ff] bridge when
>> we discover another bridge that leads to bus 80.
>
> Currently, if platform does not know the end bus number (not provide the bus resource),
> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
> Also then we could reduce the bus argument which is the same as busn_res->start.
> I would try to provide draft patch, then we could discuss it more clearly.

Without having seen a patch, my inclination is to avoid a flag because
flags change the behavior of the code you call, which makes that code
harder to follow.  Maybe we could require these platforms to
explicitly update the ending bus number after scanning the bus.

Bjorn

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-13 11:31     ` Liviu Dudau
  (?)
  (?)
@ 2015-03-13 14:48       ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:48 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> > ...
>> > Yijing Wang (29):
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
>
> Hi Bjorn and Yijing,
>
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
>
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Huh, sure enough, I missed those, too.  Yijing, when you add those,
can you pull my branch, update the patch, and repost it?  That way
you'll keep my changelog and cleanup updates.

Bjorn

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-13 11:31     ` Liviu Dudau
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-13 14:48     ` Bjorn Helgaas
  -1 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:48 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> > ...
>> > Yijing Wang (29):
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
>
> Hi Bjorn and Yijing,
>
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
>
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Huh, sure enough, I missed those, too.  Yijing, when you add those,
can you pull my branch, update the patch, and repost it?  That way
you'll keep my changelog and cleanup updates.

Bjorn

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13 14:48       ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:48 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> > ...
>> > Yijing Wang (29):
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
>
> Hi Bjorn and Yijing,
>
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
>
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Huh, sure enough, I missed those, too.  Yijing, when you add those,
can you pull my branch, update the patch, and repost it?  That way
you'll keep my changelog and cleanup updates.

Bjorn

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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13 14:48       ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> > ...
>> > Yijing Wang (29):
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
>
> Hi Bjorn and Yijing,
>
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
>
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Huh, sure enough, I missed those, too.  Yijing, when you add those,
can you pull my branch, update the patch, and repost it?  That way
you'll keep my changelog and cleanup updates.

Bjorn

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-13 14:48       ` Bjorn Helgaas
  0 siblings, 0 replies; 513+ messages in thread
From: Bjorn Helgaas @ 2015-03-13 14:48 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>> > ...
>> > Yijing Wang (29):
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>> >   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>> >   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
>
> Hi Bjorn and Yijing,
>
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
>
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Huh, sure enough, I missed those, too.  Yijing, when you add those,
can you pull my branch, update the patch, and repost it?  That way
you'll keep my changelog and cleanup updates.

Bjorn

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-13 14:33             ` Bjorn Helgaas
                                 ` (2 preceding siblings ...)
  (?)
@ 2015-03-16  1:28               ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Currently, if platform does not know the end bus number (not provide the bus resource),
>> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
>> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
>> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
>> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
>> Also then we could reduce the bus argument which is the same as busn_res->start.
>> I would try to provide draft patch, then we could discuss it more clearly.
> 
> Without having seen a patch, my inclination is to avoid a flag because
> flags change the behavior of the code you call, which makes that code
> harder to follow.  Maybe we could require these platforms to
> explicitly update the ending bus number after scanning the bus.

OK, agree, thanks for your suggestion :)

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
  2015-03-13 14:33             ` Bjorn Helgaas
                               ` (2 preceding siblings ...)
  (?)
@ 2015-03-16  1:28             ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Currently, if platform does not know the end bus number (not provide the bus resource),
>> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
>> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
>> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
>> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
>> Also then we could reduce the bus argument which is the same as busn_res->start.
>> I would try to provide draft patch, then we could discuss it more clearly.
> 
> Without having seen a patch, my inclination is to avoid a flag because
> flags change the behavior of the code you call, which makes that code
> harder to follow.  Maybe we could require these platforms to
> explicitly update the ending bus number after scanning the bus.

OK, agree, thanks for your suggestion :)

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-16  1:28               ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Currently, if platform does not know the end bus number (not provide the bus resource),
>> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
>> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
>> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
>> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
>> Also then we could reduce the bus argument which is the same as busn_res->start.
>> I would try to provide draft patch, then we could discuss it more clearly.
> 
> Without having seen a patch, my inclination is to avoid a flag because
> flags change the behavior of the code you call, which makes that code
> harder to follow.  Maybe we could require these platforms to
> explicitly update the ending bus number after scanning the bus.

OK, agree, thanks for your suggestion :)

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-16  1:28               ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:28 UTC (permalink / raw)
  To: linux-arm-kernel

>> Currently, if platform does not know the end bus number (not provide the bus resource),
>> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
>> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
>> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
>> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
>> Also then we could reduce the bus argument which is the same as busn_res->start.
>> I would try to provide draft patch, then we could discuss it more clearly.
> 
> Without having seen a patch, my inclination is to avoid a flag because
> flags change the behavior of the code you call, which makes that code
> harder to follow.  Maybe we could require these platforms to
> explicitly update the ending bus number after scanning the bus.

OK, agree, thanks for your suggestion :)

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-16  1:28               ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Currently, if platform does not know the end bus number (not provide the bus resource),
>> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
>> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
>> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
>> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
>> Also then we could reduce the bus argument which is the same as busn_res->start.
>> I would try to provide draft patch, then we could discuss it more clearly.
> 
> Without having seen a patch, my inclination is to avoid a flag because
> flags change the behavior of the code you call, which makes that code
> harder to follow.  Maybe we could require these platforms to
> explicitly update the ending bus number after scanning the bus.

OK, agree, thanks for your suggestion :)

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges
@ 2015-03-16  1:28               ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> Currently, if platform does not know the end bus number (not provide the bus resource),
>> we will update the max bus number returned by pci_scan_child_bus() to the bus resource end,
>> and I think this is reasonable. I consider to introduce a flag to identify the bus resource
>> which end bus number is undefined, then we could force all pci_scan_root_bus()  etc. callers
>> to provide the bus resource, and we could process the bus resource end according the bus resource flag.
>> Also then we could reduce the bus argument which is the same as busn_res->start.
>> I would try to provide draft patch, then we could discuss it more clearly.
> 
> Without having seen a patch, my inclination is to avoid a flag because
> flags change the behavior of the code you call, which makes that code
> harder to follow.  Maybe we could require these platforms to
> explicitly update the ending bus number after scanning the bus.

OK, agree, thanks for your suggestion :)

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-13 14:48       ` Bjorn Helgaas
                           ` (2 preceding siblings ...)
  (?)
@ 2015-03-16  1:31         ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:31 UTC (permalink / raw)
  To: Bjorn Helgaas, Liviu Dudau
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 22:48, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
>> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>>> ...
>>>> Yijing Wang (29):
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>>
>>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>>> Please rebase your next revision to that.  If there's anything else
>>> non-controversial that we can pull in to chip away at this, let me know.
>>
>> Hi Bjorn and Yijing,
>>
>> Sorry for not providing feedback earlier on this series (or any previous ones),
>> I'm just crawling out from under a rock of doing graphics drivers :)
>>
>> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
>> the users of that function from drivers/pci/host. If Yijing is going to refresh
>> the series it is probably worth starting with adding back the call into pcie-xilinx.c
>> and pci-versatile.c.
> 
> Huh, sure enough, I missed those, too.  Yijing, when you add those,
> can you pull my branch, update the patch, and repost it?  That way
> you'll keep my changelog and cleanup updates.

Sure, I will repost it today.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:31         ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:31 UTC (permalink / raw)
  To: Bjorn Helgaas, Liviu Dudau
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 22:48, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
>> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>>> ...
>>>> Yijing Wang (29):
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>>
>>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>>> Please rebase your next revision to that.  If there's anything else
>>> non-controversial that we can pull in to chip away at this, let me know.
>>
>> Hi Bjorn and Yijing,
>>
>> Sorry for not providing feedback earlier on this series (or any previous ones),
>> I'm just crawling out from under a rock of doing graphics drivers :)
>>
>> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
>> the users of that function from drivers/pci/host. If Yijing is going to refresh
>> the series it is probably worth starting with adding back the call into pcie-xilinx.c
>> and pci-versatile.c.
> 
> Huh, sure enough, I missed those, too.  Yijing, when you add those,
> can you pull my branch, update the patch, and repost it?  That way
> you'll keep my changelog and cleanup updates.

Sure, I will repost it today.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:31         ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:31 UTC (permalink / raw)
  To: Bjorn Helgaas, Liviu Dudau
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 22:48, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
>> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>>> ...
>>>> Yijing Wang (29):
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>>
>>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>>> Please rebase your next revision to that.  If there's anything else
>>> non-controversial that we can pull in to chip away at this, let me know.
>>
>> Hi Bjorn and Yijing,
>>
>> Sorry for not providing feedback earlier on this series (or any previous ones),
>> I'm just crawling out from under a rock of doing graphics drivers :)
>>
>> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
>> the users of that function from drivers/pci/host. If Yijing is going to refresh
>> the series it is probably worth starting with adding back the call into pcie-xilinx.c
>> and pci-versatile.c.
> 
> Huh, sure enough, I missed those, too.  Yijing, when you add those,
> can you pull my branch, update the patch, and repost it?  That way
> you'll keep my changelog and cleanup updates.

Sure, I will repost it today.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:31         ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/13 22:48, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
>> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>>> ...
>>>> Yijing Wang (29):
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>>
>>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>>> Please rebase your next revision to that.  If there's anything else
>>> non-controversial that we can pull in to chip away at this, let me know.
>>
>> Hi Bjorn and Yijing,
>>
>> Sorry for not providing feedback earlier on this series (or any previous ones),
>> I'm just crawling out from under a rock of doing graphics drivers :)
>>
>> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
>> the users of that function from drivers/pci/host. If Yijing is going to refresh
>> the series it is probably worth starting with adding back the call into pcie-xilinx.c
>> and pci-versatile.c.
> 
> Huh, sure enough, I missed those, too.  Yijing, when you add those,
> can you pull my branch, update the patch, and repost it?  That way
> you'll keep my changelog and cleanup updates.

Sure, I will repost it today.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:31         ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:31 UTC (permalink / raw)
  To: Bjorn Helgaas, Liviu Dudau
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 22:48, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 6:31 AM, Liviu Dudau <liviu@dudau.co.uk> wrote:
>> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>>> ...
>>>> Yijing Wang (29):
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>>
>>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>>> Please rebase your next revision to that.  If there's anything else
>>> non-controversial that we can pull in to chip away at this, let me know.
>>
>> Hi Bjorn and Yijing,
>>
>> Sorry for not providing feedback earlier on this series (or any previous ones),
>> I'm just crawling out from under a rock of doing graphics drivers :)
>>
>> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
>> the users of that function from drivers/pci/host. If Yijing is going to refresh
>> the series it is probably worth starting with adding back the call into pcie-xilinx.c
>> and pci-versatile.c.
> 
> Huh, sure enough, I missed those, too.  Yijing, when you add those,
> can you pull my branch, update the patch, and repost it?  That way
> you'll keep my changelog and cleanup updates.

Sure, I will repost it today.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-13 11:31     ` Liviu Dudau
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-16  1:48       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:48 UTC (permalink / raw)
  To: Liviu Dudau, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 19:31, Liviu Dudau wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>> ...
>>> Yijing Wang (29):
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
> 
> Hi Bjorn and Yijing,
> 
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
> 
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
would be called in pci_common_init_dev();

for arm32 pci enumeration:
pci_common_init_dev()
   pcibios_init_hw()
       hw->scan/pci_scan_root_bus()
   pci_bus_size_bridges()
   pci_bus_assign_resources()
   pci_bus_add_devices()

Is there something I have missed ?

Thanks!
Yijing.

> 
> Will try to review (and test) the rest of the series soon.
> 
> Best regards,
> Liviu
> 
>>
>>>   PCI: Export busn_resource to drivers/pci
>>>   PCI: Remove deprecated pci_scan_bus_parented()
>>>   PCI: Combine PCI domain and bus number in u32 arg
>>>   PCI: Pass PCI domain number combined with root bus number
>>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>>   PCI: Save sysdata in pci_host_bridge drvdata
>>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>>     operations
>>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Introduce pci_bus_child_max_busnr()
>>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>>   PCI: Export find_pci_host_bridge() and rename to
>>>     pci_find_host_bridge()
>>>   PCI: Remove platform specific pci_domain_nr()
>>>   PCI: Remove pci_bus_assign_domain_nr()
>>
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-13 11:31     ` Liviu Dudau
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-16  1:48     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:48 UTC (permalink / raw)
  To: Liviu Dudau, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 19:31, Liviu Dudau wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>> ...
>>> Yijing Wang (29):
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
> 
> Hi Bjorn and Yijing,
> 
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
> 
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
would be called in pci_common_init_dev();

for arm32 pci enumeration:
pci_common_init_dev()
   pcibios_init_hw()
       hw->scan/pci_scan_root_bus()
   pci_bus_size_bridges()
   pci_bus_assign_resources()
   pci_bus_add_devices()

Is there something I have missed ?

Thanks!
Yijing.

> 
> Will try to review (and test) the rest of the series soon.
> 
> Best regards,
> Liviu
> 
>>
>>>   PCI: Export busn_resource to drivers/pci
>>>   PCI: Remove deprecated pci_scan_bus_parented()
>>>   PCI: Combine PCI domain and bus number in u32 arg
>>>   PCI: Pass PCI domain number combined with root bus number
>>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>>   PCI: Save sysdata in pci_host_bridge drvdata
>>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>>     operations
>>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Introduce pci_bus_child_max_busnr()
>>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>>   PCI: Export find_pci_host_bridge() and rename to
>>>     pci_find_host_bridge()
>>>   PCI: Remove platform specific pci_domain_nr()
>>>   PCI: Remove pci_bus_assign_domain_nr()
>>
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:48       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:48 UTC (permalink / raw)
  To: Liviu Dudau, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 19:31, Liviu Dudau wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>> ...
>>> Yijing Wang (29):
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
> 
> Hi Bjorn and Yijing,
> 
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
> 
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
would be called in pci_common_init_dev();

for arm32 pci enumeration:
pci_common_init_dev()
   pcibios_init_hw()
       hw->scan/pci_scan_root_bus()
   pci_bus_size_bridges()
   pci_bus_assign_resources()
   pci_bus_add_devices()

Is there something I have missed ?

Thanks!
Yijing.

> 
> Will try to review (and test) the rest of the series soon.
> 
> Best regards,
> Liviu
> 
>>
>>>   PCI: Export busn_resource to drivers/pci
>>>   PCI: Remove deprecated pci_scan_bus_parented()
>>>   PCI: Combine PCI domain and bus number in u32 arg
>>>   PCI: Pass PCI domain number combined with root bus number
>>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>>   PCI: Save sysdata in pci_host_bridge drvdata
>>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>>     operations
>>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Introduce pci_bus_child_max_busnr()
>>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>>   PCI: Export find_pci_host_bridge() and rename to
>>>     pci_find_host_bridge()
>>>   PCI: Remove platform specific pci_domain_nr()
>>>   PCI: Remove pci_bus_assign_domain_nr()
>>
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:48       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:48 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/3/13 19:31, Liviu Dudau wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>> ...
>>> Yijing Wang (29):
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
> 
> Hi Bjorn and Yijing,
> 
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
> 
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
would be called in pci_common_init_dev();

for arm32 pci enumeration:
pci_common_init_dev()
   pcibios_init_hw()
       hw->scan/pci_scan_root_bus()
   pci_bus_size_bridges()
   pci_bus_assign_resources()
   pci_bus_add_devices()

Is there something I have missed ?

Thanks!
Yijing.

> 
> Will try to review (and test) the rest of the series soon.
> 
> Best regards,
> Liviu
> 
>>
>>>   PCI: Export busn_resource to drivers/pci
>>>   PCI: Remove deprecated pci_scan_bus_parented()
>>>   PCI: Combine PCI domain and bus number in u32 arg
>>>   PCI: Pass PCI domain number combined with root bus number
>>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>>   PCI: Save sysdata in pci_host_bridge drvdata
>>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>>     operations
>>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Introduce pci_bus_child_max_busnr()
>>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>>   PCI: Export find_pci_host_bridge() and rename to
>>>     pci_find_host_bridge()
>>>   PCI: Remove platform specific pci_domain_nr()
>>>   PCI: Remove pci_bus_assign_domain_nr()
>>
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:48       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:48 UTC (permalink / raw)
  To: Liviu Dudau, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 19:31, Liviu Dudau wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>> ...
>>> Yijing Wang (29):
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
> 
> Hi Bjorn and Yijing,
> 
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
> 
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
would be called in pci_common_init_dev();

for arm32 pci enumeration:
pci_common_init_dev()
   pcibios_init_hw()
       hw->scan/pci_scan_root_bus()
   pci_bus_size_bridges()
   pci_bus_assign_resources()
   pci_bus_add_devices()

Is there something I have missed ?

Thanks!
Yijing.

> 
> Will try to review (and test) the rest of the series soon.
> 
> Best regards,
> Liviu
> 
>>
>>>   PCI: Export busn_resource to drivers/pci
>>>   PCI: Remove deprecated pci_scan_bus_parented()
>>>   PCI: Combine PCI domain and bus number in u32 arg
>>>   PCI: Pass PCI domain number combined with root bus number
>>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>>   PCI: Save sysdata in pci_host_bridge drvdata
>>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>>     operations
>>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Introduce pci_bus_child_max_busnr()
>>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>>   PCI: Export find_pci_host_bridge() and rename to
>>>     pci_find_host_bridge()
>>>   PCI: Remove platform specific pci_domain_nr()
>>>   PCI: Remove pci_bus_assign_domain_nr()
>>
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-16  1:48       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-16  1:48 UTC (permalink / raw)
  To: Liviu Dudau, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Arnd Bergmann, Geert Uytterhoeven

On 2015/3/13 19:31, Liviu Dudau wrote:
> On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
>> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
>>> ...
>>> Yijing Wang (29):
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
>>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
>>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
>>
>> I put the above patches plus a cleanup patch on my pci/enumeration branch.
>> Please rebase your next revision to that.  If there's anything else
>> non-controversial that we can pull in to chip away at this, let me know.
> 
> Hi Bjorn and Yijing,
> 
> Sorry for not providing feedback earlier on this series (or any previous ones),
> I'm just crawling out from under a rock of doing graphics drivers :)
> 
> The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> the users of that function from drivers/pci/host. If Yijing is going to refresh
> the series it is probably worth starting with adding back the call into pcie-xilinx.c
> and pci-versatile.c.

Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
would be called in pci_common_init_dev();

for arm32 pci enumeration:
pci_common_init_dev()
   pcibios_init_hw()
       hw->scan/pci_scan_root_bus()
   pci_bus_size_bridges()
   pci_bus_assign_resources()
   pci_bus_add_devices()

Is there something I have missed ?

Thanks!
Yijing.

> 
> Will try to review (and test) the rest of the series soon.
> 
> Best regards,
> Liviu
> 
>>
>>>   PCI: Export busn_resource to drivers/pci
>>>   PCI: Remove deprecated pci_scan_bus_parented()
>>>   PCI: Combine PCI domain and bus number in u32 arg
>>>   PCI: Pass PCI domain number combined with root bus number
>>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
>>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
>>>   PCI: Introduce pci_host_bridge_list to manage host bridges
>>>   PCI: Save sysdata in pci_host_bridge drvdata
>>>   PCI: Introduce pci_host_bridge_ops to support host specific
>>>     operations
>>>   PCI: Introduce new scan function pci_scan_host_bridge()
>>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
>>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
>>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Remove weak pcibios_root_bridge_prepare()
>>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
>>>   PCI: Introduce pci_bus_child_max_busnr()
>>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
>>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
>>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
>>>   PCI/designware: Use pci_scan_root_bus() for simplicity
>>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
>>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
>>>   PCI: Export find_pci_host_bridge() and rename to
>>>     pci_find_host_bridge()
>>>   PCI: Remove platform specific pci_domain_nr()
>>>   PCI: Remove pci_bus_assign_domain_nr()
>>
> 


-- 
Thanks!
Yijing


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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:34   ` Yijing Wang
                       ` (4 preceding siblings ...)
  (?)
@ 2015-03-17  5:15     ` Manish Jaggi
  -1 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Richard Henderson, Liviu Dudau,
	Michal Simek, Tony Luck, linux-kernel, Ralf Baechle, Jiang Liu,
	linux-alpha, linuxppc-dev, David S. Miller


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");


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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:34   ` Yijing Wang
                     ` (10 preceding siblings ...)
  (?)
@ 2015-03-17  5:15   ` Manish Jaggi
  -1 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17  5:15     ` Manish Jaggi
  0 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Richard Henderson, Liviu Dudau,
	Michal Simek, Tony Luck, linux-kernel, Ralf Baechle, Jiang Liu,
	linux-alpha, linuxppc-dev, David S. Miller


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");


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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17  5:15     ` Manish Jaggi
  0 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai Lu, linux-arm-kernel, Richard Henderson, Liviu Dudau,
	Michal Simek, Tony Luck, linux-kernel, Ralf Baechle, Jiang Liu,
	linux-alpha, linuxppc-dev, David S. Miller


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17  5:15     ` Manish Jaggi
  0 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Chris Metcalf,
	Paul Mackerras, sparclinux, Guan Xuetao, linux-s390,
	Russell King, x86, Sebastian Ott, Geert Uytterhoeven,
	linux-arm-kernel, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Ivan Kokshaysky, Thomas Gleixner, Yinghai Lu, Gerald Schaefer,
	Richard Henderson, Liviu Dudau, Michal Simek, Tony Luck,
	linux-kernel, Ralf Baechle, David S. Miller, linux-alpha,
	linuxppc-dev, Jiang Liu


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");

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

* [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17  5:15     ` Manish Jaggi
  0 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: linux-arm-kernel


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha at vger.kernel.org
> CC: linux-kernel at vger.kernel.org
> CC: linux-ia64 at vger.kernel.org
> CC: linux-mips at linux-mips.org
> CC: linuxppc-dev at lists.ozlabs.org
> CC: linux-s390 at vger.kernel.org
> CC: linux-sh at vger.kernel.org
> CC: sparclinux at vger.kernel.org
> CC: xen-devel at lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-09  2:34   ` Yijing Wang
                     ` (9 preceding siblings ...)
  (?)
@ 2015-03-17  5:15   ` Manish Jaggi
  -1 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Chris Metcalf,
	Paul Mackerras, sparclinux, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, linux-arm-kernel, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Thomas Gleixner,
	Yinghai Lu


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17  5:15     ` Manish Jaggi
  0 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:15 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, sparclinux,
	Chris Metcalf, Paul Mackerras, Guan Xuetao, linux-s390,
	Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus == NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus == NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");



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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17  5:15     ` Manish Jaggi
  0 siblings, 0 replies; 513+ messages in thread
From: Manish Jaggi @ 2015-03-17  5:27 UTC (permalink / raw)
  To: linux-arm-kernel


On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> Now we could pass PCI domain combined with bus number
> in u32 argu. Because in arm/arm64, PCI domain number
> is assigned by pci_bus_assign_domain_nr(). So we leave
> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> unchanged. A new function pci_host_assign_domain_nr()
> will be introduced for arm/arm64 to assign domain number
> in later patch.
Hi,
I think these changes might not be required. We have made very few 
changes in the xen-pcifront to support PCI passthrough in arm64.
As per xen architecture for a domU only a single pci virtual bus is 
created and all passthrough devices are attached to it.


-manish
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> CC: Matt Turner <mattst88@gmail.com>
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: Michal Simek <monstr@monstr.eu>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Michael Ellerman <mpe@ellerman.id.au>
> CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
> CC: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Chris Metcalf <cmetcalf@ezchip.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: linux-alpha@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: linux-ia64@vger.kernel.org
> CC: linux-mips@linux-mips.org
> CC: linuxppc-dev@lists.ozlabs.org
> CC: linux-s390@vger.kernel.org
> CC: linux-sh@vger.kernel.org
> CC: sparclinux@vger.kernel.org
> CC: xen-devel@lists.xenproject.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/alpha/kernel/pci.c          |    5 +++--
>   arch/alpha/kernel/sys_nautilus.c |    4 ++--
>   arch/ia64/pci/pci.c              |    4 ++--
>   arch/ia64/sn/kernel/io_init.c    |    5 +++--
>   arch/microblaze/pci/pci-common.c |    5 +++--
>   arch/mips/pci/pci.c              |    4 ++--
>   arch/powerpc/kernel/pci-common.c |    5 +++--
>   arch/s390/pci/pci.c              |    5 +++--
>   arch/sh/drivers/pci/pci.c        |    5 +++--
>   arch/sparc/kernel/pci.c          |    5 +++--
>   arch/tile/kernel/pci.c           |    5 +++--
>   arch/tile/kernel/pci_gx.c        |    5 +++--
>   arch/x86/pci/acpi.c              |    7 ++++---
>   arch/x86/pci/common.c            |    3 ++-
>   drivers/pci/xen-pcifront.c       |    5 +++--
>   15 files changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index 5c845ad..deb0a36 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -336,8 +336,9 @@ common_init_pci(void)
>   		pci_add_resource_offset(&resources, hose->mem_space,
>   					hose->mem_space->start);
>   
> -		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
> -					hose, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(hose->index, next_busno),
> +				alpha_mv.pci_ops, hose, &resources);
>   		if (!bus)
>   			continue;
>   		hose->bus = bus;
> diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
> index 700686d..be0bbeb 100644
> --- a/arch/alpha/kernel/sys_nautilus.c
> +++ b/arch/alpha/kernel/sys_nautilus.c
> @@ -206,10 +206,10 @@ nautilus_init_pci(void)
>   	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
>   
>   	/* Scan our single hose.  */
> -	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
> +	bus = pci_scan_bus(PCI_DOMBUS(hose->index, 0),
> +			alpha_mv.pci_ops, hose);
>   	if (!bus)
>   		return;
> -
>   	hose->bus = bus;
>   	pcibios_claim_one_bus(bus);
>   
> diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
> index 48cc657..675749f 100644
> --- a/arch/ia64/pci/pci.c
> +++ b/arch/ia64/pci/pci.c
> @@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   	 * should handle the case here, but it appears that IA64 hasn't
>   	 * such quirk. So we just ignore the case now.
>   	 */
> -	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
> -				   &info->resources);
> +	pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
> +			&pci_root_ops, controller, &info->resources);
>   	if (!pbus) {
>   		pci_free_resource_list(&info->resources);
>   		__release_pci_root_info(info);
> diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
> index 1be65eb..7e0b7f9 100644
> --- a/arch/ia64/sn/kernel/io_init.c
> +++ b/arch/ia64/sn/kernel/io_init.c
> @@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
>   	pci_add_resource_offset(&resources,	&res[1],
>   			prom_bussoft_ptr->bs_legacy_mem);
>   
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(controller->segment, busnum),
> +			&pci_root_ops, controller, &resources);
>    	if (bus = NULL) {
>   		kfree(res);
>   		kfree(controller);
> diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
> index 6d8d173..34a32ec 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)
>   
>   	pcibios_setup_phb_resources(hose, &resources);
>   
> -	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
> -				hose->ops, hose, &resources);
> +	bus = pci_scan_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus = NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   		       hose->global_number);
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 9eb54b5..86f8d2b 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
>   	pci_add_resource_offset(&resources,
>   				hose->mem_resource, hose->mem_offset);
>   	pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	if (!bus)
>   		pci_free_resource_list(&resources);
>   
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 2a525c9..a467aca 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)
>   	pci_add_resource(&resources, &hose->busn);
>   
>   	/* Create an empty bus for the toplevel */
> -	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> -				  hose->ops, hose, &resources);
> +	bus = pci_create_root_bus(hose->parent,
> +			PCI_DOMBUS(hose->global_number, hose->first_busno),
> +			hose->ops, hose, &resources);
>   	if (bus = NULL) {
>   		pr_err("Failed to create bus for PCI domain %04x\n",
>   			hose->global_number);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index a2a7391..20e662f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
>   	if (ret)
>   		return ret;
>   
> -	zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
> -				      zdev, &resources);
> +	zdev->bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(zdev->domain, ZPCI_BUS_NR), &pci_root_ops,
> +			zdev, &resources);
>   	if (!zdev->bus) {
>   		zpci_cleanup_bus_resources(zdev);
>   		return -EIO;
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index efc1051..116f80f 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
>   		pci_add_resource_offset(&resources, res, offset);
>   	}
>   
> -	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
> -				&resources);
> +	bus = pci_scan_root_bus(NULL,
> +			PCI_DOMBUS(hose->index, next_busno),
> +			hose->pci_ops, hose, &resources);
>   	hose->bus = bus;
>   
>   	need_domain_info = need_domain_info || hose->index;
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index 9ce5afe..838fe1e 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   	pbm->busn.end	= pbm->pci_last_busno;
>   	pbm->busn.flags	= IORESOURCE_BUS;
>   	pci_add_resource(&resources, &pbm->busn);
> -	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -				  pbm, &resources);
> +	bus = pci_create_root_bus(parent,
> +			PCI_DOMBUS(pbm->index, pbm->pci_first_busno),
> +			pbm->pci_ops, pbm, &resources);
>   	if (!bus) {
>   		printk(KERN_ERR "Failed to create bus for %s\n",
>   		       node->full_name);
> diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
> index 9475a74..25b0d9b 100644
> --- a/arch/tile/kernel/pci.c
> +++ b/arch/tile/kernel/pci.c
> @@ -306,8 +306,9 @@ int __init pcibios_init(void)
>   
>   			pci_add_resource(&resources, &ioport_resource);
>   			pci_add_resource(&resources, &iomem_resource);
> -			bus = pci_scan_root_bus(NULL, 0, controller->ops,
> -						controller, &resources);
> +			bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, 0),
> +				controller->ops, controller, &resources);
>   			controller->root_bus = bus;
>   			controller->last_busno = bus->busn_res.end;
>   		}
> diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
> index b1df847..f6f41f3 100644
> --- a/arch/tile/kernel/pci_gx.c
> +++ b/arch/tile/kernel/pci_gx.c
> @@ -881,8 +881,9 @@ int __init pcibios_init(void)
>   					controller->mem_offset);
>   		pci_add_resource(&resources, &controller->io_space);
>   		controller->first_busno = next_busno;
> -		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
> -					controller, &resources);
> +		bus = pci_scan_root_bus(NULL,
> +				PCI_DOMBUS(controller->index, next_busno),
> +				controller->ops, controller, &resources);
>   		controller->root_bus = bus;
>   		next_busno = bus->busn_res.end + 1;
>   	}
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 6ac2738..ad0e926 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -424,9 +424,10 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>   		}
>   
>   		if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
> -				    (u8)root->secondary.end, root->mcfg_addr))
> -			bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
> -						  sd, &resources);
> +				(u8)root->secondary.end, root->mcfg_addr))
> +			bus = pci_create_root_bus(NULL,
> +				PCI_DOMBUS(domain, busnum), &pci_root_ops,
> +				sd, &resources);
>   
>   		if (bus) {
>   			pci_scan_child_bus(bus);
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index 0cbc723..0160280 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum)
>   	sd->node = x86_pci_root_bus_node(busnum);
>   	x86_pci_root_bus_resources(busnum, &resources);
>   	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	bus = pci_scan_root_bus(NULL, PCI_DOMBUS(0, busnum),
> +			&pci_root_ops, sd, &resources);
>   	if (!bus) {
>   		pci_free_resource_list(&resources);
>   		kfree(sd);
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 9e7c28b..af6144a 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -479,8 +479,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
>   
>   	pci_lock_rescan_remove();
>   
> -	b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> -				  &pcifront_bus_ops, sd, &resources);
> +	b = pci_scan_root_bus(&pdev->xdev->dev,
> +			PCI_DOMBUS(sd->domain, bus),
> +			&pcifront_bus_ops, sd, &resources);
>   	if (!b) {
>   		dev_err(&pdev->xdev->dev,
>   			"Error creating PCI Frontend Bus!\n");


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-16  1:48       ` Yijing Wang
  (?)
@ 2015-03-17 10:55         ` Liviu Dudau
  -1 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-17 10:55 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Bjorn Helgaas, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm-kernel, Russell King, x86,
	Thomas Gleixner, Benjamin Herrenschmidt, Rusty Russell,
	Tony Luck, linux-ia64, David S. Miller, Guan Xuetao, linux-alpha,
	linux-m68k, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 16, 2015 at 09:48:14AM +0800, Yijing Wang wrote:
> On 2015/3/13 19:31, Liviu Dudau wrote:
> > On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> >> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> >>> ...
> >>> Yijing Wang (29):
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> >>
> >> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> >> Please rebase your next revision to that.  If there's anything else
> >> non-controversial that we can pull in to chip away at this, let me know.
> > 
> > Hi Bjorn and Yijing,
> > 
> > Sorry for not providing feedback earlier on this series (or any previous ones),
> > I'm just crawling out from under a rock of doing graphics drivers :)
> > 
> > The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> > the users of that function from drivers/pci/host. If Yijing is going to refresh
> > the series it is probably worth starting with adding back the call into pcie-xilinx.c
> > and pci-versatile.c.
> 
> Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
> But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
> pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
> would be called in pci_common_init_dev();
> 
> for arm32 pci enumeration:
> pci_common_init_dev()
>    pcibios_init_hw()
>        hw->scan/pci_scan_root_bus()
>    pci_bus_size_bridges()
>    pci_bus_assign_resources()
>    pci_bus_add_devices()
> 
> Is there something I have missed ?

No, you were right. I was under impression that pcie-xilinx.c has broken away from arch/arm dependencies.

Best regards,
Liviu

> 
> Thanks!
> Yijing.
> 
> > 
> > Will try to review (and test) the rest of the series soon.
> > 
> > Best regards,
> > Liviu
> > 
> >>
> >>>   PCI: Export busn_resource to drivers/pci
> >>>   PCI: Remove deprecated pci_scan_bus_parented()
> >>>   PCI: Combine PCI domain and bus number in u32 arg
> >>>   PCI: Pass PCI domain number combined with root bus number
> >>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >>>   PCI: Introduce pci_host_bridge_list to manage host bridges
> >>>   PCI: Save sysdata in pci_host_bridge drvdata
> >>>   PCI: Introduce pci_host_bridge_ops to support host specific
> >>>     operations
> >>>   PCI: Introduce new scan function pci_scan_host_bridge()
> >>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Remove weak pcibios_root_bridge_prepare()
> >>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Introduce pci_bus_child_max_busnr()
> >>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >>>   PCI/designware: Use pci_scan_root_bus() for simplicity
> >>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >>>   PCI: Export find_pci_host_bridge() and rename to
> >>>     pci_find_host_bridge()
> >>>   PCI: Remove platform specific pci_domain_nr()
> >>>   PCI: Remove pci_bus_assign_domain_nr()
> >>
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...


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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
  2015-03-16  1:48       ` Yijing Wang
                         ` (4 preceding siblings ...)
  (?)
@ 2015-03-17 10:55       ` Liviu Dudau
  -1 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-17 10:55 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Bjorn Helgaas, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm-kernel, Russell King, x86,
	Thomas Gleixner, Benjamin Herrenschmidt, Rusty Russell,
	Tony Luck, linux-ia64, David S. Miller, Guan Xuetao, linux-alpha,
	linux-m68k, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 16, 2015 at 09:48:14AM +0800, Yijing Wang wrote:
> On 2015/3/13 19:31, Liviu Dudau wrote:
> > On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> >> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> >>> ...
> >>> Yijing Wang (29):
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> >>
> >> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> >> Please rebase your next revision to that.  If there's anything else
> >> non-controversial that we can pull in to chip away at this, let me know.
> > 
> > Hi Bjorn and Yijing,
> > 
> > Sorry for not providing feedback earlier on this series (or any previous ones),
> > I'm just crawling out from under a rock of doing graphics drivers :)
> > 
> > The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> > the users of that function from drivers/pci/host. If Yijing is going to refresh
> > the series it is probably worth starting with adding back the call into pcie-xilinx.c
> > and pci-versatile.c.
> 
> Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
> But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
> pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
> would be called in pci_common_init_dev();
> 
> for arm32 pci enumeration:
> pci_common_init_dev()
>    pcibios_init_hw()
>        hw->scan/pci_scan_root_bus()
>    pci_bus_size_bridges()
>    pci_bus_assign_resources()
>    pci_bus_add_devices()
> 
> Is there something I have missed ?

No, you were right. I was under impression that pcie-xilinx.c has broken away from arch/arm dependencies.

Best regards,
Liviu

> 
> Thanks!
> Yijing.
> 
> > 
> > Will try to review (and test) the rest of the series soon.
> > 
> > Best regards,
> > Liviu
> > 
> >>
> >>>   PCI: Export busn_resource to drivers/pci
> >>>   PCI: Remove deprecated pci_scan_bus_parented()
> >>>   PCI: Combine PCI domain and bus number in u32 arg
> >>>   PCI: Pass PCI domain number combined with root bus number
> >>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >>>   PCI: Introduce pci_host_bridge_list to manage host bridges
> >>>   PCI: Save sysdata in pci_host_bridge drvdata
> >>>   PCI: Introduce pci_host_bridge_ops to support host specific
> >>>     operations
> >>>   PCI: Introduce new scan function pci_scan_host_bridge()
> >>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Remove weak pcibios_root_bridge_prepare()
> >>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Introduce pci_bus_child_max_busnr()
> >>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >>>   PCI/designware: Use pci_scan_root_bus() for simplicity
> >>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >>>   PCI: Export find_pci_host_bridge() and rename to
> >>>     pci_find_host_bridge()
> >>>   PCI: Remove platform specific pci_domain_nr()
> >>>   PCI: Remove pci_bus_assign_domain_nr()
> >>
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...

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

* Re: [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-17 10:55         ` Liviu Dudau
  0 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-17 10:55 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Bjorn Helgaas, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm-kernel, Russell King, x86,
	Thomas Gleixner, Benjamin Herrenschmidt, Rusty Russell,
	Tony Luck, linux-ia64, David S. Miller, Guan Xuetao, linux-alpha,
	linux-m68k, Arnd Bergmann, Geert Uytterhoeven

On Mon, Mar 16, 2015 at 09:48:14AM +0800, Yijing Wang wrote:
> On 2015/3/13 19:31, Liviu Dudau wrote:
> > On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> >> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> >>> ...
> >>> Yijing Wang (29):
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> >>
> >> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> >> Please rebase your next revision to that.  If there's anything else
> >> non-controversial that we can pull in to chip away at this, let me know.
> > 
> > Hi Bjorn and Yijing,
> > 
> > Sorry for not providing feedback earlier on this series (or any previous ones),
> > I'm just crawling out from under a rock of doing graphics drivers :)
> > 
> > The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> > the users of that function from drivers/pci/host. If Yijing is going to refresh
> > the series it is probably worth starting with adding back the call into pcie-xilinx.c
> > and pci-versatile.c.
> 
> Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
> But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
> pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
> would be called in pci_common_init_dev();
> 
> for arm32 pci enumeration:
> pci_common_init_dev()
>    pcibios_init_hw()
>        hw->scan/pci_scan_root_bus()
>    pci_bus_size_bridges()
>    pci_bus_assign_resources()
>    pci_bus_add_devices()
> 
> Is there something I have missed ?

No, you were right. I was under impression that pcie-xilinx.c has broken away from arch/arm dependencies.

Best regards,
Liviu

> 
> Thanks!
> Yijing.
> 
> > 
> > Will try to review (and test) the rest of the series soon.
> > 
> > Best regards,
> > Liviu
> > 
> >>
> >>>   PCI: Export busn_resource to drivers/pci
> >>>   PCI: Remove deprecated pci_scan_bus_parented()
> >>>   PCI: Combine PCI domain and bus number in u32 arg
> >>>   PCI: Pass PCI domain number combined with root bus number
> >>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >>>   PCI: Introduce pci_host_bridge_list to manage host bridges
> >>>   PCI: Save sysdata in pci_host_bridge drvdata
> >>>   PCI: Introduce pci_host_bridge_ops to support host specific
> >>>     operations
> >>>   PCI: Introduce new scan function pci_scan_host_bridge()
> >>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Remove weak pcibios_root_bridge_prepare()
> >>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Introduce pci_bus_child_max_busnr()
> >>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >>>   PCI/designware: Use pci_scan_root_bus() for simplicity
> >>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >>>   PCI: Export find_pci_host_bridge() and rename to
> >>>     pci_find_host_bridge()
> >>>   PCI: Remove platform specific pci_domain_nr()
> >>>   PCI: Remove pci_bus_assign_domain_nr()
> >>
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...


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

* [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge
@ 2015-03-17 10:55         ` Liviu Dudau
  0 siblings, 0 replies; 513+ messages in thread
From: Liviu Dudau @ 2015-03-17 10:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 16, 2015 at 09:48:14AM +0800, Yijing Wang wrote:
> On 2015/3/13 19:31, Liviu Dudau wrote:
> > On Thu, Mar 12, 2015 at 04:23:06PM -0500, Bjorn Helgaas wrote:
> >> On Mon, Mar 09, 2015 at 10:33:57AM +0800, Yijing Wang wrote:
> >>> ...
> >>> Yijing Wang (29):
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
> >>>   PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
> >>>   sparc/PCI: Claim bus resources before pci_bus_add_devices()
> >>
> >> I put the above patches plus a cleanup patch on my pci/enumeration branch.
> >> Please rebase your next revision to that.  If there's anything else
> >> non-controversial that we can pull in to chip away at this, let me know.
> > 
> > Hi Bjorn and Yijing,
> > 
> > Sorry for not providing feedback earlier on this series (or any previous ones),
> > I'm just crawling out from under a rock of doing graphics drivers :)
> > 
> > The patch ripping out pci_bus_add_devices() from pci_scan_root_bus() misses out
> > the users of that function from drivers/pci/host. If Yijing is going to refresh
> > the series it is probably worth starting with adding back the call into pcie-xilinx.c
> > and pci-versatile.c.
> 
> Hi Liviu, thanks for your comment. I would add pci_bus_add_devices() for pci-versatile.c,
> But for pcie-xilinx.c and other host drivers used for arm32, we do not need to add
> pci_bus_add_devices() for them, because in arm32 pci enumeration, another pci_bus_add_devices()
> would be called in pci_common_init_dev();
> 
> for arm32 pci enumeration:
> pci_common_init_dev()
>    pcibios_init_hw()
>        hw->scan/pci_scan_root_bus()
>    pci_bus_size_bridges()
>    pci_bus_assign_resources()
>    pci_bus_add_devices()
> 
> Is there something I have missed ?

No, you were right. I was under impression that pcie-xilinx.c has broken away from arch/arm dependencies.

Best regards,
Liviu

> 
> Thanks!
> Yijing.
> 
> > 
> > Will try to review (and test) the rest of the series soon.
> > 
> > Best regards,
> > Liviu
> > 
> >>
> >>>   PCI: Export busn_resource to drivers/pci
> >>>   PCI: Remove deprecated pci_scan_bus_parented()
> >>>   PCI: Combine PCI domain and bus number in u32 arg
> >>>   PCI: Pass PCI domain number combined with root bus number
> >>>   PCI: Introduce pci_host_assign_domain_nr() to assign domain
> >>>   PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
> >>>   PCI: Introduce pci_host_bridge_list to manage host bridges
> >>>   PCI: Save sysdata in pci_host_bridge drvdata
> >>>   PCI: Introduce pci_host_bridge_ops to support host specific
> >>>     operations
> >>>   PCI: Introduce new scan function pci_scan_host_bridge()
> >>>   x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
> >>>   powerpc/pci: Rename pcibios_root_bridge_prepare()
> >>>   powerpc/pci: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Remove weak pcibios_root_bridge_prepare()
> >>>   sparc/PCI: Use pci_scan_host_bridge() for simplicity
> >>>   PCI: Introduce pci_bus_child_max_busnr()
> >>>   parisc/PCI: Use pci_scan_root_bus() for simplicity
> >>>   PCI/mvebu: Use pci_common_init_dev() to simplify code
> >>>   PCI/tegra: Remove redundant tegra_pcie_scan_bus()
> >>>   PCI/designware: Use pci_scan_root_bus() for simplicity
> >>>   PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
> >>>   PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
> >>>   PCI: Export find_pci_host_bridge() and rename to
> >>>     pci_find_host_bridge()
> >>>   PCI: Remove platform specific pci_domain_nr()
> >>>   PCI: Remove pci_bus_assign_domain_nr()
> >>
> > 
> 
> 
> -- 
> Thanks!
> Yijing
> 
> 

-- 
-------------------
   .oooO
   (   )
    \ (  Oooo.
     \_) (   )
          ) /
         (_/

 One small step
   for me ...

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-17  5:15     ` Manish Jaggi
                         ` (4 preceding siblings ...)
  (?)
@ 2015-03-17 14:05       ` Ian Campbell
  -1 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.


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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17 14:05       ` Ian Campbell
  0 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: Yijing Wang, Bjorn Helgaas, linux-mips, linux-ia64, linux-sh,
	linux-pci, Chris Metcalf, Paul Mackerras, sparclinux,
	Guan Xuetao, linux-s390, Russell King, Michael Ellerman, x86,
	Sebastian Ott, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Ivan Kokshaysky, Thomas Gleixner, Yinghai Lu, Gerald Schaefer,
	Richard Henderson, Liviu Dudau, Michal Simek, Tony Luck,
	linux-kernel, Ralf Baechle, David S. Miller, linux-alpha,
	linuxppc-dev, Jiang Liu

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.


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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-17  5:15     ` Manish Jaggi
                       ` (6 preceding siblings ...)
  (?)
@ 2015-03-17 14:05     ` Ian Campbell
  -1 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: Yijing Wang, Bjorn Helgaas, linux-mips, linux-ia64, linux-sh,
	linux-pci, Chris Metcalf, Paul Mackerras, sparclinux,
	Guan Xuetao, linux-s390, Russell King, Michael Ellerman, x86,
	Sebastian Ott, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k, I

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17 14:05       ` Ian Campbell
  0 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: Yijing Wang, Bjorn Helgaas, linux-mips, linux-ia64, linux-sh,
	linux-pci, Chris Metcalf, Paul Mackerras, sparclinux,
	Guan Xuetao, linux-s390, Russell King, Michael Ellerman, x86,
	Sebastian Ott, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Ivan Kokshaysky, Thomas Gleixner, Yinghai Lu, Gerald Schaefer,
	Richard Henderson, Liviu Dudau, Michal Simek, Tony Luck,
	linux-kernel, Ralf Baechle, David S. Miller, linux-alpha,
	linuxppc-dev, Jiang Liu

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.


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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17 14:05       ` Ian Campbell
  0 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: Yijing Wang, Bjorn Helgaas, linux-mips, linux-ia64, linux-sh,
	linux-pci, Chris Metcalf, Paul Mackerras, sparclinux,
	Guan Xuetao, linux-s390, Russell King, Michael Ellerman, x86,
	Sebastian Ott, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Ivan Kokshaysky, Thomas Gleixner, Yinghai Lu, Gerald Schaefer,
	Richard Henderson, Liviu Dudau, Michal Simek, Tony Luck,
	linux-kernel, Ralf Baechle, David S. Miller, linux-alpha,
	linuxppc-dev, Jiang Liu

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17 14:05       ` Ian Campbell
  0 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Yijing Wang,
	Chris Metcalf, Paul Mackerras, sparclinux, Guan Xuetao,
	linux-s390, Russell King, x86, Sebastian Ott, Geert Uytterhoeven,
	Gerald Schaefer, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k,
	Ivan Kokshaysky, Bjorn Helgaas, Thomas Gleixner, Yinghai Lu,
	linux-arm-kernel, Richard Henderson, Liviu Dudau, Michal Simek,
	Tony Luck, linux-kernel, Ralf Baechle, Jiang Liu, linux-alpha,
	linuxppc-dev, David S. Miller

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.

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

* [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17 14:05       ` Ian Campbell
  0 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-17  5:15     ` Manish Jaggi
                       ` (7 preceding siblings ...)
  (?)
@ 2015-03-17 14:05     ` Ian Campbell
  -1 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: linux-mips, linux-ia64, linux-sh, linux-pci, Yijing Wang,
	Chris Metcalf, Paul Mackerras, sparclinux, Guan Xuetao,
	linux-s390, Russell King, Michael Ellerman, x86, Sebastian Ott,
	Geert Uytterhoeven, Gerald Schaefer, Benjamin Herrenschmidt,
	xen-devel, Matt Turner, Fenghua Yu, Arnd Bergmann, Marc Zyngier,
	Rusty Russell, linux-m68k, Ivan Kokshaysky, Bjorn

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.

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

* Re: [Xen-devel] [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
@ 2015-03-17 14:05       ` Ian Campbell
  0 siblings, 0 replies; 513+ messages in thread
From: Ian Campbell @ 2015-03-17 14:05 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: Yijing Wang, Bjorn Helgaas, linux-mips, linux-ia64, linux-sh,
	linux-pci, Chris Metcalf, Paul Mackerras, sparclinux,
	Guan Xuetao, linux-s390, Russell King, Michael Ellerman, x86,
	Sebastian Ott, Geert Uytterhoeven, linux-arm-kernel,
	Benjamin Herrenschmidt, xen-devel, Matt Turner, Fenghua Yu,
	Arnd Bergmann, Marc Zyngier, Rusty Russell, linux-m68k, I

On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
> > Now we could pass PCI domain combined with bus number
> > in u32 argu. Because in arm/arm64, PCI domain number
> > is assigned by pci_bus_assign_domain_nr(). So we leave
> > pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
> > unchanged. A new function pci_host_assign_domain_nr()
> > will be introduced for arm/arm64 to assign domain number
> > in later patch.
> Hi,
> I think these changes might not be required. We have made very few 
> changes in the xen-pcifront to support PCI passthrough in arm64.
> As per xen architecture for a domU only a single pci virtual bus is 
> created and all passthrough devices are attached to it.

I guess you are only talking about the changes to xen-pcifront.c?
Otherwise you are ignoring the dom0 case which is exposed to the real
set of PCI root complexes and anyway I'm not sure how "not needed for
Xen domU" translates into not required, since it is clearly required for
other systems.

Strictly speaking the Xen pciif protocol does support multiple buses,
it's just that the tools, and perhaps kernels, have not yet felt any
need to actually make use of that.

There doesn't seem to be any harm in updating pcifront to follow this
generic API change.

Ian.


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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-17 14:05       ` Ian Campbell
                         ` (5 preceding siblings ...)
  (?)
@ 2015-03-18  4:26       ` Manish Jaggi
  2015-03-18  5:56         ` Yijing Wang
  -1 siblings, 1 reply; 513+ messages in thread
From: Manish Jaggi @ 2015-03-18  4:26 UTC (permalink / raw)
  To: Ian Campbell, xen-devel, Yijing Wang


On Tuesday 17 March 2015 07:35 PM, Ian Campbell wrote:
> On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
>> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
>>> Now we could pass PCI domain combined with bus number
>>> in u32 argu. Because in arm/arm64, PCI domain number
>>> is assigned by pci_bus_assign_domain_nr(). So we leave
>>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>>> unchanged. A new function pci_host_assign_domain_nr()
>>> will be introduced for arm/arm64 to assign domain number
>>> in later patch.
>> Hi,
>> I think these changes might not be required. We have made very few
>> changes in the xen-pcifront to support PCI passthrough in arm64.
>> As per xen architecture for a domU only a single pci virtual bus is
>> created and all passthrough devices are attached to it.
> I guess you are only talking about the changes to xen-pcifront.c?
> Otherwise you are ignoring the dom0 case which is exposed to the real
> set of PCI root complexes and anyway I'm not sure how "not needed for
> Xen domU" translates into not required, since it is clearly required for
> other systems.
>
> Strictly speaking the Xen pciif protocol does support multiple buses,
> it's just that the tools, and perhaps kernels, have not yet felt any
> need to actually make use of that.
>
> There doesn't seem to be any harm in updating pcifront to follow this
> generic API change.
ok.

One side question, the function

  pci_host_assign_domain_nr()

which would be introduced in later patch, does it appear to be doing the 
same binding which we are trying to implement via a pci_host_bridge add 
hypercall.

>
> Ian.
>

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

* Re: [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number
  2015-03-18  4:26       ` Manish Jaggi
@ 2015-03-18  5:56         ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-18  5:56 UTC (permalink / raw)
  To: Manish Jaggi, Ian Campbell, xen-devel

On 2015/3/18 12:26, Manish Jaggi wrote:
> 
> On Tuesday 17 March 2015 07:35 PM, Ian Campbell wrote:
>> On Tue, 2015-03-17 at 10:45 +0530, Manish Jaggi wrote:
>>> On Monday 09 March 2015 08:04 AM, Yijing Wang wrote:
>>>> Now we could pass PCI domain combined with bus number
>>>> in u32 argu. Because in arm/arm64, PCI domain number
>>>> is assigned by pci_bus_assign_domain_nr(). So we leave
>>>> pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
>>>> unchanged. A new function pci_host_assign_domain_nr()
>>>> will be introduced for arm/arm64 to assign domain number
>>>> in later patch.
>>> Hi,
>>> I think these changes might not be required. We have made very few
>>> changes in the xen-pcifront to support PCI passthrough in arm64.
>>> As per xen architecture for a domU only a single pci virtual bus is
>>> created and all passthrough devices are attached to it.
>> I guess you are only talking about the changes to xen-pcifront.c?
>> Otherwise you are ignoring the dom0 case which is exposed to the real
>> set of PCI root complexes and anyway I'm not sure how "not needed for
>> Xen domU" translates into not required, since it is clearly required for
>> other systems.
>>
>> Strictly speaking the Xen pciif protocol does support multiple buses,
>> it's just that the tools, and perhaps kernels, have not yet felt any
>> need to actually make use of that.
>>
>> There doesn't seem to be any harm in updating pcifront to follow this
>> generic API change.
> ok.
> 
> One side question, the function
> 
>  pci_host_assign_domain_nr()
> 
> which would be introduced in later patch, does it appear to be doing the same binding which we are trying to implement via a pci_host_bridge add hypercall.

pci_host_assign_domain_nr() will be called only when CONFIG_PCI_DOMAINS_GENERIC enabled, now mostly be used in arm/arm64.

Thanks!
Yijing.

> 
>>
>> Ian.
>>
> 
> 
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-09  2:34   ` Yijing Wang
                       ` (2 preceding siblings ...)
  (?)
@ 2015-03-21 23:21     ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 513+ messages in thread
From: Suravee Suthikulpanit @ 2015-03-21 23:21 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven



On 3/8/15 21:34, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>   drivers/pci/pci.h         |    3 +
>   drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>   include/linux/pci.h       |    1 +
>   4 files changed, 109 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>
>   #include "pci.h"
>
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */
> +	pci_host_assign_domain_nr(host);

At this point, host->dev.parent has not been assigned. However, when 
calling pci_host_assign_domain_nr(host), it calls 
pci_assign_domain_nr(host->dev.parent), which uses parent->of_node 
directly w/o checking if parent is NULL. This ended up causing NULL 
pointer exception when I do the test.

I think we need to moveo host->dev.parent = parent before calling 
pci_host_assign_domain_nr(host).

Thanks,

Suravee

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-21 23:21     ` Suravee Suthikulpanit
  0 siblings, 0 replies; 513+ messages in thread
From: Suravee Suthikulpanit @ 2015-03-21 23:21 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven



On 3/8/15 21:34, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>   drivers/pci/pci.h         |    3 +
>   drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>   include/linux/pci.h       |    1 +
>   4 files changed, 109 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>
>   #include "pci.h"
>
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */
> +	pci_host_assign_domain_nr(host);

At this point, host->dev.parent has not been assigned. However, when 
calling pci_host_assign_domain_nr(host), it calls 
pci_assign_domain_nr(host->dev.parent), which uses parent->of_node 
directly w/o checking if parent is NULL. This ended up causing NULL 
pointer exception when I do the test.

I think we need to moveo host->dev.parent = parent before calling 
pci_host_assign_domain_nr(host).

Thanks,

Suravee

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-21 23:21     ` Suravee Suthikulpanit
  0 siblings, 0 replies; 513+ messages in thread
From: Suravee Suthikulpanit @ 2015-03-21 23:21 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven



On 3/8/15 21:34, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>   drivers/pci/pci.h         |    3 +
>   drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>   include/linux/pci.h       |    1 +
>   4 files changed, 109 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>
>   #include "pci.h"
>
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */
> +	pci_host_assign_domain_nr(host);

At this point, host->dev.parent has not been assigned. However, when 
calling pci_host_assign_domain_nr(host), it calls 
pci_assign_domain_nr(host->dev.parent), which uses parent->of_node 
directly w/o checking if parent is NULL. This ended up causing NULL 
pointer exception when I do the test.

I think we need to moveo host->dev.parent = parent before calling 
pci_host_assign_domain_nr(host).

Thanks,

Suravee

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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-21 23:21     ` Suravee Suthikulpanit
  0 siblings, 0 replies; 513+ messages in thread
From: Suravee Suthikulpanit @ 2015-03-21 23:21 UTC (permalink / raw)
  To: linux-arm-kernel



On 3/8/15 21:34, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>   drivers/pci/pci.h         |    3 +
>   drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>   include/linux/pci.h       |    1 +
>   4 files changed, 109 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>
>   #include "pci.h"
>
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */
> +	pci_host_assign_domain_nr(host);

At this point, host->dev.parent has not been assigned. However, when 
calling pci_host_assign_domain_nr(host), it calls 
pci_assign_domain_nr(host->dev.parent), which uses parent->of_node 
directly w/o checking if parent is NULL. This ended up causing NULL 
pointer exception when I do the test.

I think we need to moveo host->dev.parent = parent before calling 
pci_host_assign_domain_nr(host).

Thanks,

Suravee

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-21 23:21     ` Suravee Suthikulpanit
  0 siblings, 0 replies; 513+ messages in thread
From: Suravee Suthikulpanit @ 2015-03-21 23:21 UTC (permalink / raw)
  To: Yijing Wang, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven



On 3/8/15 21:34, Yijing Wang wrote:
> This patch separate pci_host_bridge creation out
> of pci_create_root_bus(), and try to make a generic
> pci_host_bridge, then we could place generic PCI
> infos like domain number in it. Also Ripping out
> pci_host_bridge creation from pci_create_root_bus()
> make code more better readability. Further more,
> we could use the generic pci_host_bridge to hold
> host bridge specific operations like
> pcibios_root_bridge_prepare(). The changes are
> transparent to platform host bridge drivers.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   drivers/pci/host-bridge.c |   55 ++++++++++++++++++++++
>   drivers/pci/pci.h         |    3 +
>   drivers/pci/probe.c       |  114 ++++++++++++++++++++-------------------------
>   include/linux/pci.h       |    1 +
>   4 files changed, 109 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 39b2dbe..3bd45e7 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -8,6 +8,61 @@
>
>   #include "pci.h"
>
> +static void pci_release_host_bridge_dev(struct device *dev)
> +{
> +	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> +
> +	if (bridge->release_fn)
> +		bridge->release_fn(bridge);
> +
> +	pci_free_resource_list(&bridge->windows);
> +	kfree(bridge);
> +}
> +
> +struct pci_host_bridge *pci_create_host_bridge(
> +		struct device *parent, u32 db, struct list_head *resources)
> +{
> +	int error;
> +	int bus = PCI_BUSNUM(db);
> +	int domain = PCI_DOMAIN(db);
> +	struct pci_host_bridge *host;
> +	struct resource_entry *window, *n;
> +
> +	host = kzalloc(sizeof(*host), GFP_KERNEL);
> +	if (!host)
> +		return NULL;
> +
> +	host->busnum = bus;
> +	host->domain = domain;
> +	/* If support CONFIG_PCI_DOMAINS_GENERIC, use
> +	 * pci_host_assign_domain_nr() to assign domain
> +	 * number instead PCI_DOMAIN(db).
> +	 */
> +	pci_host_assign_domain_nr(host);

At this point, host->dev.parent has not been assigned. However, when 
calling pci_host_assign_domain_nr(host), it calls 
pci_assign_domain_nr(host->dev.parent), which uses parent->of_node 
directly w/o checking if parent is NULL. This ended up causing NULL 
pointer exception when I do the test.

I think we need to moveo host->dev.parent = parent before calling 
pci_host_assign_domain_nr(host).

Thanks,

Suravee

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-21 23:21     ` Suravee Suthikulpanit
                         ` (2 preceding siblings ...)
  (?)
@ 2015-03-23  1:08       ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-23  1:08 UTC (permalink / raw)
  To: Suravee Suthikulpanit, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_create_host_bridge(
>> +        struct device *parent, u32 db, struct list_head *resources)
>> +{
>> +    int error;
>> +    int bus = PCI_BUSNUM(db);
>> +    int domain = PCI_DOMAIN(db);
>> +    struct pci_host_bridge *host;
>> +    struct resource_entry *window, *n;
>> +
>> +    host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +    if (!host)
>> +        return NULL;
>> +
>> +    host->busnum = bus;
>> +    host->domain = domain;
>> +    /* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +     * pci_host_assign_domain_nr() to assign domain
>> +     * number instead PCI_DOMAIN(db).
>> +     */
>> +    pci_host_assign_domain_nr(host);
> 
> At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test.
> 
> I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host).

Good catch! Hi Suravee, thanks for your test, I would assign host->dev.parent before pci_host_assign_domain_nr().

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  2015-03-21 23:21     ` Suravee Suthikulpanit
                       ` (3 preceding siblings ...)
  (?)
@ 2015-03-23  1:08     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-23  1:08 UTC (permalink / raw)
  To: Suravee Suthikulpanit, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_create_host_bridge(
>> +        struct device *parent, u32 db, struct list_head *resources)
>> +{
>> +    int error;
>> +    int bus = PCI_BUSNUM(db);
>> +    int domain = PCI_DOMAIN(db);
>> +    struct pci_host_bridge *host;
>> +    struct resource_entry *window, *n;
>> +
>> +    host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +    if (!host)
>> +        return NULL;
>> +
>> +    host->busnum = bus;
>> +    host->domain = domain;
>> +    /* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +     * pci_host_assign_domain_nr() to assign domain
>> +     * number instead PCI_DOMAIN(db).
>> +     */
>> +    pci_host_assign_domain_nr(host);
> 
> At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test.
> 
> I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host).

Good catch! Hi Suravee, thanks for your test, I would assign host->dev.parent before pci_host_assign_domain_nr().

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-23  1:08       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-23  1:08 UTC (permalink / raw)
  To: Suravee Suthikulpanit, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_create_host_bridge(
>> +        struct device *parent, u32 db, struct list_head *resources)
>> +{
>> +    int error;
>> +    int bus = PCI_BUSNUM(db);
>> +    int domain = PCI_DOMAIN(db);
>> +    struct pci_host_bridge *host;
>> +    struct resource_entry *window, *n;
>> +
>> +    host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +    if (!host)
>> +        return NULL;
>> +
>> +    host->busnum = bus;
>> +    host->domain = domain;
>> +    /* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +     * pci_host_assign_domain_nr() to assign domain
>> +     * number instead PCI_DOMAIN(db).
>> +     */
>> +    pci_host_assign_domain_nr(host);
> 
> At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test.
> 
> I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host).

Good catch! Hi Suravee, thanks for your test, I would assign host->dev.parent before pci_host_assign_domain_nr().

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-23  1:08       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-23  1:08 UTC (permalink / raw)
  To: linux-arm-kernel

>> +struct pci_host_bridge *pci_create_host_bridge(
>> +        struct device *parent, u32 db, struct list_head *resources)
>> +{
>> +    int error;
>> +    int bus = PCI_BUSNUM(db);
>> +    int domain = PCI_DOMAIN(db);
>> +    struct pci_host_bridge *host;
>> +    struct resource_entry *window, *n;
>> +
>> +    host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +    if (!host)
>> +        return NULL;
>> +
>> +    host->busnum = bus;
>> +    host->domain = domain;
>> +    /* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +     * pci_host_assign_domain_nr() to assign domain
>> +     * number instead PCI_DOMAIN(db).
>> +     */
>> +    pci_host_assign_domain_nr(host);
> 
> At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test.
> 
> I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host).

Good catch! Hi Suravee, thanks for your test, I would assign host->dev.parent before pci_host_assign_domain_nr().

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-23  1:08       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-23  1:08 UTC (permalink / raw)
  To: Suravee Suthikulpanit, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_create_host_bridge(
>> +        struct device *parent, u32 db, struct list_head *resources)
>> +{
>> +    int error;
>> +    int bus = PCI_BUSNUM(db);
>> +    int domain = PCI_DOMAIN(db);
>> +    struct pci_host_bridge *host;
>> +    struct resource_entry *window, *n;
>> +
>> +    host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +    if (!host)
>> +        return NULL;
>> +
>> +    host->busnum = bus;
>> +    host->domain = domain;
>> +    /* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +     * pci_host_assign_domain_nr() to assign domain
>> +     * number instead PCI_DOMAIN(db).
>> +     */
>> +    pci_host_assign_domain_nr(host);
> 
> At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test.
> 
> I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host).

Good catch! Hi Suravee, thanks for your test, I would assign host->dev.parent before pci_host_assign_domain_nr().

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
@ 2015-03-23  1:08       ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-23  1:08 UTC (permalink / raw)
  To: Suravee Suthikulpanit, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm-kernel, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven

>> +struct pci_host_bridge *pci_create_host_bridge(
>> +        struct device *parent, u32 db, struct list_head *resources)
>> +{
>> +    int error;
>> +    int bus = PCI_BUSNUM(db);
>> +    int domain = PCI_DOMAIN(db);
>> +    struct pci_host_bridge *host;
>> +    struct resource_entry *window, *n;
>> +
>> +    host = kzalloc(sizeof(*host), GFP_KERNEL);
>> +    if (!host)
>> +        return NULL;
>> +
>> +    host->busnum = bus;
>> +    host->domain = domain;
>> +    /* If support CONFIG_PCI_DOMAINS_GENERIC, use
>> +     * pci_host_assign_domain_nr() to assign domain
>> +     * number instead PCI_DOMAIN(db).
>> +     */
>> +    pci_host_assign_domain_nr(host);
> 
> At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test.
> 
> I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host).

Good catch! Hi Suravee, thanks for your test, I would assign host->dev.parent before pci_host_assign_domain_nr().

Thanks!
Yijing.

> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13 14:26                 ` Bjorn Helgaas
  (?)
  (?)
@ 2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
  -1 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-25 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 09:26:08AM -0500, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com> wrote:
> > On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> >> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >> >>>>
> >> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >> >>>> own struct resource for it here.  And, of course, figure out the details of
> >> >>>> which PCI domain you're in and whether you need to share one struct
> >> >>>> resource across several host bridges in the same domain.
> >> >>>
> >> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >> >>
> >> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> >> have in the same domain.  In principle, every host bridge could be in its
> >> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> >> xen assumes.
> >> >
> >> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> >> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> >> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >> >
> >> > Something like:
> >> >
> >> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> >> > index b1ffebe..a69e529 100644
> >> > --- a/drivers/pci/xen-pcifront.c
> >> > +++ b/drivers/pci/xen-pcifront.c
> >> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                                  unsigned int domain, unsigned int bus)
> >> >  {
> >> >         struct pci_bus *b;
> >> > +       LIST_HEAD(resources);
> >> >         struct pcifront_sd *sd = NULL;
> >> >         struct pci_bus_entry *bus_entry = NULL;
> >> >         int err = 0;
> >> > +       static struct resource busn_res = {
> >> > +               .start = 0,
> >> > +               .end = 255,
> >> > +               .flags = IORESOURCE_BUS,
> >> > +       };
> >> >
> >> >  #ifndef CONFIG_PCI_DOMAINS
> >> >         if (domain != 0) {
> >> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                 err = -ENOMEM;
> >> >                 goto err_out;
> >> >         }
> >> > +       pci_add_resource(&resources, &ioport_resource);
> >> > +       pci_add_resource(&resources, &iomem_resource);
> >> > +       pci_add_resource(&resources, &busn_res);
> >> >         pcifront_init_sd(sd, domain, bus, pdev);
> >> >
> >> >         pci_lock_rescan_remove();
> >> >
> >> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> > -                                 &pcifront_bus_ops, sd);
> >> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> > +                                 &pcifront_bus_ops, sd, &resources);
> >> >         if (!b) {
> >> >
> >> > Bjorn, what do you think about ?
> >>
> >> That seems OK to me.  Probably still wrong, but no worse than it was before.
> >
> > Interesting. The mechanism for PCI passthrough can either synthesize
> > and PCI bus number starting at zero (so first device is always 0:0:0.0)
> > or it can replicate the backend PCI topology. That means you
> > could have segment values passed in, so: ab:ff:00.1). I've to admin
> > I hadn't tried the 'physical' replication on an machine with
> > domains (err, segments).
> >
> > Is there an git tree with this so I can just try it out?
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
> pci/enumeration-yw6 has similar code (it exports the single

I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
this week.
> busn_resource and makes xen use it).  That should be functionally
> identical to what v4.0-rc1 does.
> 
> Yijing hasn't posted the static busn_res proposal above yet, so I
> don't have a branch with that in it.
> 
> Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-25 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 09:26:08AM -0500, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com> wrote:
> > On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> >> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >> >>>>
> >> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >> >>>> own struct resource for it here.  And, of course, figure out the details of
> >> >>>> which PCI domain you're in and whether you need to share one struct
> >> >>>> resource across several host bridges in the same domain.
> >> >>>
> >> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >> >>
> >> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> >> have in the same domain.  In principle, every host bridge could be in its
> >> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> >> xen assumes.
> >> >
> >> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> >> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> >> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >> >
> >> > Something like:
> >> >
> >> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> >> > index b1ffebe..a69e529 100644
> >> > --- a/drivers/pci/xen-pcifront.c
> >> > +++ b/drivers/pci/xen-pcifront.c
> >> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                                  unsigned int domain, unsigned int bus)
> >> >  {
> >> >         struct pci_bus *b;
> >> > +       LIST_HEAD(resources);
> >> >         struct pcifront_sd *sd = NULL;
> >> >         struct pci_bus_entry *bus_entry = NULL;
> >> >         int err = 0;
> >> > +       static struct resource busn_res = {
> >> > +               .start = 0,
> >> > +               .end = 255,
> >> > +               .flags = IORESOURCE_BUS,
> >> > +       };
> >> >
> >> >  #ifndef CONFIG_PCI_DOMAINS
> >> >         if (domain != 0) {
> >> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                 err = -ENOMEM;
> >> >                 goto err_out;
> >> >         }
> >> > +       pci_add_resource(&resources, &ioport_resource);
> >> > +       pci_add_resource(&resources, &iomem_resource);
> >> > +       pci_add_resource(&resources, &busn_res);
> >> >         pcifront_init_sd(sd, domain, bus, pdev);
> >> >
> >> >         pci_lock_rescan_remove();
> >> >
> >> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> > -                                 &pcifront_bus_ops, sd);
> >> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> > +                                 &pcifront_bus_ops, sd, &resources);
> >> >         if (!b) {
> >> >
> >> > Bjorn, what do you think about ?
> >>
> >> That seems OK to me.  Probably still wrong, but no worse than it was before.
> >
> > Interesting. The mechanism for PCI passthrough can either synthesize
> > and PCI bus number starting at zero (so first device is always 0:0:0.0)
> > or it can replicate the backend PCI topology. That means you
> > could have segment values passed in, so: ab:ff:00.1). I've to admin
> > I hadn't tried the 'physical' replication on an machine with
> > domains (err, segments).
> >
> > Is there an git tree with this so I can just try it out?
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
> pci/enumeration-yw6 has similar code (it exports the single

I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
this week.
> busn_resource and makes xen use it).  That should be functionally
> identical to what v4.0-rc1 does.
> 
> Yijing hasn't posted the static busn_res proposal above yet, so I
> don't have a branch with that in it.
> 
> Bjorn

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-25 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 13, 2015 at 09:26:08AM -0500, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com> wrote:
> > On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> >> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >> >>>>
> >> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >> >>>> own struct resource for it here.  And, of course, figure out the details of
> >> >>>> which PCI domain you're in and whether you need to share one struct
> >> >>>> resource across several host bridges in the same domain.
> >> >>>
> >> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >> >>
> >> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> >> have in the same domain.  In principle, every host bridge could be in its
> >> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> >> xen assumes.
> >> >
> >> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> >> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> >> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >> >
> >> > Something like:
> >> >
> >> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> >> > index b1ffebe..a69e529 100644
> >> > --- a/drivers/pci/xen-pcifront.c
> >> > +++ b/drivers/pci/xen-pcifront.c
> >> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                                  unsigned int domain, unsigned int bus)
> >> >  {
> >> >         struct pci_bus *b;
> >> > +       LIST_HEAD(resources);
> >> >         struct pcifront_sd *sd = NULL;
> >> >         struct pci_bus_entry *bus_entry = NULL;
> >> >         int err = 0;
> >> > +       static struct resource busn_res = {
> >> > +               .start = 0,
> >> > +               .end = 255,
> >> > +               .flags = IORESOURCE_BUS,
> >> > +       };
> >> >
> >> >  #ifndef CONFIG_PCI_DOMAINS
> >> >         if (domain != 0) {
> >> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                 err = -ENOMEM;
> >> >                 goto err_out;
> >> >         }
> >> > +       pci_add_resource(&resources, &ioport_resource);
> >> > +       pci_add_resource(&resources, &iomem_resource);
> >> > +       pci_add_resource(&resources, &busn_res);
> >> >         pcifront_init_sd(sd, domain, bus, pdev);
> >> >
> >> >         pci_lock_rescan_remove();
> >> >
> >> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> > -                                 &pcifront_bus_ops, sd);
> >> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> > +                                 &pcifront_bus_ops, sd, &resources);
> >> >         if (!b) {
> >> >
> >> > Bjorn, what do you think about ?
> >>
> >> That seems OK to me.  Probably still wrong, but no worse than it was before.
> >
> > Interesting. The mechanism for PCI passthrough can either synthesize
> > and PCI bus number starting at zero (so first device is always 0:0:0.0)
> > or it can replicate the backend PCI topology. That means you
> > could have segment values passed in, so: ab:ff:00.1). I've to admin
> > I hadn't tried the 'physical' replication on an machine with
> > domains (err, segments).
> >
> > Is there an git tree with this so I can just try it out?
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
> pci/enumeration-yw6 has similar code (it exports the single

I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
this week.
> busn_resource and makes xen use it).  That should be functionally
> identical to what v4.0-rc1 does.
> 
> Yijing hasn't posted the static busn_res proposal above yet, so I
> don't have a branch with that in it.
> 
> Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-13 14:26                 ` Bjorn Helgaas
                                   ` (3 preceding siblings ...)
  (?)
@ 2015-03-25 19:23                 ` Konrad Rzeszutek Wilk
  -1 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-25 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-m68k, linux-ia64, linux-pci, Yijing Wang, Guan Xuetao,
	Russell King, x86, Geert Uytterhoeven, Benjamin Herrenschmidt,
	xen-devel, Arnd Bergmann, Marc Zyngier, Rusty Russell,
	Thomas Gleixner, Yinghai Lu, linux-arm, Liviu Dudau, Tony Luck,
	linux-kernel, Jiang Liu, linux-alpha, Davi

On Fri, Mar 13, 2015 at 09:26:08AM -0500, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com> wrote:
> > On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> >> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >> >>>>
> >> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >> >>>> own struct resource for it here.  And, of course, figure out the details of
> >> >>>> which PCI domain you're in and whether you need to share one struct
> >> >>>> resource across several host bridges in the same domain.
> >> >>>
> >> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >> >>
> >> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> >> have in the same domain.  In principle, every host bridge could be in its
> >> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> >> xen assumes.
> >> >
> >> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> >> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> >> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >> >
> >> > Something like:
> >> >
> >> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> >> > index b1ffebe..a69e529 100644
> >> > --- a/drivers/pci/xen-pcifront.c
> >> > +++ b/drivers/pci/xen-pcifront.c
> >> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                                  unsigned int domain, unsigned int bus)
> >> >  {
> >> >         struct pci_bus *b;
> >> > +       LIST_HEAD(resources);
> >> >         struct pcifront_sd *sd = NULL;
> >> >         struct pci_bus_entry *bus_entry = NULL;
> >> >         int err = 0;
> >> > +       static struct resource busn_res = {
> >> > +               .start = 0,
> >> > +               .end = 255,
> >> > +               .flags = IORESOURCE_BUS,
> >> > +       };
> >> >
> >> >  #ifndef CONFIG_PCI_DOMAINS
> >> >         if (domain != 0) {
> >> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                 err = -ENOMEM;
> >> >                 goto err_out;
> >> >         }
> >> > +       pci_add_resource(&resources, &ioport_resource);
> >> > +       pci_add_resource(&resources, &iomem_resource);
> >> > +       pci_add_resource(&resources, &busn_res);
> >> >         pcifront_init_sd(sd, domain, bus, pdev);
> >> >
> >> >         pci_lock_rescan_remove();
> >> >
> >> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> > -                                 &pcifront_bus_ops, sd);
> >> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> > +                                 &pcifront_bus_ops, sd, &resources);
> >> >         if (!b) {
> >> >
> >> > Bjorn, what do you think about ?
> >>
> >> That seems OK to me.  Probably still wrong, but no worse than it was before.
> >
> > Interesting. The mechanism for PCI passthrough can either synthesize
> > and PCI bus number starting at zero (so first device is always 0:0:0.0)
> > or it can replicate the backend PCI topology. That means you
> > could have segment values passed in, so: ab:ff:00.1). I've to admin
> > I hadn't tried the 'physical' replication on an machine with
> > domains (err, segments).
> >
> > Is there an git tree with this so I can just try it out?
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
> pci/enumeration-yw6 has similar code (it exports the single

I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
this week.
> busn_resource and makes xen use it).  That should be functionally
> identical to what v4.0-rc1 does.
> 
> Yijing hasn't posted the static busn_res proposal above yet, so I
> don't have a branch with that in it.
> 
> Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 513+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-25 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yijing Wang, Jiang Liu, linux-pci, Yinghai Lu, linux-kernel,
	Marc Zyngier, linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

On Fri, Mar 13, 2015 at 09:26:08AM -0500, Bjorn Helgaas wrote:
> On Fri, Mar 13, 2015 at 9:01 AM, Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com> wrote:
> > On Fri, Mar 13, 2015 at 08:24:58AM -0500, Bjorn Helgaas wrote:
> >> On Thu, Mar 12, 2015 at 9:36 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> >> >>>>> +  pci_add_resource(&resources, &ioport_resource);
> >> >>>>> +  pci_add_resource(&resources, &iomem_resource);
> >> >>>>> +  pci_add_resource(&resources, &busn_resource);
> >> >>>>
> >> >>>> Since I don't want to export busn_resource, you might have to allocate your
> >> >>>> own struct resource for it here.  And, of course, figure out the details of
> >> >>>> which PCI domain you're in and whether you need to share one struct
> >> >>>> resource across several host bridges in the same domain.
> >> >>>
> >> >>> Allocate its own resource here is ok for me, as I mentioned in previous reply,
> >> >>> so do we still need to add additional info to figure out which domain own the bus resource ?
> >> >>
> >> >> That's up to the caller.  Only the platform knows which bridges it wants to
> >> >> have in the same domain.  In principle, every host bridge could be in its
> >> >> own domain, since each bridge is the root of a unique PCI hierarchy.  But
> >> >> some platforms have firmware that assumes otherwise.  I have no idea what
> >> >> xen assumes.
> >> >
> >> > I'm not xen guy, so I don't know much about it, but because it call pci_scan_bus_parented()
> >> > before, and in which busn_resource is always shared for different host bridges(same domain or not),
> >> > I think add a static bus resource(0,255) should be safe, at least, it would not introduce new risk.
> >> >
> >> > Something like:
> >> >
> >> > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> >> > index b1ffebe..a69e529 100644
> >> > --- a/drivers/pci/xen-pcifront.c
> >> > +++ b/drivers/pci/xen-pcifront.c
> >> > @@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                                  unsigned int domain, unsigned int bus)
> >> >  {
> >> >         struct pci_bus *b;
> >> > +       LIST_HEAD(resources);
> >> >         struct pcifront_sd *sd = NULL;
> >> >         struct pci_bus_entry *bus_entry = NULL;
> >> >         int err = 0;
> >> > +       static struct resource busn_res = {
> >> > +               .start = 0,
> >> > +               .end = 255,
> >> > +               .flags = IORESOURCE_BUS,
> >> > +       };
> >> >
> >> >  #ifndef CONFIG_PCI_DOMAINS
> >> >         if (domain != 0) {
> >> > @@ -470,17 +476,21 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
> >> >                 err = -ENOMEM;
> >> >                 goto err_out;
> >> >         }
> >> > +       pci_add_resource(&resources, &ioport_resource);
> >> > +       pci_add_resource(&resources, &iomem_resource);
> >> > +       pci_add_resource(&resources, &busn_res);
> >> >         pcifront_init_sd(sd, domain, bus, pdev);
> >> >
> >> >         pci_lock_rescan_remove();
> >> >
> >> > -       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
> >> > -                                 &pcifront_bus_ops, sd);
> >> > +       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
> >> > +                                 &pcifront_bus_ops, sd, &resources);
> >> >         if (!b) {
> >> >
> >> > Bjorn, what do you think about ?
> >>
> >> That seems OK to me.  Probably still wrong, but no worse than it was before.
> >
> > Interesting. The mechanism for PCI passthrough can either synthesize
> > and PCI bus number starting at zero (so first device is always 0:0:0.0)
> > or it can replicate the backend PCI topology. That means you
> > could have segment values passed in, so: ab:ff:00.1). I've to admin
> > I hadn't tried the 'physical' replication on an machine with
> > domains (err, segments).
> >
> > Is there an git tree with this so I can just try it out?
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
> pci/enumeration-yw6 has similar code (it exports the single

I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
this week.
> busn_resource and makes xen use it).  That should be functionally
> identical to what v4.0-rc1 does.
> 
> Yijing hasn't posted the static busn_res proposal above yet, so I
> don't have a branch with that in it.
> 
> Bjorn

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
  (?)
  (?)
@ 2015-03-26  1:18                     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  1:18 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

>>>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>>>
>>> Interesting. The mechanism for PCI passthrough can either synthesize
>>> and PCI bus number starting at zero (so first device is always 0:0:0.0)
>>> or it can replicate the backend PCI topology. That means you
>>> could have segment values passed in, so: ab:ff:00.1). I've to admin
>>> I hadn't tried the 'physical' replication on an machine with
>>> domains (err, segments).
>>>
>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Yes, it's the latest version. thanks!

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-26  1:18                     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  1:18 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	xen-devel@lists.xenproject.org

>>>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>>>
>>> Interesting. The mechanism for PCI passthrough can either synthesize
>>> and PCI bus number starting at zero (so first device is always 0:0:0.0)
>>> or it can replicate the backend PCI topology. That means you
>>> could have segment values passed in, so: ab:ff:00.1). I've to admin
>>> I hadn't tried the 'physical' replication on an machine with
>>> domains (err, segments).
>>>
>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Yes, it's the latest version. thanks!

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-26  1:18                     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

>>>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>>>
>>> Interesting. The mechanism for PCI passthrough can either synthesize
>>> and PCI bus number starting at zero (so first device is always 0:0:0.0)
>>> or it can replicate the backend PCI topology. That means you
>>> could have segment values passed in, so: ab:ff:00.1). I've to admin
>>> I hadn't tried the 'physical' replication on an machine with
>>> domains (err, segments).
>>>
>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Yes, it's the latest version. thanks!

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
                                     ` (2 preceding siblings ...)
  (?)
@ 2015-03-26  1:18                   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  1:18 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Liviu Dudau, linux-m68k, Rusty Russell, Russell King, xen-devel,
	Arnd Bergmann, Marc Zyngier, linux-pci, x86, linux-kernel,
	David S. Miller, linux-alpha, Tony Luck, Geert Uytterhoeven,
	Benjamin Herrenschmidt, linux-ia64, Thomas Gleixner, Guan Xuetao,
	Yinghai Lu, Jiang Liu, linux-arm

>>>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>>>
>>> Interesting. The mechanism for PCI passthrough can either synthesize
>>> and PCI bus number starting at zero (so first device is always 0:0:0.0)
>>> or it can replicate the backend PCI topology. That means you
>>> could have segment values passed in, so: ab:ff:00.1). I've to admin
>>> I hadn't tried the 'physical' replication on an machine with
>>> domains (err, segments).
>>>
>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Yes, it's the latest version. thanks!

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-26  1:18                     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  1:18 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

>>>> That seems OK to me.  Probably still wrong, but no worse than it was before.
>>>
>>> Interesting. The mechanism for PCI passthrough can either synthesize
>>> and PCI bus number starting at zero (so first device is always 0:0:0.0)
>>> or it can replicate the backend PCI topology. That means you
>>> could have segment values passed in, so: ab:ff:00.1). I've to admin
>>> I hadn't tried the 'physical' replication on an machine with
>>> domains (err, segments).
>>>
>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Yes, it's the latest version. thanks!

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
  (?)
  (?)
@ 2015-03-26  7:30                     ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  7:30 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Hi Konrad, I fixed two issues found by Tomasz and Daniel for the current v8 version.
I posted out the latest v9 in my github tree. Could you pull this series from my
github tree ?
The URL is: https://github.com/YijingWang/linux-pci.git enumer9

Thanks!
Yijing.

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-26  7:30                     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  7:30 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven,
	xen-devel@lists.xenproject.org

>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Hi Konrad, I fixed two issues found by Tomasz and Daniel for the current v8 version.
I posted out the latest v9 in my github tree. Could you pull this series from my
github tree ?
The URL is: https://github.com/YijingWang/linux-pci.git enumer9

Thanks!
Yijing.

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

* [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-26  7:30                     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  7:30 UTC (permalink / raw)
  To: linux-arm-kernel

>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Hi Konrad, I fixed two issues found by Tomasz and Daniel for the current v8 version.
I posted out the latest v9 in my github tree. Could you pull this series from my
github tree ?
The URL is: https://github.com/YijingWang/linux-pci.git enumer9

Thanks!
Yijing.

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
                                     ` (5 preceding siblings ...)
  (?)
@ 2015-03-26  7:30                   ` Yijing Wang
  -1 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  7:30 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Liviu Dudau, linux-m68k, Rusty Russell, Russell King, xen-devel,
	Arnd Bergmann, Marc Zyngier, linux-pci, x86, linux-kernel,
	David S. Miller, linux-alpha, Tony Luck, Geert Uytterhoeven,
	Benjamin Herrenschmidt, linux-ia64, Thomas Gleixner, Guan Xuetao,
	Yinghai Lu, Jiang Liu, linux-arm

>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Hi Konrad, I fixed two issues found by Tomasz and Daniel for the current v8 version.
I posted out the latest v9 in my github tree. Could you pull this series from my
github tree ?
The URL is: https://github.com/YijingWang/linux-pci.git enumer9

Thanks!
Yijing.

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

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

* Re: [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
@ 2015-03-26  7:30                     ` Yijing Wang
  0 siblings, 0 replies; 513+ messages in thread
From: Yijing Wang @ 2015-03-26  7:30 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Bjorn Helgaas
  Cc: Jiang Liu, linux-pci, Yinghai Lu, linux-kernel, Marc Zyngier,
	linux-arm, Russell King, x86, Thomas Gleixner,
	Benjamin Herrenschmidt, Rusty Russell, Tony Luck, linux-ia64,
	David S. Miller, Guan Xuetao, linux-alpha, linux-m68k,
	Liviu Dudau, Arnd Bergmann, Geert Uytterhoeven, xen-devel

>>> Is there an git tree with this so I can just try it out?
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>> pci/enumeration-yw6 has similar code (it exports the single
> 
> I presume now it is bjorn/pci/enumeration-yw8 ? Going to test this out
> this week.

Hi Konrad, I fixed two issues found by Tomasz and Daniel for the current v8 version.
I posted out the latest v9 in my github tree. Could you pull this series from my
github tree ?
The URL is: https://github.com/YijingWang/linux-pci.git enumer9

Thanks!
Yijing.

>> busn_resource and makes xen use it).  That should be functionally
>> identical to what v4.0-rc1 does.
>>
>> Yijing hasn't posted the static busn_res proposal above yet, so I
>> don't have a branch with that in it.
>>
>> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


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

end of thread, other threads:[~2015-03-26  7:32 UTC | newest]

Thread overview: 513+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09  2:33 [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge Yijing Wang
2015-03-09  2:33 ` Yijing Wang
2015-03-09  2:33 ` Yijing Wang
2015-03-09  2:33 ` Yijing Wang
2015-03-09  2:33 ` Yijing Wang
2015-03-09  2:33 ` [PATCH v6 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus() Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33 ` Yijing Wang
2015-03-09  2:33 ` [PATCH v6 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus() Yijing Wang
2015-03-09  2:33 ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:33   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 03/30] PCI: Export busn_resource to drivers/pci Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-11 22:28   ` Bjorn Helgaas
2015-03-11 22:28   ` Bjorn Helgaas
2015-03-11 22:28     ` Bjorn Helgaas
2015-03-11 22:28     ` Bjorn Helgaas
2015-03-11 22:28     ` Bjorn Helgaas
2015-03-12 11:42     ` Yijing Wang
2015-03-12 11:42     ` Yijing Wang
2015-03-12 11:42       ` Yijing Wang
2015-03-12 11:42       ` Yijing Wang
2015-03-12 11:42       ` Yijing Wang
2015-03-12 11:42       ` Yijing Wang
2015-03-12 19:32       ` Bjorn Helgaas
2015-03-12 19:32         ` Bjorn Helgaas
2015-03-12 19:32         ` Bjorn Helgaas
2015-03-12 19:32         ` Bjorn Helgaas
2015-03-13  1:57         ` Yijing Wang
2015-03-13  1:57           ` Yijing Wang
2015-03-13  1:57           ` Yijing Wang
2015-03-13  1:57           ` Yijing Wang
2015-03-13  1:57           ` Yijing Wang
2015-03-13  1:57         ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 04/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-11 22:32   ` Bjorn Helgaas
2015-03-11 22:32   ` Bjorn Helgaas
2015-03-11 22:32   ` Bjorn Helgaas
2015-03-11 22:32     ` Bjorn Helgaas
2015-03-11 22:32     ` Bjorn Helgaas
2015-03-11 22:32     ` Bjorn Helgaas
2015-03-12 11:46     ` Yijing Wang
2015-03-12 11:46       ` Yijing Wang
2015-03-12 11:46       ` Yijing Wang
2015-03-12 11:46       ` Yijing Wang
2015-03-12 11:46       ` Yijing Wang
2015-03-12 19:35       ` Bjorn Helgaas
2015-03-12 19:35       ` Bjorn Helgaas
2015-03-12 19:35       ` Bjorn Helgaas
2015-03-12 19:35         ` Bjorn Helgaas
2015-03-12 19:35         ` Bjorn Helgaas
2015-03-12 19:35         ` Bjorn Helgaas
2015-03-13  2:36         ` Yijing Wang
2015-03-13  2:36         ` Yijing Wang
2015-03-13  2:36           ` Yijing Wang
2015-03-13  2:36           ` Yijing Wang
2015-03-13  2:36           ` Yijing Wang
2015-03-13  2:36           ` Yijing Wang
2015-03-13 13:24           ` Bjorn Helgaas
2015-03-13 13:24           ` Bjorn Helgaas
2015-03-13 13:24           ` Bjorn Helgaas
2015-03-13 13:24             ` Bjorn Helgaas
2015-03-13 13:24             ` Bjorn Helgaas
2015-03-13 13:24             ` Bjorn Helgaas
2015-03-13 13:24             ` Bjorn Helgaas
2015-03-13 14:01             ` Konrad Rzeszutek Wilk
2015-03-13 14:01               ` Konrad Rzeszutek Wilk
2015-03-13 14:01               ` Konrad Rzeszutek Wilk
2015-03-13 14:01               ` Konrad Rzeszutek Wilk
2015-03-13 14:26               ` Bjorn Helgaas
2015-03-13 14:26                 ` Bjorn Helgaas
2015-03-13 14:26                 ` Bjorn Helgaas
2015-03-13 14:26                 ` Bjorn Helgaas
2015-03-25 19:23                 ` Konrad Rzeszutek Wilk
2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
2015-03-25 19:23                   ` Konrad Rzeszutek Wilk
2015-03-26  1:18                   ` Yijing Wang
2015-03-26  1:18                   ` Yijing Wang
2015-03-26  1:18                     ` Yijing Wang
2015-03-26  1:18                     ` Yijing Wang
2015-03-26  1:18                     ` Yijing Wang
2015-03-26  7:30                   ` Yijing Wang
2015-03-26  7:30                     ` Yijing Wang
2015-03-26  7:30                     ` Yijing Wang
2015-03-26  7:30                     ` Yijing Wang
2015-03-26  7:30                   ` Yijing Wang
2015-03-25 19:23                 ` Konrad Rzeszutek Wilk
2015-03-13 14:26               ` Bjorn Helgaas
2015-03-13 14:01             ` Konrad Rzeszutek Wilk
2015-03-12 11:46     ` Yijing Wang
2015-03-12 11:46     ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 05/30] PCI: Remove deprecated pci_scan_bus_parented() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 06/30] PCI: Combine PCI domain and bus number in u32 arg Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  1:29   ` Bjorn Helgaas
2015-03-12  1:29   ` Bjorn Helgaas
2015-03-12  1:29     ` Bjorn Helgaas
2015-03-12  1:29     ` Bjorn Helgaas
2015-03-12  1:29     ` Bjorn Helgaas
2015-03-12 12:14     ` Yijing Wang
2015-03-12 12:14     ` Yijing Wang
2015-03-12 12:14       ` Yijing Wang
2015-03-12 12:14       ` Yijing Wang
2015-03-12 12:14       ` Yijing Wang
2015-03-12 12:14       ` Yijing Wang
2015-03-12 19:49       ` Bjorn Helgaas
2015-03-12 19:49       ` Bjorn Helgaas
2015-03-12 19:49         ` Bjorn Helgaas
2015-03-12 19:49         ` Bjorn Helgaas
2015-03-12 19:49         ` Bjorn Helgaas
2015-03-13  3:19         ` Yijing Wang
2015-03-13  3:19         ` Yijing Wang
2015-03-13  3:19           ` Yijing Wang
2015-03-13  3:19           ` Yijing Wang
2015-03-13  3:19           ` Yijing Wang
2015-03-13  3:19           ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 07/30] PCI: Pass PCI domain number combined with root bus number Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  1:34   ` Bjorn Helgaas
2015-03-12  1:34   ` Bjorn Helgaas
2015-03-12  1:34   ` Bjorn Helgaas
2015-03-12  1:34     ` Bjorn Helgaas
2015-03-12  1:34     ` Bjorn Helgaas
2015-03-12  1:34     ` Bjorn Helgaas
2015-03-12  1:34     ` Bjorn Helgaas
2015-03-12  1:34     ` Bjorn Helgaas
2015-03-12 12:20     ` Yijing Wang
2015-03-12 12:20     ` Yijing Wang
2015-03-12 12:20     ` Yijing Wang
2015-03-12 12:20       ` Yijing Wang
2015-03-12 12:20       ` Yijing Wang
2015-03-12 12:20       ` Yijing Wang
2015-03-12 12:20       ` Yijing Wang
2015-03-12 12:20       ` Yijing Wang
2015-03-12 12:20       ` Yijing Wang
2015-03-17  5:15   ` [Xen-devel] " Manish Jaggi
2015-03-17  5:27     ` Manish Jaggi
2015-03-17  5:15     ` Manish Jaggi
2015-03-17  5:15     ` Manish Jaggi
2015-03-17  5:15     ` Manish Jaggi
2015-03-17  5:15     ` Manish Jaggi
2015-03-17  5:15     ` Manish Jaggi
2015-03-17 14:05     ` Ian Campbell
2015-03-17 14:05       ` Ian Campbell
2015-03-17 14:05       ` Ian Campbell
2015-03-17 14:05       ` Ian Campbell
2015-03-17 14:05       ` Ian Campbell
2015-03-17 14:05       ` Ian Campbell
2015-03-17 14:05       ` Ian Campbell
2015-03-18  4:26       ` Manish Jaggi
2015-03-18  5:56         ` Yijing Wang
2015-03-17 14:05     ` [Xen-devel] " Ian Campbell
2015-03-17 14:05     ` Ian Campbell
2015-03-17  5:15   ` Manish Jaggi
2015-03-17  5:15   ` [Xen-devel] " Manish Jaggi
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 08/30] PCI: Introduce pci_host_assign_domain_nr() to assign domain Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  1:39   ` Bjorn Helgaas
2015-03-12  1:39   ` Bjorn Helgaas
2015-03-12  1:39     ` Bjorn Helgaas
2015-03-12  1:39     ` Bjorn Helgaas
2015-03-12  1:39     ` Bjorn Helgaas
2015-03-12 12:23     ` Yijing Wang
2015-03-12 12:23       ` Yijing Wang
2015-03-12 12:23       ` Yijing Wang
2015-03-12 12:23       ` Yijing Wang
2015-03-12 12:23       ` Yijing Wang
2015-03-12 12:23     ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:52   ` Bjorn Helgaas
2015-03-12  3:52     ` Bjorn Helgaas
2015-03-12  3:52     ` Bjorn Helgaas
2015-03-12  3:52     ` Bjorn Helgaas
2015-03-12 13:44     ` Yijing Wang
2015-03-12 13:44     ` Yijing Wang
2015-03-12 13:44       ` Yijing Wang
2015-03-12 13:44       ` Yijing Wang
2015-03-12 13:44       ` Yijing Wang
2015-03-12 13:44       ` Yijing Wang
2015-03-12  3:52   ` Bjorn Helgaas
2015-03-21 23:21   ` Suravee Suthikulpanit
2015-03-21 23:21     ` Suravee Suthikulpanit
2015-03-21 23:21     ` Suravee Suthikulpanit
2015-03-21 23:21     ` Suravee Suthikulpanit
2015-03-21 23:21     ` Suravee Suthikulpanit
2015-03-23  1:08     ` Yijing Wang
2015-03-23  1:08     ` Yijing Wang
2015-03-23  1:08       ` Yijing Wang
2015-03-23  1:08       ` Yijing Wang
2015-03-23  1:08       ` Yijing Wang
2015-03-23  1:08       ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 10/30] PCI: Introduce pci_host_bridge_list to manage host bridges Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  2:55   ` Bjorn Helgaas
2015-03-12  2:55     ` Bjorn Helgaas
2015-03-12  2:55     ` Bjorn Helgaas
2015-03-12  2:55     ` Bjorn Helgaas
2015-03-12 13:03     ` Yijing Wang
2015-03-12 13:03     ` Yijing Wang
2015-03-12 13:03       ` Yijing Wang
2015-03-12 13:03       ` Yijing Wang
2015-03-12 13:03       ` Yijing Wang
2015-03-12 13:03       ` Yijing Wang
2015-03-12 19:56       ` Bjorn Helgaas
2015-03-12 19:56         ` Bjorn Helgaas
2015-03-12 19:56         ` Bjorn Helgaas
2015-03-12 19:56         ` Bjorn Helgaas
2015-03-13  3:28         ` Yijing Wang
2015-03-13  3:28         ` Yijing Wang
2015-03-13  3:28           ` Yijing Wang
2015-03-13  3:28           ` Yijing Wang
2015-03-13  3:28           ` Yijing Wang
2015-03-13  3:28           ` Yijing Wang
2015-03-13 14:33           ` Bjorn Helgaas
2015-03-13 14:33             ` Bjorn Helgaas
2015-03-13 14:33             ` Bjorn Helgaas
2015-03-13 14:33             ` Bjorn Helgaas
2015-03-16  1:28             ` Yijing Wang
2015-03-16  1:28             ` Yijing Wang
2015-03-16  1:28               ` Yijing Wang
2015-03-16  1:28               ` Yijing Wang
2015-03-16  1:28               ` Yijing Wang
2015-03-16  1:28               ` Yijing Wang
2015-03-12 19:56       ` Bjorn Helgaas
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 11/30] PCI: Save sysdata in pci_host_bridge drvdata Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:23   ` Bjorn Helgaas
2015-03-12  3:23   ` Bjorn Helgaas
2015-03-12  3:23     ` Bjorn Helgaas
2015-03-12  3:23     ` Bjorn Helgaas
2015-03-12  3:23     ` Bjorn Helgaas
2015-03-12 13:14     ` Yijing Wang
2015-03-12 13:14     ` Yijing Wang
2015-03-12 13:14       ` Yijing Wang
2015-03-12 13:14       ` Yijing Wang
2015-03-12 13:14       ` Yijing Wang
2015-03-12 13:14       ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 13/30] PCI: Introduce new scan function pci_scan_host_bridge() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:25   ` Bjorn Helgaas
2015-03-12  3:25     ` Bjorn Helgaas
2015-03-12  3:25     ` Bjorn Helgaas
2015-03-12  3:25     ` Bjorn Helgaas
2015-03-12 13:15     ` Yijing Wang
2015-03-12 13:15     ` Yijing Wang
2015-03-12 13:15       ` Yijing Wang
2015-03-12 13:15       ` Yijing Wang
2015-03-12 13:15       ` Yijing Wang
2015-03-12 13:15       ` Yijing Wang
2015-03-12  3:25   ` Bjorn Helgaas
2015-03-09  2:34 ` [PATCH v6 14/30] x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 15/30] ia64/PCI: " Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 16/30] powerpc/pci: Rename pcibios_root_bridge_prepare() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 17/30] powerpc/pci: Use pci_scan_host_bridge() for simplicity Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 18/30] PCI: Remove weak pcibios_root_bridge_prepare() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 19/30] sparc/PCI: Claim bus resources before pci_bus_add_devices() Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 20/30] sparc/PCI: Use pci_scan_host_bridge() for simplicity Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:30   ` Bjorn Helgaas
2015-03-12  3:30   ` Bjorn Helgaas
2015-03-12  3:30     ` Bjorn Helgaas
2015-03-12  3:30     ` Bjorn Helgaas
2015-03-12  3:30     ` Bjorn Helgaas
2015-03-12  3:30     ` Bjorn Helgaas
2015-03-12 13:17     ` Yijing Wang
2015-03-12 13:17     ` Yijing Wang
2015-03-12 13:17       ` Yijing Wang
2015-03-12 13:17       ` Yijing Wang
2015-03-12 13:17       ` Yijing Wang
2015-03-12 13:17       ` Yijing Wang
2015-03-12 13:17       ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 21/30] PCI: Introduce pci_bus_child_max_busnr() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:33   ` Bjorn Helgaas
2015-03-12  3:33     ` Bjorn Helgaas
2015-03-12  3:33     ` Bjorn Helgaas
2015-03-12  3:33     ` Bjorn Helgaas
2015-03-12 13:24     ` Yijing Wang
2015-03-12 13:24     ` Yijing Wang
2015-03-12 13:24       ` Yijing Wang
2015-03-12 13:24       ` Yijing Wang
2015-03-12 13:24       ` Yijing Wang
2015-03-12 13:24       ` Yijing Wang
2015-03-12  3:36   ` Bjorn Helgaas
2015-03-12  3:36   ` Bjorn Helgaas
2015-03-12  3:36     ` Bjorn Helgaas
2015-03-12  3:36     ` Bjorn Helgaas
2015-03-12  3:36     ` Bjorn Helgaas
2015-03-12 13:28     ` Yijing Wang
2015-03-12 13:28       ` Yijing Wang
2015-03-12 13:28       ` Yijing Wang
2015-03-12 13:28       ` Yijing Wang
2015-03-12 13:28       ` Yijing Wang
2015-03-12 20:00       ` Bjorn Helgaas
2015-03-12 20:00         ` Bjorn Helgaas
2015-03-12 20:00         ` Bjorn Helgaas
2015-03-12 20:00         ` Bjorn Helgaas
2015-03-12 20:00       ` Bjorn Helgaas
2015-03-12 13:28     ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 22/30] parisc/PCI: Use pci_scan_root_bus() for simplicity Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 24/30] PCI/tegra: Remove redundant tegra_pcie_scan_bus() Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 25/30] PCI/designware: Use pci_scan_root_bus() for simplicity Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 26/30] PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 27/30] PCI: Rename __pci_create_root_bus() to pci_create_root_bus() Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 28/30] PCI: Export find_pci_host_bridge() and rename to pci_find_host_bridge() Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:43   ` Bjorn Helgaas
2015-03-12  3:43   ` Bjorn Helgaas
2015-03-12  3:43     ` Bjorn Helgaas
2015-03-12  3:43     ` Bjorn Helgaas
2015-03-12  3:43     ` Bjorn Helgaas
2015-03-12 13:29     ` Yijing Wang
2015-03-12 13:29       ` Yijing Wang
2015-03-12 13:29       ` Yijing Wang
2015-03-12 13:29       ` Yijing Wang
2015-03-12 13:29       ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 29/30] PCI: Remove platform specific pci_domain_nr() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34 ` [PATCH v6 30/30] PCI: Remove pci_bus_assign_domain_nr() Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-09  2:34   ` Yijing Wang
2015-03-12  3:48   ` Bjorn Helgaas
2015-03-12  3:48   ` Bjorn Helgaas
2015-03-12  3:48     ` Bjorn Helgaas
2015-03-12  3:48     ` Bjorn Helgaas
2015-03-12  3:48     ` Bjorn Helgaas
2015-03-12 13:32     ` Yijing Wang
2015-03-12 13:32     ` Yijing Wang
2015-03-12 13:32       ` Yijing Wang
2015-03-12 13:32       ` Yijing Wang
2015-03-12 13:32       ` Yijing Wang
2015-03-12 13:32       ` Yijing Wang
2015-03-09  2:34 ` Yijing Wang
2015-03-12 21:23 ` [PATCH v6 00/30] Refine PCI scan interfaces and make generic pci host bridge Bjorn Helgaas
2015-03-12 21:23 ` Bjorn Helgaas
2015-03-12 21:23   ` Bjorn Helgaas
2015-03-12 21:23   ` Bjorn Helgaas
2015-03-12 21:23   ` Bjorn Helgaas
2015-03-13  3:29   ` Yijing Wang
2015-03-13  3:29     ` Yijing Wang
2015-03-13  3:29     ` Yijing Wang
2015-03-13  3:29     ` Yijing Wang
2015-03-13  3:29     ` Yijing Wang
2015-03-13 11:31   ` Liviu Dudau
2015-03-13 11:31   ` Liviu Dudau
2015-03-13 11:31     ` Liviu Dudau
2015-03-13 11:31     ` Liviu Dudau
2015-03-13 14:48     ` Bjorn Helgaas
2015-03-13 14:48       ` Bjorn Helgaas
2015-03-13 14:48       ` Bjorn Helgaas
2015-03-13 14:48       ` Bjorn Helgaas
2015-03-16  1:31       ` Yijing Wang
2015-03-16  1:31         ` Yijing Wang
2015-03-16  1:31         ` Yijing Wang
2015-03-16  1:31         ` Yijing Wang
2015-03-16  1:31         ` Yijing Wang
2015-03-13 14:48     ` Bjorn Helgaas
2015-03-16  1:48     ` Yijing Wang
2015-03-16  1:48     ` Yijing Wang
2015-03-16  1:48       ` Yijing Wang
2015-03-16  1:48       ` Yijing Wang
2015-03-16  1:48       ` Yijing Wang
2015-03-16  1:48       ` Yijing Wang
2015-03-17 10:55       ` Liviu Dudau
2015-03-17 10:55         ` Liviu Dudau
2015-03-17 10:55         ` Liviu Dudau
2015-03-17 10:55       ` Liviu Dudau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.