Skip to contentSkip to conversation

DMA: Expand dmaengine implementation for more DMACs

RFC PATCH In review Peter Pearse 3 participants 3 messages Jul 3, 2007 – Jul 11, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 DMA: Expand dmaengine implementation for more DMACs

Hi,

The existing DMAC used by the dmaengine API (Intel IOAT) assumes all possible clients can use any available DMA channel.

Some other DMACs restrict particular peripherals to particular DMA channels.

The patch below (against v2.6.22-rc7) extends the dmaengine implementation to allow such DMACs to differentiate between clients.

Regards

Peter Pearse

---
From: Peter Pearse <[email protected]>

Pass client data down to the dmaengine DMAC implementation code.

---
diff -purN RFCbase/drivers/dma/dmaengine.c
RFCpatched/drivers/dma/dmaengine.c

drivers/dma/dmaengine.c +0 -1
@@ -146,7 +146,7 @@ static struct dma_chan *dma_client_chan_
 			if (chan->client)
 				continue;
 
-			desc =

chan->device->device_alloc_chan_resources(chan);
+ desc =
chan->device->device_alloc_chan_resources(chan, client);
if (desc >= 0) {
kref_get(&device->refcount); kref_init(&chan->refcount);

drivers/dma/ioatdma.c +1 -1
diff -purN RFCbase/drivers/dma/ioatdma.c RFCpatched/drivers/dma/ioatdma.c
@@ -110,7 +110,7 @@ static struct ioat_desc_sw *ioat_dma_all
 static void ioat_start_null_desc(struct ioat_dma_chan *ioat_chan);
 
 /* returns the actual number of allocated descriptors */
-static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
+static int ioat_dma_alloc_chan_resources(struct dma_chan, struct dma_client

*client)
{
struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); struct ioat_desc_sw *desc = NULL;
diff -purN RFCbase/include/linux/dmaengine.h RFCpatched/include/linux/dmaengine.h
--- RFCbase/include/linux/dmaengine.h 2007-07-02 09:39:08.954261000 +0100
+++ RFCpatched/include/linux/dmaengine.h 2007-07-03
15:46:33.552608000 +0100
@@ -143,6 +143,8 @@ typedef void (*dma_event_callback) (stru
* @event_callback: func ptr to call when something happens
* @chan_count: number of chans allocated
* @chans_desired: number of chans requested. Can be +/- chan_count
+ * @client_data: ptr to data which allows implementations to distinguish
+ * between clients
* @lock: protects access to the channels list
* @channels: the list of DMA channels allocated
* @global_node: list_head for global dma_client_list
@@ -151,6 +153,7 @@ struct dma_client {
dma_event_callback event_callback;
unsigned int chan_count;
unsigned int chans_desired;
+ void *client_data;

spinlock_t lock;
struct list_head channels;

#1 lore raw
Quoted 10 lines · Peter Pearse

Hi,

The existing DMAC used by the dmaengine API (Intel IOAT) assumes all possible clients can use any available DMA channel.

Some other DMACs restrict particular peripherals to particular DMA channels.

The patch below (against v2.6.22-rc7) extends the dmaengine implementation to allow such DMACs to differentiate between clients.

Hi Peter,

Have a look at:
http://marc.info/?l=linux-raid&m=118290909528910&w=2
http://marc.info/?l=linux-raid&m=118290909523734&w=2

It seems your requirement could be satisfied by a natural extension of the 'dma_cap_mask' implementation. 'dma_cap_mask' allows clients to only be notified of channels that meet a certain capability profile.

However since your driver is pretty much guaranteed to be the only dmaengine driver in the system you can safely do something like the following in your client callback:

static enum dma_state_client my_dma_client_callback(struct dma_client *client,
struct dma_chan *chan, enum dma_state state)

{
	struct dma_device *dma_dev;
	struct my_platform_specific_dma *plat_dma_dev;
	
	dma_dev = chan->device;
	plat_dma_dev = container_of(dma_dev, struct my_platform_specific_dma, dma_dev);

	if (!plat_dma_dev->platform_specific_capability)
		return DMA_DUP;

	. . .
}
Quoted 4 lines

Regards

Peter Pearse

--
Dan

#2 lore raw

Dan Williams [mailto:[email protected]]

Quoted 19 lines · Peter Pearse
Quoted 6 lines

Hi,

The existing DMAC used by the dmaengine API (Intel IOAT) assumes all possible clients can use any available DMA channel.

Some other DMACs restrict particular peripherals to

particular DMA channels.

Quoted 2 lines

The patch below (against v2.6.22-rc7) extends the dmaengine

implementation

Quoted 2 lines

to allow such DMACs to differentiate between clients.

Hi Peter,

Have a look at:
http://marc.info/?l=linux-raid&m=118290909528910&w=2
http://marc.info/?l=linux-raid&m=118290909523734&w=2

Quoted 8 lines

It seems your requirement could be satisfied by a natural extension of the 'dma_cap_mask' implementation. 'dma_cap_mask' allows clients to only be notified of channels that meet a certain capability profile.

However since your driver is pretty much guaranteed to be the only dmaengine driver in the system you can safely do something like the following in your client callback:

Peter,

If the client is looking for a specific channel capability, that can be worked with Dan's version of the interface as he suggests with the dma_cap_mask. However, it sounds like you need not just channel capabilities, but also client capabilities information, which I assume you would carry in the "void *client_data" that you suggested, allowing the DMAC itself to Ack/Nak the provisioning. Dan's other suggestion below has the client controlling the provisioning by accepting a particular channel. If the DMAC is the one that has the restriction information and needs to enforce the restriction based on the specific client, I suspect this may not help.

Can you give us an example of exactly how your DMAC restriction works?

Is it possible for you to pull this off with the suggested dma_cap_mask? The only info the client would need is the particular capability bit for a specific channel type.

Thanks,
sln