linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] Extend the DMA-engine API.
@ 2007-07-10  9:45 Zhang Wei
  2007-07-10 15:46 ` Randy Dunlap
  2007-07-10 18:41 ` Dan Williams
  0 siblings, 2 replies; 6+ messages in thread
From: Zhang Wei @ 2007-07-10  9:45 UTC (permalink / raw)
  To: akpm, paulus, galak; +Cc: linuxppc-dev, linux-kernel

Add channel wait queue and transfer callback dma_xfer_callback().
If the DMA controller and driver support interrupt, when the
transfer is finished, it will wakeup the wait queue
and call the callback function of the channel.

Add dma_async_raw_xfer() to API and device_raw_xfer() to struct dma_device
for RAW physical address DMA transfer, which will be used at transfer
between I/O address and memory address.

Signed-off-by: Zhang Wei <wei.zhang@freescale.com>
---
 include/linux/dmaengine.h |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c94d8f1..d9dfc57 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -28,6 +28,7 @@
 #include <linux/kref.h>
 #include <linux/completion.h>
 #include <linux/rcupdate.h>
+#include <linux/wait.h>
 
 /**
  * enum dma_event - resource PNP/power managment events
@@ -108,6 +109,8 @@ struct dma_chan {
 	struct list_head client_node;
 	struct list_head device_node;
 	struct dma_chan_percpu *local;
+
+	wait_queue_head_t wait_q;
 };
 
 void dma_chan_cleanup(struct kref *kref);
@@ -138,6 +141,12 @@ static inline void dma_chan_put(struct dma_chan *chan)
 typedef void (*dma_event_callback) (struct dma_client *client,
 		struct dma_chan *chan, enum dma_event event);
 
+/*
+ * typedef dma_xfer_callback
+ *   - function pointer to a DMA transfer callback when finished
+ */
+typedef void (*dma_xfer_callback) (struct dma_chan *chan, void *data);
+
 /**
  * struct dma_client - info on the entity making use of DMA services
  * @event_callback: func ptr to call when something happens
@@ -187,6 +196,9 @@ struct dma_device {
 
 	int (*device_alloc_chan_resources)(struct dma_chan *chan);
 	void (*device_free_chan_resources)(struct dma_chan *chan);
+	dma_cookie_t (*device_raw_xfer)(struct dma_chan *chan,
+			dma_addr_t dest, dma_addr_t src, size_t len,
+			dma_xfer_callback cb, void *data);
 	dma_cookie_t (*device_memcpy_buf_to_buf)(struct dma_chan *chan,
 			void *dest, void *src, size_t len);
 	dma_cookie_t (*device_memcpy_buf_to_pg)(struct dma_chan *chan,
@@ -209,6 +221,29 @@ void dma_async_client_chan_request(struct dma_client *client,
 		unsigned int number);
 
 /**
+ * dma_async_raw_xfer - transfor data between physical addresses with callback
+ * @chan: DMA channel to be used
+ * @dest: destination address (physical)
+ * @src: source address (physical)
+ * @len: length
+ */
+static inline dma_cookie_t dma_async_raw_xfer(struct dma_chan *chan,
+				dma_addr_t dest, dma_addr_t src, size_t len,
+				dma_xfer_callback cb, void *data)
+{
+	int cpu = get_cpu();
+	per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
+	per_cpu_ptr(chan->local, cpu)->memcpy_count++;
+	put_cpu();
+
+	if (chan->device->device_raw_xfer)
+		return chan->device->device_raw_xfer(chan, dest, src, len,
+							cb, data);
+	else
+		return -EPERM;
+}
+
+/**
  * dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses
  * @chan: DMA channel to offload copy to
  * @dest: destination address (virtual)
-- 
1.5.1

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

* Re: [PATCH 3/4] Extend the DMA-engine API.
  2007-07-10  9:45 [PATCH 3/4] Extend the DMA-engine API Zhang Wei
@ 2007-07-10 15:46 ` Randy Dunlap
  2007-07-10 18:41 ` Dan Williams
  1 sibling, 0 replies; 6+ messages in thread
From: Randy Dunlap @ 2007-07-10 15:46 UTC (permalink / raw)
  To: Zhang Wei; +Cc: linuxppc-dev, akpm, paulus, linux-kernel

On Tue, 10 Jul 2007 17:45:11 +0800 Zhang Wei wrote:

> Add channel wait queue and transfer callback dma_xfer_callback().
> If the DMA controller and driver support interrupt, when the
> transfer is finished, it will wakeup the wait queue
> and call the callback function of the channel.
> 
> Add dma_async_raw_xfer() to API and device_raw_xfer() to struct dma_device
> for RAW physical address DMA transfer, which will be used at transfer
> between I/O address and memory address.
> 
> Signed-off-by: Zhang Wei <wei.zhang@freescale.com>
> ---
>  include/linux/dmaengine.h |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)

>  /**
> + * dma_async_raw_xfer - transfor data between physical addresses with callback

                           transfer

> + * @chan: DMA channel to be used
> + * @dest: destination address (physical)
> + * @src: source address (physical)
> + * @len: length
> + */
> +static inline dma_cookie_t dma_async_raw_xfer(struct dma_chan *chan,
> +				dma_addr_t dest, dma_addr_t src, size_t len,
> +				dma_xfer_callback cb, void *data)
> +{


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

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

* Re: [PATCH 3/4] Extend the DMA-engine API.
  2007-07-10  9:45 [PATCH 3/4] Extend the DMA-engine API Zhang Wei
  2007-07-10 15:46 ` Randy Dunlap
@ 2007-07-10 18:41 ` Dan Williams
  2007-07-11  7:39   ` Zhang Wei-r63237
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Williams @ 2007-07-10 18:41 UTC (permalink / raw)
  To: Zhang Wei; +Cc: linuxppc-dev, akpm, paulus, linux-kernel

On 7/10/07, Zhang Wei <wei.zhang@freescale.com> wrote:
> Add channel wait queue and transfer callback dma_xfer_callback().
> If the DMA controller and driver support interrupt, when the
> transfer is finished, it will wakeup the wait queue
> and call the callback function of the channel.
>
> Add dma_async_raw_xfer() to API and device_raw_xfer() to struct dma_device
> for RAW physical address DMA transfer, which will be used at transfer
> between I/O address and memory address.
>

Please review the async_tx API patch series[1], it should meet your
needs.  What you call "raw" mode support is now default for the
dmaengine driver interface.  I plan to request that this series be
merged for 2.6.23.

Regards,
Dan

[1]http://marc.info/?l=linux-raid&w=2&r=1&s=md-accel&q=b

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

* RE: [PATCH 3/4] Extend the DMA-engine API.
  2007-07-10 18:41 ` Dan Williams
@ 2007-07-11  7:39   ` Zhang Wei-r63237
  2007-07-11 16:56     ` Dan Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang Wei-r63237 @ 2007-07-11  7:39 UTC (permalink / raw)
  To: Dan Williams; +Cc: linuxppc-dev, akpm, paulus, linux-kernel

Hi, Dan,=20

Do you mention here: =
http://marc.info/?l=3Dlinux-raid&m=3D118290909614463&w=3D2 ?
I see the async_tx is located at crypto/ of the above page, but my patch =
is for DMA engine in drivers/dma and for DMA engine driver.

Thanks!
Wei.
> -----Original Message-----
> Subject: Re: [PATCH 3/4] Extend the DMA-engine API.
>=20
> On 7/10/07, Zhang Wei <wei.zhang@freescale.com> wrote:
> > Add channel wait queue and transfer callback dma_xfer_callback().
> > If the DMA controller and driver support interrupt, when the
> > transfer is finished, it will wakeup the wait queue
> > and call the callback function of the channel.
> >
> > Add dma_async_raw_xfer() to API and device_raw_xfer() to=20
> struct dma_device
> > for RAW physical address DMA transfer, which will be used=20
> at transfer
> > between I/O address and memory address.
> >
>=20
> Please review the async_tx API patch series[1], it should meet your
> needs.  What you call "raw" mode support is now default for the
> dmaengine driver interface.  I plan to request that this series be
> merged for 2.6.23.
>=20
> Regards,
> Dan
>=20
> [1]http://marc.info/?l=3Dlinux-raid&w=3D2&r=3D1&s=3Dmd-accel&q=3Db
>=20

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

* Re: [PATCH 3/4] Extend the DMA-engine API.
  2007-07-11  7:39   ` Zhang Wei-r63237
@ 2007-07-11 16:56     ` Dan Williams
  2007-07-12  6:31       ` Zhang Wei-r63237
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Williams @ 2007-07-11 16:56 UTC (permalink / raw)
  To: Zhang Wei-r63237; +Cc: shannon.nelson, linux-kernel, linuxppc-dev, paulus, akpm

On 7/11/07, Zhang Wei-r63237 <Wei.Zhang@freescale.com> wrote:
> Hi, Dan,
>
> Do you mention here: http://marc.info/?l=linux-raid&m=118290909614463&w=2 ?
> I see the async_tx is located at crypto/ of the above page, but my patch is for DMA engine in drivers/dma and for DMA engine driver.
>
> Thanks!
> Wei.

Hi Wei,

I was referring to:
http://marc.info/?l=linux-raid&m=118290909528910&w=2

async_tx is an api that exploits the raw capabilities of the new
dmaengine interface.  For your case when the existing api calls do not
provide the proper interface you can open code something like the
following:

tx = dev->device_prep_dma_<operation>(chan, len, int_flag)
tx->tx_set_src(dma_addr_t, tx, index /* for multi-source ops */)
tx->tx_set_dest(dma_addr_t, tx, index)
tx->tx_submit(tx)

The expectation is that the most common usages of dmaengines will use
async_tx calls, or the 'dma_async_memcpy_foo_to_bar' helper routines.

--
Dan

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

* RE: [PATCH 3/4] Extend the DMA-engine API.
  2007-07-11 16:56     ` Dan Williams
@ 2007-07-12  6:31       ` Zhang Wei-r63237
  0 siblings, 0 replies; 6+ messages in thread
From: Zhang Wei-r63237 @ 2007-07-12  6:31 UTC (permalink / raw)
  To: Dan Williams; +Cc: shannon.nelson, linux-kernel, linuxppc-dev, paulus, akpm

Hi, Dan,

Thanks! I get it.
It's so lucky we have the same target.
When your patch could be accepted?

Cheers,
Wei.=20

> -----Original Message-----
> From: dan.j.williams@gmail.com=20
> [mailto:dan.j.williams@gmail.com] On Behalf Of Dan Williams
> Sent: Thursday, July 12, 2007 12:57 AM
> To: Zhang Wei-r63237
> Cc: akpm@linux-foundation.org; paulus@samba.org;=20
> galak@kernel.crashing.org; linuxppc-dev@ozlabs.org;=20
> linux-kernel@vger.kernel.org; shannon.nelson@intel.com
> Subject: Re: [PATCH 3/4] Extend the DMA-engine API.
>=20
> On 7/11/07, Zhang Wei-r63237 <Wei.Zhang@freescale.com> wrote:
> > Hi, Dan,
> >
> > Do you mention here:=20
> http://marc.info/?l=3Dlinux-raid&m=3D118290909614463&w=3D2 ?
> > I see the async_tx is located at crypto/ of the above page,=20
> but my patch is for DMA engine in drivers/dma and for DMA=20
> engine driver.
> >
> > Thanks!
> > Wei.
>=20
> Hi Wei,
>=20
> I was referring to:
> http://marc.info/?l=3Dlinux-raid&m=3D118290909528910&w=3D2
>=20
> async_tx is an api that exploits the raw capabilities of the new
> dmaengine interface.  For your case when the existing api calls do not
> provide the proper interface you can open code something like the
> following:
>=20
> tx =3D dev->device_prep_dma_<operation>(chan, len, int_flag)
> tx->tx_set_src(dma_addr_t, tx, index /* for multi-source ops */)
> tx->tx_set_dest(dma_addr_t, tx, index)
> tx->tx_submit(tx)
>=20
> The expectation is that the most common usages of dmaengines will use
> async_tx calls, or the 'dma_async_memcpy_foo_to_bar' helper routines.
>=20
> --
> Dan
>=20

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

end of thread, other threads:[~2007-07-12  6:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10  9:45 [PATCH 3/4] Extend the DMA-engine API Zhang Wei
2007-07-10 15:46 ` Randy Dunlap
2007-07-10 18:41 ` Dan Williams
2007-07-11  7:39   ` Zhang Wei-r63237
2007-07-11 16:56     ` Dan Williams
2007-07-12  6:31       ` Zhang Wei-r63237

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