Re: [PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-04-08 Thread Rob Herring
Adding PPC and Microblaze maintainers.

On 04/08/2013 09:33 AM, Andrew Murray wrote:
> This patch factors out common implementation patterns to reduce overall kernel
> code and provide a means for host bridge drivers to directly obtain struct
> resources from the DT's ranges property without relying on architecture 
> specific
> DT handling. This will make it easier to write archiecture independent host 
> bridge
> drivers and mitigate against further duplication of DT parsing code.
> 
> This patch can be used in the following way:
> 
>   struct of_pci_range_parser parser;
>   struct of_pci_range range;
> 
>   if (of_pci_range_parser(, np))
>   ; //no ranges property
> 
>   for_each_of_pci_range(, ) {
> 
>   /*
>   directly access properties of the address range, e.g.:
>   range.pci_space, range.pci_addr, range.cpu_addr,
>   range.size, range.flags
> 
>   alternatively obtain a struct resource, e.g.:
>   struct resource res;
>   of_pci_range_to_resource(, np, );
>   */
>   }
> 
> Additionally the implementation takes care of adjacent ranges and merges them
> into a single range (as was the case with powerpc and microblaze).
> 
> The modifications to microblaze, mips and powerpc have not been tested.
> 
> Signed-off-by: Andrew Murray 
> Signed-off-by: Liviu Dudau 
> Signed-off-by: Thomas Petazzoni 
> ---
> Compared to the v3 sent by Andrew Murray, the following changes have
> been made:
> 
>  * Unify and move duplicate pci_process_bridge_OF_ranges functions to
>drivers/of/of_pci.c as suggested by Rob Herring

This part should really be a separate patch with just the move and
should have acks from PPC and Microblaze maintainers.

Otherwise it looks okay to me.

Rob

>  * Fix potential build errors with Microblaze/MIPS
> 
> Compared to "[PATCH v5 01/17] of/pci: Provide support for parsing PCI DT
> ranges property", the following changes have been made:
> 
>  * Correct use of IORESOURCE_* as suggested by Russell King
> 
>  * Improved interface and naming as suggested by Thierry Reding
> 
> Compared to the v2 sent by Andrew Murray, Thomas Petazzoni did:
> 
>  * Add a memset() on the struct of_pci_range_iter when starting the
>for loop in for_each_pci_range(). Otherwise, with an uninitialized
>of_pci_range_iter, of_pci_process_ranges() may crash.
> 
>  * Add parenthesis around 'res', 'np' and 'iter' in the
>for_each_of_pci_range macro definitions. Otherwise, passing
>something like  as 'res' didn't work.
> 
>  * Rebased on top of 3.9-rc2, which required fixing a few conflicts in
>the Microblaze code.
> 
> v2:
>   This follows on from suggestions made by Grant Likely
>   (marc.info/?l=linux-kernel=136079602806328)
> ---
>  arch/microblaze/include/asm/pci-bridge.h |5 +-
>  arch/microblaze/pci/pci-common.c |  192 
> --
>  arch/mips/pci/pci.c  |   50 +++--
>  arch/powerpc/include/asm/pci-bridge.h|5 +-
>  arch/powerpc/kernel/pci-common.c |  192 
> --
>  drivers/of/address.c |   63 ++
>  drivers/of/of_pci.c  |  168 ++
>  include/linux/of_address.h   |   42 +++
>  include/linux/of_pci.h   |3 +
>  9 files changed, 294 insertions(+), 426 deletions(-)
> 
> diff --git a/arch/microblaze/include/asm/pci-bridge.h 
> b/arch/microblaze/include/asm/pci-bridge.h
> index cb5d397..5783cd6 100644
> --- a/arch/microblaze/include/asm/pci-bridge.h
> +++ b/arch/microblaze/include/asm/pci-bridge.h
> @@ -10,6 +10,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  struct device_node;
>  
> @@ -132,10 +133,6 @@ extern void setup_indirect_pci(struct pci_controller 
> *hose,
>  extern struct pci_controller *pci_find_hose_for_OF_device(
>   struct device_node *node);
>  
> -/* Fill up host controller resources from the OF node */
> -extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
> - struct device_node *dev, int primary);
> -
>  /* Allocate & free a PCI host bridge structure */
>  extern struct pci_controller *pcibios_alloc_controller(struct device_node 
> *dev);
>  extern void pcibios_free_controller(struct pci_controller *phb);
> diff --git a/arch/microblaze/pci/pci-common.c 
> b/arch/microblaze/pci/pci-common.c
> index 9ea521e..2735ad9 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -622,198 +622,6 @@ void pci_resource_to_user(const struct pci_dev *dev, 
> int bar,
>   *end = rsrc->end - offset;
>  }
>  
> -/**
> - * pci_process_bridge_OF_ranges - Parse PCI bridge resources from device tree
> - * @hose: newly allocated pci_controller to be setup
> - * @dev: device node of the host bridge
> - * @primary: set 

Re: [PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-04-08 Thread Rob Herring
Adding PPC and Microblaze maintainers.

On 04/08/2013 09:33 AM, Andrew Murray wrote:
 This patch factors out common implementation patterns to reduce overall kernel
 code and provide a means for host bridge drivers to directly obtain struct
 resources from the DT's ranges property without relying on architecture 
 specific
 DT handling. This will make it easier to write archiecture independent host 
 bridge
 drivers and mitigate against further duplication of DT parsing code.
 
 This patch can be used in the following way:
 
   struct of_pci_range_parser parser;
   struct of_pci_range range;
 
   if (of_pci_range_parser(parser, np))
   ; //no ranges property
 
   for_each_of_pci_range(parser, range) {
 
   /*
   directly access properties of the address range, e.g.:
   range.pci_space, range.pci_addr, range.cpu_addr,
   range.size, range.flags
 
   alternatively obtain a struct resource, e.g.:
   struct resource res;
   of_pci_range_to_resource(range, np, res);
   */
   }
 
 Additionally the implementation takes care of adjacent ranges and merges them
 into a single range (as was the case with powerpc and microblaze).
 
 The modifications to microblaze, mips and powerpc have not been tested.
 
 Signed-off-by: Andrew Murray andrew.mur...@arm.com
 Signed-off-by: Liviu Dudau liviu.du...@arm.com
 Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
 ---
 Compared to the v3 sent by Andrew Murray, the following changes have
 been made:
 
  * Unify and move duplicate pci_process_bridge_OF_ranges functions to
drivers/of/of_pci.c as suggested by Rob Herring

This part should really be a separate patch with just the move and
should have acks from PPC and Microblaze maintainers.

Otherwise it looks okay to me.

Rob

  * Fix potential build errors with Microblaze/MIPS
 
 Compared to [PATCH v5 01/17] of/pci: Provide support for parsing PCI DT
 ranges property, the following changes have been made:
 
  * Correct use of IORESOURCE_* as suggested by Russell King
 
  * Improved interface and naming as suggested by Thierry Reding
 
 Compared to the v2 sent by Andrew Murray, Thomas Petazzoni did:
 
  * Add a memset() on the struct of_pci_range_iter when starting the
for loop in for_each_pci_range(). Otherwise, with an uninitialized
of_pci_range_iter, of_pci_process_ranges() may crash.
 
  * Add parenthesis around 'res', 'np' and 'iter' in the
for_each_of_pci_range macro definitions. Otherwise, passing
something like foobar as 'res' didn't work.
 
  * Rebased on top of 3.9-rc2, which required fixing a few conflicts in
the Microblaze code.
 
 v2:
   This follows on from suggestions made by Grant Likely
   (marc.info/?l=linux-kernelm=136079602806328)
 ---
  arch/microblaze/include/asm/pci-bridge.h |5 +-
  arch/microblaze/pci/pci-common.c |  192 
 --
  arch/mips/pci/pci.c  |   50 +++--
  arch/powerpc/include/asm/pci-bridge.h|5 +-
  arch/powerpc/kernel/pci-common.c |  192 
 --
  drivers/of/address.c |   63 ++
  drivers/of/of_pci.c  |  168 ++
  include/linux/of_address.h   |   42 +++
  include/linux/of_pci.h   |3 +
  9 files changed, 294 insertions(+), 426 deletions(-)
 
 diff --git a/arch/microblaze/include/asm/pci-bridge.h 
 b/arch/microblaze/include/asm/pci-bridge.h
 index cb5d397..5783cd6 100644
 --- a/arch/microblaze/include/asm/pci-bridge.h
 +++ b/arch/microblaze/include/asm/pci-bridge.h
 @@ -10,6 +10,7 @@
  #include linux/pci.h
  #include linux/list.h
  #include linux/ioport.h
 +#include linux/of_pci.h
  
  struct device_node;
  
 @@ -132,10 +133,6 @@ extern void setup_indirect_pci(struct pci_controller 
 *hose,
  extern struct pci_controller *pci_find_hose_for_OF_device(
   struct device_node *node);
  
 -/* Fill up host controller resources from the OF node */
 -extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
 - struct device_node *dev, int primary);
 -
  /* Allocate  free a PCI host bridge structure */
  extern struct pci_controller *pcibios_alloc_controller(struct device_node 
 *dev);
  extern void pcibios_free_controller(struct pci_controller *phb);
 diff --git a/arch/microblaze/pci/pci-common.c 
 b/arch/microblaze/pci/pci-common.c
 index 9ea521e..2735ad9 100644
 --- a/arch/microblaze/pci/pci-common.c
 +++ b/arch/microblaze/pci/pci-common.c
 @@ -622,198 +622,6 @@ void pci_resource_to_user(const struct pci_dev *dev, 
 int bar,
   *end = rsrc-end - offset;
  }
  
 -/**
 - * pci_process_bridge_OF_ranges - Parse PCI bridge resources from device tree
 - * @hose: newly allocated pci_controller to be setup
 - * @dev: device node of the 

Re: [PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-04-03 Thread Jingoo Han
On Wednesday, March 27, 2013 10:04 PM, Thierry Reding wrote:
> 
> On Tue, Mar 26, 2013 at 04:20:23PM +, Andrew Murray wrote:
> > This patch factors out common implementation patterns to reduce overall 
> > kernel
> > code and provide a means for host bridge drivers to directly obtain struct
> > resources from the DT's ranges property without relying on architecture 
> > specific
> > DT handling. This will make it easier to write archiecture independent host 
> > bridge
> > drivers and mitigate against further duplication of DT parsing code.
> >
> > This patch can be used in the following way:
> >
> > struct of_pci_range_parser parser;
> > struct of_pci_range range;
> >
> > if (of_pci_range_parser(, np))
> > ; //no ranges property
> >
> > for_each_of_pci_range(, ) {
> >
> > /*
> > directly access properties of the address range, e.g.:
> > range.pci_space, range.pci_addr, range.cpu_addr,
> > range.size, range.flags
> >
> > alternatively obtain a struct resource, e.g.:
> > struct resource res;
> > of_pci_range_to_resource(, np, );
> > */
> > }
> >
> > Additionally the implementation takes care of adjacent ranges and merges 
> > them
> > into a single range (as was the case with powerpc and microblaze).
> >
> > The modifications to microblaze, mips and powerpc have not been tested.
> >
> > Signed-off-by: Andrew Murray 
> > Signed-off-by: Liviu Dudau 
> > Signed-off-by: Thomas Petazzoni 
> 
> Tested-by: Thierry Reding 

It works properly with Exynos5440.

Tested-by: Jingoo Han 



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-04-03 Thread Jingoo Han
On Wednesday, March 27, 2013 10:04 PM, Thierry Reding wrote:
 
 On Tue, Mar 26, 2013 at 04:20:23PM +, Andrew Murray wrote:
  This patch factors out common implementation patterns to reduce overall 
  kernel
  code and provide a means for host bridge drivers to directly obtain struct
  resources from the DT's ranges property without relying on architecture 
  specific
  DT handling. This will make it easier to write archiecture independent host 
  bridge
  drivers and mitigate against further duplication of DT parsing code.
 
  This patch can be used in the following way:
 
  struct of_pci_range_parser parser;
  struct of_pci_range range;
 
  if (of_pci_range_parser(parser, np))
  ; //no ranges property
 
  for_each_of_pci_range(parser, range) {
 
  /*
  directly access properties of the address range, e.g.:
  range.pci_space, range.pci_addr, range.cpu_addr,
  range.size, range.flags
 
  alternatively obtain a struct resource, e.g.:
  struct resource res;
  of_pci_range_to_resource(range, np, res);
  */
  }
 
  Additionally the implementation takes care of adjacent ranges and merges 
  them
  into a single range (as was the case with powerpc and microblaze).
 
  The modifications to microblaze, mips and powerpc have not been tested.
 
  Signed-off-by: Andrew Murray andrew.mur...@arm.com
  Signed-off-by: Liviu Dudau liviu.du...@arm.com
  Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
 
 Tested-by: Thierry Reding thierry.red...@avionic-design.de

It works properly with Exynos5440.

Tested-by: Jingoo Han jg1@samsung.com



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-03-27 Thread Thierry Reding
On Tue, Mar 26, 2013 at 04:20:23PM +, Andrew Murray wrote:
> This patch factors out common implementation patterns to reduce overall kernel
> code and provide a means for host bridge drivers to directly obtain struct
> resources from the DT's ranges property without relying on architecture 
> specific
> DT handling. This will make it easier to write archiecture independent host 
> bridge
> drivers and mitigate against further duplication of DT parsing code.
> 
> This patch can be used in the following way:
> 
>   struct of_pci_range_parser parser;
>   struct of_pci_range range;
> 
>   if (of_pci_range_parser(, np))
>   ; //no ranges property
> 
>   for_each_of_pci_range(, ) {
> 
>   /*
>   directly access properties of the address range, e.g.:
>   range.pci_space, range.pci_addr, range.cpu_addr,
>   range.size, range.flags
> 
>   alternatively obtain a struct resource, e.g.:
>   struct resource res;
>   of_pci_range_to_resource(, np, );
>   */
>   }
> 
> Additionally the implementation takes care of adjacent ranges and merges them
> into a single range (as was the case with powerpc and microblaze).
> 
> The modifications to microblaze, mips and powerpc have not been tested.
> 
> Signed-off-by: Andrew Murray 
> Signed-off-by: Liviu Dudau 
> Signed-off-by: Thomas Petazzoni 

Tested-by: Thierry Reding 


pgpa4aVD0xnry.pgp
Description: PGP signature


Re: [PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-03-27 Thread Thierry Reding
On Tue, Mar 26, 2013 at 04:20:23PM +, Andrew Murray wrote:
 This patch factors out common implementation patterns to reduce overall kernel
 code and provide a means for host bridge drivers to directly obtain struct
 resources from the DT's ranges property without relying on architecture 
 specific
 DT handling. This will make it easier to write archiecture independent host 
 bridge
 drivers and mitigate against further duplication of DT parsing code.
 
 This patch can be used in the following way:
 
   struct of_pci_range_parser parser;
   struct of_pci_range range;
 
   if (of_pci_range_parser(parser, np))
   ; //no ranges property
 
   for_each_of_pci_range(parser, range) {
 
   /*
   directly access properties of the address range, e.g.:
   range.pci_space, range.pci_addr, range.cpu_addr,
   range.size, range.flags
 
   alternatively obtain a struct resource, e.g.:
   struct resource res;
   of_pci_range_to_resource(range, np, res);
   */
   }
 
 Additionally the implementation takes care of adjacent ranges and merges them
 into a single range (as was the case with powerpc and microblaze).
 
 The modifications to microblaze, mips and powerpc have not been tested.
 
 Signed-off-by: Andrew Murray andrew.mur...@arm.com
 Signed-off-by: Liviu Dudau liviu.du...@arm.com
 Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com

Tested-by: Thierry Reding thierry.red...@avionic-design.de


pgpa4aVD0xnry.pgp
Description: PGP signature