linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] dmaengine: Allow controller drivers to set channel ids
@ 2011-09-22 10:43 Viresh Kumar
  2011-09-22 10:43 ` [PATCH 2/3] dmaengine/dw_dmac: Set channel id's in controller driver Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Viresh Kumar @ 2011-09-22 10:43 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: linux-kernel, armando.visconti, shiraz.hashim, vipin.kumar,
	rajeev-dlh.kumar, deepak.sikri, vipulkumar.samar, amit.virdi,
	viresh.kumar, pratyush.anand, bhupesh.sharma, viresh.linux,
	bhavna.yadav

Currently value of chan_id field is updated by dmaengine.c while the dma device
is registered. In some cases the controller driver may need to assign channel
numbers by itself. For example, dw_dmac.c wants to control the order in which
channels are allocated by dmaengine. So it added channels inside channel list of
dma_device in reverse order. Now channel 7 is allocated first and channel 0 is
allocated last.

But as the channel ids are updated by dmaengine, channel numbers in sysfs will
be overwritten if controller has added channels in reverse order. To represent
correct channel number in sysfs, it is required that dmaengine must not assume
that first channel in list is channel 0 and last is 7.

To handled this situation, chan_ids_set is passed by controller driver inside
struct dma_device. Controller drivers that need to set channel numbers
themselves must pass this field as true.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dmaengine.c   |    7 ++++++-
 include/linux/dmaengine.h |    5 +++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 0e5f684..1d09258 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -735,7 +735,12 @@ int dma_async_device_register(struct dma_device *device)
 			goto err_out;
 		}
 
-		chan->chan_id = chancnt++;
+		/* channel ids are set by controller drivers, don't update it */
+		if (!device->chan_ids_set)
+			chan->chan_id = chancnt;
+
+		chancnt++;
+
 		chan->dev->device.class = &dma_devclass;
 		chan->dev->device.parent = device->dev;
 		chan->dev->chan = chan;
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 19cbe39..b4607f4 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -417,6 +417,8 @@ struct dma_tx_state {
  * @xor_align: alignment shift for xor operations
  * @pq_align: alignment shift for pq operations
  * @fill_align: alignment shift for memset operations
+ * @chan_ids_set: channel id's are already set by driver and must not be
+ * reinitialized by dmaengine.
  * @dev_id: unique device ID
  * @dev: struct device reference for dma mapping api
  * @device_alloc_chan_resources: allocate resources and return the
@@ -456,6 +458,9 @@ struct dma_device {
 	u8 fill_align;
 	#define DMA_HAS_PQ_CONTINUE (1 << 15)
 
+	/* sysfs */
+	bool chan_ids_set;
+
 	int dev_id;
 	struct device *dev;
 
-- 
1.7.2.2


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

end of thread, other threads:[~2011-11-28  4:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-22 10:43 [PATCH 1/3] dmaengine: Allow controller drivers to set channel ids Viresh Kumar
2011-09-22 10:43 ` [PATCH 2/3] dmaengine/dw_dmac: Set channel id's in controller driver Viresh Kumar
2011-09-22 10:43 ` [PATCH 3/3] dmaengine/dw_dmac: Don't use magic number for total number of channels Viresh Kumar
2011-09-28  9:08 ` [PATCH 1/3] dmaengine: Allow controller drivers to set channel ids Vinod Koul
2011-10-13  8:46   ` Viresh Kumar
2011-10-14  5:43     ` Vinod Koul
2011-10-31 10:22       ` Viresh Kumar
2011-11-16 11:41         ` Viresh Kumar
2011-11-28  4:05   ` Viresh Kumar

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