linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: of_dma: approximate an average distribution
@ 2016-05-11 13:15 Niklas Söderlund
  2016-05-11 13:49 ` Niklas Söderlund
  2016-05-14  8:04 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas Söderlund @ 2016-05-11 13:15 UTC (permalink / raw)
  To: dan.j.williams, vinod.koul, dmaengine, linux-kernel, arnd
  Cc: linux-renesas-soc, Niklas Söderlund

Currently the following DT description would result in dmac0 always
being tried first and dmac1 second if dmac0 was unavailable. This
results in heavier use of dmac0 then of dmac1. This patch adds an
approximate average distribution over the two nodes lessening the load
of anyone of them.

   i2c6: i2c@e60b0000 {
           ...
           dmas = <&dmac0 0x77>, <&dmac0 0x78>,
                  <&dmac1 0x77>, <&dmac1 0x78>;
           dma-names = "tx", "rx", "tx", "rx";
           ...
   };

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/dma/of-dma.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index 1e1f298..faae0bf 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -240,8 +240,9 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
 	struct of_phandle_args	dma_spec;
 	struct of_dma		*ofdma;
 	struct dma_chan		*chan;
-	int			count, i;
+	int			count, i, start;
 	int			ret_no_channel = -ENODEV;
+	static atomic_t		last_index;
 
 	if (!np || !name) {
 		pr_err("%s: not enough information provided\n", __func__);
@@ -259,8 +260,15 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
 		return ERR_PTR(-ENODEV);
 	}
 
+	/*
+	 * approximate an average distribution across multiple
+	 * entries with the same name
+	 */
+	start = atomic_inc_return(&last_index);
 	for (i = 0; i < count; i++) {
-		if (of_dma_match_channel(np, name, i, &dma_spec))
+		if (of_dma_match_channel(np, name,
+					 (i + start) % count,
+					 &dma_spec))
 			continue;
 
 		mutex_lock(&of_dma_lock);
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: of_dma: approximate an average distribution
  2016-05-11 13:15 [PATCH] dmaengine: of_dma: approximate an average distribution Niklas Söderlund
@ 2016-05-11 13:49 ` Niklas Söderlund
  2016-05-14  8:04 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Söderlund @ 2016-05-11 13:49 UTC (permalink / raw)
  To: dan.j.williams, vinod.koul, dmaengine, linux-kernel, arnd
  Cc: linux-renesas-soc

In my haste I forgot the most important part of this patch, I'm sorry 
Arnd.

Suggested-by: Arnd Bergmann <arnd@arndb.de>

On 2016-05-11 15:15:11 +0200, Niklas Söderlund wrote:
> Currently the following DT description would result in dmac0 always
> being tried first and dmac1 second if dmac0 was unavailable. This
> results in heavier use of dmac0 then of dmac1. This patch adds an
> approximate average distribution over the two nodes lessening the load
> of anyone of them.
> 
>    i2c6: i2c@e60b0000 {
>            ...
>            dmas = <&dmac0 0x77>, <&dmac0 0x78>,
>                   <&dmac1 0x77>, <&dmac1 0x78>;
>            dma-names = "tx", "rx", "tx", "rx";
>            ...
>    };
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/dma/of-dma.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
> index 1e1f298..faae0bf 100644
> --- a/drivers/dma/of-dma.c
> +++ b/drivers/dma/of-dma.c
> @@ -240,8 +240,9 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
>  	struct of_phandle_args	dma_spec;
>  	struct of_dma		*ofdma;
>  	struct dma_chan		*chan;
> -	int			count, i;
> +	int			count, i, start;
>  	int			ret_no_channel = -ENODEV;
> +	static atomic_t		last_index;
>  
>  	if (!np || !name) {
>  		pr_err("%s: not enough information provided\n", __func__);
> @@ -259,8 +260,15 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
>  		return ERR_PTR(-ENODEV);
>  	}
>  
> +	/*
> +	 * approximate an average distribution across multiple
> +	 * entries with the same name
> +	 */
> +	start = atomic_inc_return(&last_index);
>  	for (i = 0; i < count; i++) {
> -		if (of_dma_match_channel(np, name, i, &dma_spec))
> +		if (of_dma_match_channel(np, name,
> +					 (i + start) % count,
> +					 &dma_spec))
>  			continue;
>  
>  		mutex_lock(&of_dma_lock);
> -- 
> 2.8.2
> 

-- 
Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: of_dma: approximate an average distribution
  2016-05-11 13:15 [PATCH] dmaengine: of_dma: approximate an average distribution Niklas Söderlund
  2016-05-11 13:49 ` Niklas Söderlund
@ 2016-05-14  8:04 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2016-05-14  8:04 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: dan.j.williams, dmaengine, linux-kernel, arnd, linux-renesas-soc

On Wed, May 11, 2016 at 03:15:11PM +0200, Niklas Söderlund wrote:
> Currently the following DT description would result in dmac0 always
> being tried first and dmac1 second if dmac0 was unavailable. This
> results in heavier use of dmac0 then of dmac1. This patch adds an
> approximate average distribution over the two nodes lessening the load
> of anyone of them.
> 
>    i2c6: i2c@e60b0000 {
>            ...
>            dmas = <&dmac0 0x77>, <&dmac0 0x78>,
>                   <&dmac1 0x77>, <&dmac1 0x78>;
>            dma-names = "tx", "rx", "tx", "rx";
>            ...
>    };

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-14  7:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-11 13:15 [PATCH] dmaengine: of_dma: approximate an average distribution Niklas Söderlund
2016-05-11 13:49 ` Niklas Söderlund
2016-05-14  8:04 ` Vinod Koul

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