Patchwork [v3,08/10] of/address: Handle #address-cells > 2 specially

login
register
mail settings
Submitter Thierry Reding
Date July 26, 2012, 7:55 p.m.
Message ID <1343332512-28762-9-git-send-email-thierry.reding@avionic-design.de>
Download mbox | patch
Permalink /patch/173498/
State Not Applicable
Headers show

Comments

Thierry Reding - July 26, 2012, 7:55 p.m.
When a bus specifies #address-cells > 2, of_bus_default_map() now
assumes that the mapping isn't for a physical address but rather an
identifier that needs to match exactly.

This is required by bindings that use multiple cells to translate a
resource to the parent bus (device index, type, ...).

See here for the discussion:

	https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html

Originally-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
Changes in v3:
- new patch

 drivers/of/address.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Rob Herring - July 31, 2012, 8:18 p.m.
On 07/26/2012 02:55 PM, Thierry Reding wrote:
> When a bus specifies #address-cells > 2, of_bus_default_map() now
> assumes that the mapping isn't for a physical address but rather an
> identifier that needs to match exactly.
> 
> This is required by bindings that use multiple cells to translate a
> resource to the parent bus (device index, type, ...).
> 
> See here for the discussion:
> 
> 	https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html
> 
> Originally-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>

Acked-by: Rob Herring <rob.herring@calxeda.com>

> ---
> Changes in v3:
> - new patch
> 
>  drivers/of/address.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 7e262a6..2776119 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -69,6 +69,14 @@ static u64 of_bus_default_map(u32 *addr, const __be32 *range,
>  		 (unsigned long long)cp, (unsigned long long)s,
>  		 (unsigned long long)da);
>  
> +	/*
> +	 * If the number of address cells is larger than 2 we assume the
> +	 * mapping doesn't specify a physical address. Rather, the address
> +	 * specifies an identifier that must match exactly.
> +	 */
> +	if (na > 2 && memcmp(range, addr, na * 4) != 0)
> +		return OF_BAD_ADDR;
> +
>  	if (da < cp || da >= (cp + s))
>  		return OF_BAD_ADDR;
>  	return da - cp;
> 


--
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
Thierry Reding - Aug. 15, 2012, 8:06 p.m.
On Tue, Jul 31, 2012 at 03:18:43PM -0500, Rob Herring wrote:
> On 07/26/2012 02:55 PM, Thierry Reding wrote:
> > When a bus specifies #address-cells > 2, of_bus_default_map() now
> > assumes that the mapping isn't for a physical address but rather an
> > identifier that needs to match exactly.
> > 
> > This is required by bindings that use multiple cells to translate a
> > resource to the parent bus (device index, type, ...).
> > 
> > See here for the discussion:
> > 
> > 	https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html
> > 
> > Originally-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
> 
> Acked-by: Rob Herring <rob.herring@calxeda.com>

Hi Rob,

Were you going to take this through your DT tree? I'm trying to reduce
the number of patches in this series to make it more manageable and
split it into smaller chunks. There are also a couple of issues that
need to be resolved so I don't know if I can get the whole series into
shape for 3.7.

However if you don't think this patch is useful to be applied by itself
I can also carry it until the complete series is ready.

Thierry
Stephen Warren - Sept. 7, 2012, 4:24 p.m.
On 08/15/2012 02:06 PM, Thierry Reding wrote:
> On Tue, Jul 31, 2012 at 03:18:43PM -0500, Rob Herring wrote:
>> On 07/26/2012 02:55 PM, Thierry Reding wrote:
>>> When a bus specifies #address-cells > 2, of_bus_default_map()
>>> now assumes that the mapping isn't for a physical address but
>>> rather an identifier that needs to match exactly.
>>> 
>>> This is required by bindings that use multiple cells to
>>> translate a resource to the parent bus (device index, type,
>>> ...).
>>> 
>>> See here for the discussion:
>>> 
>>> https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html
>>>
>>>
>>> 
Originally-by: Arnd Bergmann <arnd@arndb.de>
>>> Signed-off-by: Thierry Reding
>>> <thierry.reding@avionic-design.de>
>> 
>> Acked-by: Rob Herring <rob.herring@calxeda.com>
> 
> Hi Rob,
> 
> Were you going to take this through your DT tree? I'm trying to
> reduce the number of patches in this series to make it more
> manageable and split it into smaller chunks. There are also a
> couple of issues that need to be resolved so I don't know if I can
> get the whole series into shape for 3.7.
> 
> However if you don't think this patch is useful to be applied by
> itself I can also carry it until the complete series is ready.

Rob,

Are you able to take this patch now for 3.7, or should it be held off
until the Tegra PCIe driver is re-written and requires this
functionality (in which case I'd expect to take this through the Tegra
tree at that time).

For reference, it's at http://patchwork.ozlabs.org/patch/173497/.

Thanks.
--
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
Rob Herring - Sept. 7, 2012, 4:32 p.m.
On 09/07/2012 11:24 AM, Stephen Warren wrote:
> On 08/15/2012 02:06 PM, Thierry Reding wrote:
>> On Tue, Jul 31, 2012 at 03:18:43PM -0500, Rob Herring wrote:
>>> On 07/26/2012 02:55 PM, Thierry Reding wrote:
>>>> When a bus specifies #address-cells > 2, of_bus_default_map()
>>>> now assumes that the mapping isn't for a physical address but
>>>> rather an identifier that needs to match exactly.
>>>>
>>>> This is required by bindings that use multiple cells to
>>>> translate a resource to the parent bus (device index, type,
>>>> ...).
>>>>
>>>> See here for the discussion:
>>>>
>>>> https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html
>>>>
>>>>
>>>>
> Originally-by: Arnd Bergmann <arnd@arndb.de>
>>>> Signed-off-by: Thierry Reding
>>>> <thierry.reding@avionic-design.de>
>>>
>>> Acked-by: Rob Herring <rob.herring@calxeda.com>
>>
>> Hi Rob,
>>
>> Were you going to take this through your DT tree? I'm trying to
>> reduce the number of patches in this series to make it more
>> manageable and split it into smaller chunks. There are also a
>> couple of issues that need to be resolved so I don't know if I can
>> get the whole series into shape for 3.7.
>>
>> However if you don't think this patch is useful to be applied by
>> itself I can also carry it until the complete series is ready.
> 
> Rob,
> 
> Are you able to take this patch now for 3.7, or should it be held off
> until the Tegra PCIe driver is re-written and requires this
> functionality (in which case I'd expect to take this through the Tegra
> tree at that time).
> 
> For reference, it's at http://patchwork.ozlabs.org/patch/173497/.

Applied for 3.7.

Rob

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

Patch

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 7e262a6..2776119 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -69,6 +69,14 @@  static u64 of_bus_default_map(u32 *addr, const __be32 *range,
 		 (unsigned long long)cp, (unsigned long long)s,
 		 (unsigned long long)da);
 
+	/*
+	 * If the number of address cells is larger than 2 we assume the
+	 * mapping doesn't specify a physical address. Rather, the address
+	 * specifies an identifier that must match exactly.
+	 */
+	if (na > 2 && memcmp(range, addr, na * 4) != 0)
+		return OF_BAD_ADDR;
+
 	if (da < cp || da >= (cp + s))
 		return OF_BAD_ADDR;
 	return da - cp;