[RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-17 Thread Yijing Wang
There are some common PCI infos like domain, msi_controller, these infos are saved in arch PCI sysdata, and lots arch specific functions like pci_domain_nr() and pcibios_msi_controller() required. We could separate pci_host_bridge creation out of pci_create_root_bus(), then we could put the common

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-17 Thread Arnd Bergmann
On Monday 17 November 2014 18:21:41 Yijing Wang wrote: > There are some common PCI infos like domain, msi_controller, these > infos are saved in arch PCI sysdata, and lots arch specific functions > like pci_domain_nr() and pcibios_msi_controller() required. > We could separate pci_host_bridge creat

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Yijing Wang
>> +LIST_HEAD(pci_host_bridge_list); >> +DECLARE_RWSEM(pci_host_bridge_sem); > > Unless the pci_host_bridge_sem is accessed thousands of times per second, > it's normally better to use a simple mutex instead. OK, I will use simple mutex instead. > >> +static struct resource busn_resource = { >

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Arnd Bergmann
On Tuesday 18 November 2014 16:32:26 Yijing Wang wrote: > >> +static struct resource busn_resource = { > >> + .name = "PCI busn", > >> + .start = 0, > >> + .end= 255, > >> + .flags = IORESOURCE_BUS, > >> +}; > > > > I think it would be better to require callers to pass the bus resourc

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Yijing Wang
On 2014/11/18 17:30, Arnd Bergmann wrote: > On Tuesday 18 November 2014 16:32:26 Yijing Wang wrote: > +static struct resource busn_resource = { + .name = "PCI busn", + .start = 0, + .end= 255, + .flags = IORESOURCE_BUS, +}; >>> >>> I think it would be bett

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Arnd Bergmann
On Tuesday 18 November 2014 19:44:36 Yijing Wang wrote: > On 2014/11/18 17:30, Arnd Bergmann wrote: > > On Tuesday 18 November 2014 16:32:26 Yijing Wang wrote: > > > +static struct resource busn_resource = { > +.name = "PCI busn", > +.start = 0, > +.e

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Yijing Wang
We need, some platforms pass NULL pointer as host bridge parent. >>> >>> But those don't have to use the new pci_create_host_bridge() function, >>> right? >> >> As I mentioned in another reply, I hope all pci host drivers could use >> pci_create_host_bridge(), keep different PCI scan interface

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Liviu Dudau
On Tue, Nov 18, 2014 at 08:32:26AM +, Yijing Wang wrote: > > >> +LIST_HEAD(pci_host_bridge_list); > >> +DECLARE_RWSEM(pci_host_bridge_sem); > > > > Unless the pci_host_bridge_sem is accessed thousands of times per second, > > it's normally better to use a simple mutex instead. > > OK, I will

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Liviu Dudau
On Mon, Nov 17, 2014 at 10:21:41AM +, Yijing Wang wrote: > There are some common PCI infos like domain, msi_controller, these > infos are saved in arch PCI sysdata, and lots arch specific functions > like pci_domain_nr() and pcibios_msi_controller() required. > We could separate pci_host_bridge

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Yijing Wang
On 2014/11/18 23:30, Liviu Dudau wrote: > On Mon, Nov 17, 2014 at 10:21:41AM +, Yijing Wang wrote: >> There are some common PCI infos like domain, msi_controller, these >> infos are saved in arch PCI sysdata, and lots arch specific functions >> like pci_domain_nr() and pcibios_msi_controller()

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-18 Thread Yijing Wang
>> We need, some platforms pass NULL pointer as host bridge parent. > > Yijing, > > May I suggest a different approach here? Rather than having to pass an opaque > pointer that gets converted by the host bridge driver back to the private > structure, what about promoting a new style of usage, tha

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-19 Thread Liviu Dudau
On Wed, Nov 19, 2014 at 10:24:52AM +0800, Yijing Wang wrote: > >> We need, some platforms pass NULL pointer as host bridge parent. > > > > Yijing, > > > > May I suggest a different approach here? Rather than having to pass an > > opaque > > pointer that gets converted by the host bridge driver b

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-19 Thread Liviu Dudau
On Wed, Nov 19, 2014 at 01:42:52AM +, Yijing Wang wrote: > On 2014/11/18 23:30, Liviu Dudau wrote: > > On Mon, Nov 17, 2014 at 10:21:41AM +, Yijing Wang wrote: > >> There are some common PCI infos like domain, msi_controller, these > >> infos are saved in arch PCI sysdata, and lots arch spe

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-19 Thread Yijing Wang
>>> Something like this: >>> >>> struct pci_controller { >>> struct pci_host_bridge bridge; >>> /* private host bridge data here */ >>> . >>> }; >>> >>> #define PCI_CONTROLLER(bus) ({ >>> struct pci_host_bridge *hb = to_pci_host_bridge(bus->bridge); \ >>> container_of(hb, st

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-19 Thread Yijing Wang
+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); +

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-20 Thread Liviu Dudau
On Thu, Nov 20, 2014 at 02:47:35AM +, Yijing Wang wrote: > +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_

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-20 Thread Yijing Wang
>>> pci_create_host_bridge() can get pci_host_bridge ops while >>> pci_create_root_bus() gets >>> the bus ops. For find out the MSI controller, the domain number and any >>> other HB >>> specific stuff, you use the HB ops. For config R/W acceses you use bus ops. >>> >> >> I want to unexport pci_c

Re: [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()

2014-11-21 Thread Liviu Dudau
On Fri, Nov 21, 2014 at 02:53:01AM +, Yijing Wang wrote: > >>> pci_create_host_bridge() can get pci_host_bridge ops while > >>> pci_create_root_bus() gets > >>> the bus ops. For find out the MSI controller, the domain number and any > >>> other HB > >>> specific stuff, you use the HB ops. For