public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] dw_dmac: don't exceed AHB master number in dwc_get_data_width
@ 2013-01-17  8:03 Andy Shevchenko
  2013-01-17  8:05 ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2013-01-17  8:03 UTC (permalink / raw)
  To: Viresh Kumar, Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko

The driver assumes that hardware has two AHB masters which might not be always
true. In such cases we must not exceed number of the AHB masters present in the
hardware. In the proposed scheme in this patch, we would choose the master with
highest possible number whenever we exceed max AHB masters.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Since v3:
 - substitute "else if" by "else", we don't pass anything else than SRC_MASTER
   or DST_MASTER

 drivers/dma/dw_dmac.c |   33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 30ff2a4..2ab3f3c 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -46,13 +46,29 @@ static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave)
 	return slave ? slave->src_master : 1;
 }
 
+#define SRC_MASTER	0
+#define DST_MASTER	1
+
+static inline unsigned int dwc_get_master(struct dma_chan *chan, int master)
+{
+	struct dw_dma *dw = to_dw_dma(chan->device);
+	struct dw_dma_slave *dws = chan->private;
+	unsigned int m;
+
+	if (master == SRC_MASTER)
+		m = dwc_get_sms(dws);
+	else
+		m = dwc_get_dms(dws);
+
+	return min_t(unsigned int, dw->nr_masters - 1, m);
+}
+
 #define DWC_DEFAULT_CTLLO(_chan) ({				\
-		struct dw_dma_slave *__slave = (_chan->private);	\
 		struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan);	\
 		struct dma_slave_config	*_sconfig = &_dwc->dma_sconfig;	\
 		bool _is_slave = is_slave_direction(_dwc->direction);	\
-		int _dms = dwc_get_dms(__slave);		\
-		int _sms = dwc_get_sms(__slave);		\
+		int _dms = dwc_get_master(_chan, DST_MASTER);		\
+		int _sms = dwc_get_master(_chan, SRC_MASTER);		\
 		u8 _smsize = _is_slave ? _sconfig->src_maxburst :	\
 			DW_DMA_MSIZE_16;			\
 		u8 _dmsize = _is_slave ? _sconfig->dst_maxburst :	\
@@ -73,20 +89,11 @@ static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave)
  */
 #define NR_DESCS_PER_CHANNEL	64
 
-#define SRC_MASTER	0
-#define DST_MASTER	1
-
 static inline unsigned int dwc_get_data_width(struct dma_chan *chan, int master)
 {
 	struct dw_dma *dw = to_dw_dma(chan->device);
-	struct dw_dma_slave *dws = chan->private;
-
-	if (master == SRC_MASTER)
-		return dw->data_width[dwc_get_sms(dws)];
-	else if (master == DST_MASTER)
-		return dw->data_width[dwc_get_dms(dws)];
 
-	return 0;
+	return dw->data_width[dwc_get_master(chan, master)];
 }
 
 /*----------------------------------------------------------------------*/
-- 
1.7.10.4


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

* Re: [PATCH v4] dw_dmac: don't exceed AHB master number in dwc_get_data_width
  2013-01-17  8:03 [PATCH v4] dw_dmac: don't exceed AHB master number in dwc_get_data_width Andy Shevchenko
@ 2013-01-17  8:05 ` Viresh Kumar
  2013-01-21  4:51   ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2013-01-17  8:05 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Vinod Koul, linux-kernel, spear-devel

On Thu, Jan 17, 2013 at 1:33 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> The driver assumes that hardware has two AHB masters which might not be always
> true. In such cases we must not exceed number of the AHB masters present in the
> hardware. In the proposed scheme in this patch, we would choose the master with
> highest possible number whenever we exceed max AHB masters.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Looks good now.

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

* Re: [PATCH v4] dw_dmac: don't exceed AHB master number in dwc_get_data_width
  2013-01-17  8:05 ` Viresh Kumar
@ 2013-01-21  4:51   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2013-01-21  4:51 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Andy Shevchenko, linux-kernel, spear-devel

On Thu, Jan 17, 2013 at 01:35:47PM +0530, Viresh Kumar wrote:
> On Thu, Jan 17, 2013 at 1:33 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > The driver assumes that hardware has two AHB masters which might not be always
> > true. In such cases we must not exceed number of the AHB masters present in the
> > hardware. In the proposed scheme in this patch, we would choose the master with
> > highest possible number whenever we exceed max AHB masters.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Applied, Thanks

--
~Vinod

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

end of thread, other threads:[~2013-01-21  5:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17  8:03 [PATCH v4] dw_dmac: don't exceed AHB master number in dwc_get_data_width Andy Shevchenko
2013-01-17  8:05 ` Viresh Kumar
2013-01-21  4:51   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox