dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: robh+dt@kernel.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, dan.j.williams@intel.com,
	devicetree@vger.kernel.org
Subject: Re: [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client
Date: Sun, 8 Sep 2019 17:42:33 +0530	[thread overview]
Message-ID: <20190908121233.GM2672@vkoul-mobl> (raw)
In-Reply-To: <20190906141816.24095-3-peter.ujfalusi@ti.com>

On 06-09-19, 17:18, Peter Ujfalusi wrote:
> Find the DMA domain controller of the client device by iterating up in
> device tree looking for the closest 'dma-domain-controller' property.
> 
> If the client's node is not provided then check the DT root for the
> controller.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
>  drivers/dma/of-dma.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
>  include/linux/of_dma.h |  7 +++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
> index c2d779daa4b5..04b5795cd76b 100644
> --- a/drivers/dma/of-dma.c
> +++ b/drivers/dma/of-dma.c
> @@ -18,6 +18,48 @@
>  static LIST_HEAD(of_dma_list);
>  static DEFINE_MUTEX(of_dma_lock);
>  
> +/**
> + * of_find_dma_domain - Get the domain DMA controller
> + * @np:		device node of the client device
> + *
> + * Look up the DMA controller of the domain the client device is part of.
> + * Finds the dma-domain controller the client device belongs to. It is used when
> + * requesting non slave channels (like channel for memcpy) to make sure that the
> + * channel can be request from a DMA controller which can service the given
> + * domain best.
> + *
> + * Returns the device_node pointer of the DMA controller or succes or NULL on
> + * error.
> + */
> +struct device_node *of_find_dma_domain(struct device_node *np)
> +{
> +	struct device_node *dma_domain = NULL;
> +	phandle dma_phandle;
> +
> +	/*
> +	 * If no device_node is provided look at the root level for system
> +	 * default DMA controller for modules.
> +	 */
> +	if (!np)
> +		np = of_root;
> +
> +	if (!np || !of_node_get(np))
> +		return NULL;
> +
> +	do {
> +		if (of_property_read_u32(np, "dma-domain-controller",
> +					 &dma_phandle))
> +			np = of_get_next_parent(np);

lets have braces around if as well please

> +		else {
> +			dma_domain = of_find_node_by_phandle(dma_phandle);
> +			of_node_put(np);
> +		}
> +	} while (!dma_domain && np);
> +
> +	return dma_domain;
> +}
> +EXPORT_SYMBOL_GPL(of_find_dma_domain);
> +
>  /**
>   * of_dma_find_controller - Get a DMA controller in DT DMA helpers list
>   * @dma_spec:	pointer to DMA specifier as found in the device tree
> diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
> index fd706cdf255c..6eab0a8d3335 100644
> --- a/include/linux/of_dma.h
> +++ b/include/linux/of_dma.h
> @@ -32,6 +32,8 @@ struct of_dma_filter_info {
>  };
>  
>  #ifdef CONFIG_DMA_OF
> +extern struct device_node *of_find_dma_domain(struct device_node *np);
> +
>  extern int of_dma_controller_register(struct device_node *np,
>  		struct dma_chan *(*of_dma_xlate)
>  		(struct of_phandle_args *, struct of_dma *),
> @@ -52,6 +54,11 @@ extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec
>  		struct of_dma *ofdma);
>  
>  #else
> +static inline struct device_node *of_find_dma_domain(struct device_node *np)
> +{
> +	return NULL;
> +}
> +
>  static inline int of_dma_controller_register(struct device_node *np,
>  		struct dma_chan *(*of_dma_xlate)
>  		(struct of_phandle_args *, struct of_dma *),
> -- 
> Peter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

-- 
~Vinod

  reply	other threads:[~2019-09-08 12:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 14:18 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
2019-09-06 14:18 ` [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains Peter Ujfalusi
2019-09-08  7:47   ` Peter Ujfalusi
2019-09-08 12:10     ` Vinod Koul
2019-09-09  6:30       ` Peter Ujfalusi
2019-09-12 17:03         ` Vinod Koul
2019-09-13  7:21           ` Peter Ujfalusi
2019-09-13 10:36             ` Vinod Koul
2019-09-13 12:19               ` Peter Ujfalusi
2019-09-13 13:33                 ` Vinod Koul
2019-09-08 12:06   ` Vinod Koul
2019-09-09  6:00     ` Peter Ujfalusi
2019-09-06 14:18 ` [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client Peter Ujfalusi
2019-09-08 12:12   ` Vinod Koul [this message]
2019-09-06 14:18 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
2019-09-08  7:46   ` Peter Ujfalusi
2019-09-08 12:15   ` Vinod Koul
2019-09-09  5:56     ` Peter Ujfalusi
2019-09-12 16:49       ` Vinod Koul
  -- strict thread matches above, loose matches on Subject: below --
2019-09-06 14:17 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
2019-09-06 14:17 ` [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client Peter Ujfalusi

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=20190908121233.GM2672@vkoul-mobl \
    --to=vkoul@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@ti.com \
    --cc=robh+dt@kernel.org \
    /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).