From: Robin Murphy <robin.murphy@arm.com>
To: Maxime Ripard <maxime.ripard@bootlin.com>,
Mark Rutland <mark.rutland@arm.com>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Chen-Yu Tsai <wens@csie.org>
Cc: devicetree@vger.kernel.org, Yong Deng <yong.deng@magewell.com>,
Arnd Bergmann <arnd@arndb.de>,
dri-devel@lists.freedesktop.org,
Dave Martin <dave.martin@arm.com>,
Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Georgi Djakov <georgi.djakov@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 3/7] of: address: Add parent pointer to the __of_translate_address args
Date: Tue, 12 Feb 2019 18:02:27 +0000 [thread overview]
Message-ID: <fbac5719-5d76-e7f4-5e5e-2d5167783106@arm.com> (raw)
In-Reply-To: <57fa05909120919f33590fed11bd4041467a09f5.1549897336.git-series.maxime.ripard@bootlin.com>
On 11/02/2019 15:02, Maxime Ripard wrote:
> The __of_translate_address function is used to translate the device tree
> addresses to physical addresses using the various ranges property to create
> the offset.
>
> However, it's shared between the CPU addresses (based on the ranges
> property) and the DMA addresses (based on dma-ranges). Since we're going to
> add support for a DMA parent node that is not the DT parent node, we need
> to change the logic a bit to have an optional parent node that we should
> use.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
> drivers/of/address.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 2270373b30ab..4c5dc21c71ca 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -569,10 +569,10 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
> * relative to that node.
> */
> static u64 __of_translate_address(struct device_node *dev,
> + struct device_node *parent,
> const __be32 *in_addr, const char *rprop,
> struct device_node **host)
> {
> - struct device_node *parent = NULL;
> struct of_bus *bus, *pbus;
> __be32 addr[OF_MAX_ADDR_CELLS];
> int na, ns, pna, pns;
> @@ -583,11 +583,14 @@ static u64 __of_translate_address(struct device_node *dev,
> /* Increase refcount at current level */
> of_node_get(dev);
>
> - *host = NULL;
> - /* Get parent & match bus type */
> - parent = of_get_parent(dev);
> - if (parent == NULL)
> - goto bail;
> + if (!parent) {
I would have suggested having the callers make the of_get_parent() call
themselves, but having pulled up the code for a look at the whole
function, there's a bigger issue at play. The parent traversal happens
within the main translation loop as well, and topologies could quite
feasibly exist where that makes a difference, e.g.:
icc {
#interconnect-cells = <0>;
dma-ranges = <...>;
};
subsystem {
interconnects = <&icc>;
interconnect-names = "dma";
intermediate-bus {
dma-ranges;
device {
...
};
};
};
or:
icc2 {
#interconnect-cells = <0>;
dma-ranges = <...>;
};
icc1 {
#interconnect-cells = <0>;
dma-ranges = <...>;
interconnects = <&icc2>;
interconnect-names = "dma";
};
device {
interconnects = <&icc1>;
interconnect-names = "dma";
...
};
So I guess the answer is to switch this over to using a callback and
have the callers pass of_get_parent/of_get_dma_parent in as appropriate.
Robin.
> + *host = NULL;
> + /* Get parent & match bus type */
> + parent = of_get_parent(dev);
> + if (parent == NULL)
> + goto bail;
> + }
> +
> bus = of_match_bus(parent);
>
> /* Count address cells & copy address locally */
> @@ -665,7 +668,7 @@ u64 of_translate_address(struct device_node *dev, const __be32 *in_addr)
> struct device_node *host;
> u64 ret;
>
> - ret = __of_translate_address(dev, in_addr, "ranges", &host);
> + ret = __of_translate_address(dev, NULL, in_addr, "ranges", &host);
> if (host) {
> of_node_put(host);
> return OF_BAD_ADDR;
> @@ -680,7 +683,7 @@ u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr)
> struct device_node *host;
> u64 ret;
>
> - ret = __of_translate_address(dev, in_addr, "dma-ranges", &host);
> + ret = __of_translate_address(dev, NULL, in_addr, "dma-ranges", &host);
>
> if (host) {
> of_node_put(host);
> @@ -736,7 +739,7 @@ static u64 of_translate_ioport(struct device_node *dev, const __be32 *in_addr,
> unsigned long port;
> struct device_node *host;
>
> - taddr = __of_translate_address(dev, in_addr, "ranges", &host);
> + taddr = __of_translate_address(dev, NULL, in_addr, "ranges", &host);
> if (host) {
> /* host-specific port access */
> port = logic_pio_trans_hwaddr(&host->fwnode, taddr, size);
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-02-12 18:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 15:02 [PATCH v3 0/7] sunxi: Add DT representation for the MBUS controller Maxime Ripard
2019-02-11 15:02 ` [PATCH v3 1/7] dt-bindings: interconnect: Add a dma interconnect name Maxime Ripard
2019-03-01 17:48 ` Georgi Djakov
2019-03-05 15:53 ` Maxime Ripard
2019-03-05 16:14 ` Robin Murphy
2019-03-07 15:15 ` Georgi Djakov
2019-03-07 15:47 ` Maxime Ripard
2019-03-07 16:09 ` Chen-Yu Tsai
2019-03-11 10:11 ` Maxime Ripard
2019-03-11 14:11 ` Chen-Yu Tsai
2019-03-13 11:48 ` Georgi Djakov
2019-02-11 15:02 ` [PATCH v3 2/7] dt-bindings: bus: Add binding for the Allwinner MBUS controller Maxime Ripard
2019-02-12 18:53 ` Robin Murphy
2019-02-11 15:02 ` [PATCH v3 3/7] of: address: Add parent pointer to the __of_translate_address args Maxime Ripard
2019-02-12 18:02 ` Robin Murphy [this message]
2019-02-11 15:02 ` [PATCH v3 4/7] of: address: Add support for the parent DMA bus Maxime Ripard
2019-02-12 18:15 ` Robin Murphy
2019-02-11 15:02 ` [PATCH v3 5/7] drm/sun4i: Rely on dma interconnect for our RAM offset Maxime Ripard
2019-02-12 18:46 ` Robin Murphy
2019-02-13 15:41 ` Maxime Ripard
2019-02-13 16:40 ` Robin Murphy
2019-02-19 10:55 ` Maxime Ripard
2019-03-05 16:11 ` Robin Murphy
2019-02-11 15:02 ` [PATCH v3 6/7] clk: sunxi-ng: sun5i: Export the MBUS clock Maxime Ripard
2019-02-11 15:02 ` [PATCH v3 7/7] ARM: dts: sun5i: Add the MBUS controller Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fbac5719-5d76-e7f4-5e5e-2d5167783106@arm.com \
--to=robin.murphy@arm.com \
--cc=arnd@arndb.de \
--cc=dave.martin@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=frowand.list@gmail.com \
--cc=georgi.djakov@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@bootlin.com \
--cc=paul.kocialkowski@bootlin.com \
--cc=robh+dt@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wens@csie.org \
--cc=yong.deng@magewell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).