Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-05-25 Thread Olof Johansson
Hi,

On Tue, May 23, 2006 at 05:20:12PM -0700, Chris Leech wrote:

 +EXPORT_SYMBOL(dma_async_memcpy_buf_to_buf);
 +EXPORT_SYMBOL(dma_async_memcpy_buf_to_pg);
 +EXPORT_SYMBOL(dma_async_memcpy_pg_to_pg);

Is there a specific reason for why you chose to export 3 different
memcpu calls? They're all just wrapped to the same internals.

It would seem to make sense to have the client do their own
page_address(page) + offset calculations and just export one function?


-Olof

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-05-25 Thread Olof Johansson
On Thu, May 25, 2006 at 10:59:40AM -0700, Olof Johansson wrote:

 Is there a specific reason for why you chose to export 3 different
 memcpu calls? They're all just wrapped to the same internals.

 It would seem to make sense to have the client do their own
 page_address(page) + offset calculations and just export one function?

Nevermind. I'm too used to 64-bit environments where all memory is
always addressable to the kernel. There's obvious reasons to do it on
32-bit platforms to avoid the extra kernel mapping.


-Olof
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-05-23 Thread Chris Leech
Provides an API for offloading memory copies to DMA devices

Signed-off-by: Chris Leech [EMAIL PROTECTED]
---

 drivers/Kconfig   |2 
 drivers/Makefile  |1 
 drivers/dma/Kconfig   |   13 +
 drivers/dma/Makefile  |1 
 drivers/dma/dmaengine.c   |  408 +
 include/linux/dmaengine.h |  337 +
 6 files changed, 762 insertions(+), 0 deletions(-)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index aeb5ab2..8b11ceb 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -72,4 +72,6 @@ source drivers/edac/Kconfig
 
 source drivers/rtc/Kconfig
 
+source drivers/dma/Kconfig
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 447d8e6..3c51703 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_SGI_SN)  += sn/
 obj-y  += firmware/
 obj-$(CONFIG_CRYPTO)   += crypto/
 obj-$(CONFIG_SUPERH)   += sh/
+obj-$(CONFIG_DMA_ENGINE)   += dma/
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
new file mode 100644
index 000..f9ac4bc
--- /dev/null
+++ b/drivers/dma/Kconfig
@@ -0,0 +1,13 @@
+#
+# DMA engine configuration
+#
+
+menu DMA Engine support
+
+config DMA_ENGINE
+   bool Support for DMA engines
+   ---help---
+ DMA engines offload copy operations from the CPU to dedicated
+ hardware, allowing the copies to happen asynchronously.
+
+endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
new file mode 100644
index 000..10b7391
--- /dev/null
+++ b/drivers/dma/Makefile
@@ -0,0 +1 @@
+obj-y += dmaengine.o
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
new file mode 100644
index 000..473c47b
--- /dev/null
+++ b/drivers/dma/dmaengine.c
@@ -0,0 +1,408 @@
+/*
+ * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+/*
+ * This code implements the DMA subsystem. It provides a HW-neutral interface
+ * for other kernel code to use asynchronous memory copy capabilities,
+ * if present, and allows different HW DMA drivers to register as providing
+ * this capability.
+ *
+ * Due to the fact we are accelerating what is already a relatively fast
+ * operation, the code goes to great lengths to avoid additional overhead,
+ * such as locking.
+ *
+ * LOCKING:
+ *
+ * The subsystem keeps two global lists, dma_device_list and dma_client_list.
+ * Both of these are protected by a mutex, dma_list_mutex.
+ *
+ * Each device has a channels list, which runs unlocked but is never modified
+ * once the device is registered, it's just setup by the driver.
+ *
+ * Each client has a channels list, it's only modified under the client-lock
+ * and in an RCU callback, so it's safe to read under rcu_read_lock().
+ *
+ * Each device has a kref, which is initialized to 1 when the device is
+ * registered. A kref_put is done for each class_device registered.  When the
+ * class_device is released, the coresponding kref_put is done in the release
+ * method. Every time one of the device's channels is allocated to a client,
+ * a kref_get occurs.  When the channel is freed, the coresponding kref_put
+ * happens. The device's release function does a completion, so
+ * unregister_device does a remove event, class_device_unregister, a kref_put
+ * for the first reference, then waits on the completion for all other
+ * references to finish.
+ *
+ * Each channel has an open-coded implementation of Rusty Russell's bigref,
+ * with a kref and a per_cpu local_t.  A single reference is set when on an
+ * ADDED event, and removed with a REMOVE event.  Net DMA client takes an
+ * extra reference per outstanding transaction.  The relase function does a
+ * kref_put on the device. -ChrisL
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/device.h
+#include linux/dmaengine.h
+#include linux/hardirq.h
+#include linux/spinlock.h
+#include linux/percpu.h
+#include linux/rcupdate.h
+#include linux/mutex.h
+
+static DEFINE_MUTEX(dma_list_mutex);
+static LIST_HEAD(dma_device_list);
+static LIST_HEAD(dma_client_list);
+
+/* --- sysfs 

Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-05-23 Thread Andrew Morton
Chris Leech [EMAIL PROTECTED] wrote:

 + for_each_cpu(i)

That's about to be deleted.  Please use for_each_possible_cpu().

That's if for_each_possible_cpu() is appropriate.  Perhaps it should be
using for_each_present_cpu(), or for_each_online_cpu().  That's why
for_each_cpu() is going away - to make people think about such things..

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-05-23 Thread Andrew Morton
Chris Leech [EMAIL PROTECTED] wrote:

 +/**
  + * dma_client_chan_free - release a DMA channel
  + * @chan: dma_chan
  + */
  +void dma_chan_cleanup(struct kref *kref)
  +{
  +struct dma_chan *chan = container_of(kref, struct dma_chan, refcount);
  +chan-device-device_free_chan_resources(chan);
  +chan-client = NULL;
  +kref_put(chan-device-refcount, dma_async_device_cleanup);
  +}
  +
  +static void dma_chan_free_rcu(struct rcu_head *rcu)
  +{
  +struct dma_chan *chan = container_of(rcu, struct dma_chan, rcu);
  +int bias = 0x7FFF;
  +int i;
  +for_each_cpu(i)
  +bias -= local_read(per_cpu_ptr(chan-local, i)-refcount);
  +atomic_sub(bias, chan-refcount.refcount);
  +kref_put(chan-refcount, dma_chan_cleanup);
  +}
  +
  +static void dma_client_chan_free(struct dma_chan *chan)
  +{
  +atomic_add(0x7FFF, chan-refcount.refcount);
  +chan-slow_ref = 1;
  +call_rcu(chan-rcu, dma_chan_free_rcu);
  +}

A comment describing this `bias' magic would be nice.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-05-08 Thread Chris Leech
Provides an API for offloading memory copies to DMA devices

Signed-off-by: Chris Leech [EMAIL PROTECTED]
---

 drivers/Kconfig   |2 
 drivers/Makefile  |1 
 drivers/dma/Kconfig   |   13 +
 drivers/dma/Makefile  |1 
 drivers/dma/dmaengine.c   |  408 +
 include/linux/dmaengine.h |  337 +
 6 files changed, 762 insertions(+), 0 deletions(-)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index aeb5ab2..8b11ceb 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -72,4 +72,6 @@ source drivers/edac/Kconfig
 
 source drivers/rtc/Kconfig
 
+source drivers/dma/Kconfig
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 447d8e6..3c51703 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_SGI_SN)  += sn/
 obj-y  += firmware/
 obj-$(CONFIG_CRYPTO)   += crypto/
 obj-$(CONFIG_SUPERH)   += sh/
+obj-$(CONFIG_DMA_ENGINE)   += dma/
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
new file mode 100644
index 000..f9ac4bc
--- /dev/null
+++ b/drivers/dma/Kconfig
@@ -0,0 +1,13 @@
+#
+# DMA engine configuration
+#
+
+menu DMA Engine support
+
+config DMA_ENGINE
+   bool Support for DMA engines
+   ---help---
+ DMA engines offload copy operations from the CPU to dedicated
+ hardware, allowing the copies to happen asynchronously.
+
+endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
new file mode 100644
index 000..10b7391
--- /dev/null
+++ b/drivers/dma/Makefile
@@ -0,0 +1 @@
+obj-y += dmaengine.o
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
new file mode 100644
index 000..473c47b
--- /dev/null
+++ b/drivers/dma/dmaengine.c
@@ -0,0 +1,408 @@
+/*
+ * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+/*
+ * This code implements the DMA subsystem. It provides a HW-neutral interface
+ * for other kernel code to use asynchronous memory copy capabilities,
+ * if present, and allows different HW DMA drivers to register as providing
+ * this capability.
+ *
+ * Due to the fact we are accelerating what is already a relatively fast
+ * operation, the code goes to great lengths to avoid additional overhead,
+ * such as locking.
+ *
+ * LOCKING:
+ *
+ * The subsystem keeps two global lists, dma_device_list and dma_client_list.
+ * Both of these are protected by a mutex, dma_list_mutex.
+ *
+ * Each device has a channels list, which runs unlocked but is never modified
+ * once the device is registered, it's just setup by the driver.
+ *
+ * Each client has a channels list, it's only modified under the client-lock
+ * and in an RCU callback, so it's safe to read under rcu_read_lock().
+ *
+ * Each device has a kref, which is initialized to 1 when the device is
+ * registered. A kref_put is done for each class_device registered.  When the
+ * class_device is released, the coresponding kref_put is done in the release
+ * method. Every time one of the device's channels is allocated to a client,
+ * a kref_get occurs.  When the channel is freed, the coresponding kref_put
+ * happens. The device's release function does a completion, so
+ * unregister_device does a remove event, class_device_unregister, a kref_put
+ * for the first reference, then waits on the completion for all other
+ * references to finish.
+ *
+ * Each channel has an open-coded implementation of Rusty Russell's bigref,
+ * with a kref and a per_cpu local_t.  A single reference is set when on an
+ * ADDED event, and removed with a REMOVE event.  Net DMA client takes an
+ * extra reference per outstanding transaction.  The relase function does a
+ * kref_put on the device. -ChrisL
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/device.h
+#include linux/dmaengine.h
+#include linux/hardirq.h
+#include linux/spinlock.h
+#include linux/percpu.h
+#include linux/rcupdate.h
+#include linux/mutex.h
+
+static DEFINE_MUTEX(dma_list_mutex);
+static LIST_HEAD(dma_device_list);
+static LIST_HEAD(dma_client_list);
+
+/* --- sysfs 

Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-31 Thread Ingo Oeser
Kumar Gala wrote:
 On Mar 30, 2006, at 12:36 PM, Andrew Grover wrote:
  Wellit's true they're useful for debugging but I would put them in
  the category of system statistics that shouldn't go in debugfs. I
  think they are like /proc/interrupts' interrupt counts or the TX/RX
  stats reported by ifconfig.
 
 Fair, but wouldn't it be better to have the association per client.
 
 Maybe leave the one as a summary and have a dir per client with  
 similar stats that are for each client and add a per channel summary  
 at the top level as well.

Such level of detail really belongs to debugging, IMHO.

I think, it would suffer to say, how many channels are in use.
So you can answer the question, whether your customers are actually
using this experimental technology. 

If you want more, let them mount debugfs. 
If it becomes really important, we can revisit this later.

Thats the advantage of files under debugfs 
not being stable API in any way.

BTW: What is the actual frequency, at which such counters 
will be incremented?


Regards

Ingo Oeser
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-31 Thread Kumar Gala


On Mar 31, 2006, at 2:04 PM, Andrew Grover wrote:


On 3/31/06, Ingo Oeser [EMAIL PROTECTED] wrote:

Kumar Gala wrote:

Fair, but wouldn't it be better to have the association per client.

Maybe leave the one as a summary and have a dir per client with
similar stats that are for each client and add a per channel summary
at the top level as well.

Such level of detail really belongs to debugging, IMHO.

[snip]

If we implemented more stats then yes debugfs sounds like it might be
the way to go.


BTW: What is the actual frequency, at which such counters
will be incremented?


Currently the code updates these variables (kept per cpu) every time a
copy is queued. See include/linux/dmaengine.h.


Might it be better to update when the transfer is done incase of an  
error?


- kumar

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-31 Thread Andrew Grover
On 3/31/06, Ingo Oeser [EMAIL PROTECTED] wrote:
 Kumar Gala wrote:
  Fair, but wouldn't it be better to have the association per client.
 
  Maybe leave the one as a summary and have a dir per client with
  similar stats that are for each client and add a per channel summary
  at the top level as well.
 Such level of detail really belongs to debugging, IMHO.
[snip]

If we implemented more stats then yes debugfs sounds like it might be
the way to go.

 BTW: What is the actual frequency, at which such counters
 will be incremented?

Currently the code updates these variables (kept per cpu) every time a
copy is queued. See include/linux/dmaengine.h.

-- Andy
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-31 Thread Andrew Grover
On 3/31/06, Kumar Gala [EMAIL PROTECTED] wrote:
  Currently the code updates these variables (kept per cpu) every time a
  copy is queued. See include/linux/dmaengine.h.

 Might it be better to update when the transfer is done incase of an
 error?

The queueing function is really in the best position to do this. It
knows the size of each request. However in the cleanup/status check
routine, all we know is the last request completed -- we don't know
the completed requests' sizes.

The other reason is that the DMA engine should never throw an error.
If it does then something is very wrong, we print scary warnings, and
up-to-date stats are the least of our problems.

Regards -- Andy
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-30 Thread Kumar Gala


On Mar 29, 2006, at 4:55 PM, Chris Leech wrote:


Provides an API for offloading memory copies to DMA devices

Signed-off-by: Chris Leech [EMAIL PROTECTED]
---

 drivers/Kconfig   |2
 drivers/Makefile  |1
 drivers/dma/Kconfig   |   13 +
 drivers/dma/Makefile  |1
 drivers/dma/dmaengine.c   |  405 ++ 
+++
 include/linux/dmaengine.h |  337 ++ 
+++

 6 files changed, 759 insertions(+), 0 deletions(-)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 9f5c0da..f89ac05 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -72,4 +72,6 @@ source drivers/edac/Kconfig

 source drivers/rtc/Kconfig

+source drivers/dma/Kconfig
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 4249552..9b808a6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_SGI_SN)  += sn/
 obj-y  += firmware/
 obj-$(CONFIG_CRYPTO)   += crypto/
 obj-$(CONFIG_SUPERH)   += sh/
+obj-$(CONFIG_DMA_ENGINE)   += dma/
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
new file mode 100644
index 000..f9ac4bc
--- /dev/null
+++ b/drivers/dma/Kconfig
@@ -0,0 +1,13 @@
+#
+# DMA engine configuration
+#
+
+menu DMA Engine support
+
+config DMA_ENGINE
+   bool Support for DMA engines
+   ---help---
+ DMA engines offload copy operations from the CPU to dedicated
+ hardware, allowing the copies to happen asynchronously.
+
+endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
new file mode 100644
index 000..10b7391
--- /dev/null
+++ b/drivers/dma/Makefile
@@ -0,0 +1 @@
+obj-y += dmaengine.o
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
new file mode 100644
index 000..683456a
--- /dev/null
+++ b/drivers/dma/dmaengine.c
@@ -0,0 +1,405 @@
+/*
+ * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or  
modify it
+ * under the terms of the GNU General Public License as published  
by the Free
+ * Software Foundation; either version 2 of the License, or (at  
your option)

+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,  
but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of  
MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public  
License for

+ * more details.
+ *
+ * You should have received a copy of the GNU General Public  
License along with
+ * this program; if not, write to the Free Software Foundation,  
Inc., 59

+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this  
distribution in the

+ * file called COPYING.
+ */
+
+/*
+ * This code implements the DMA subsystem. It provides a HW- 
neutral interface
+ * for other kernel code to use asynchronous memory copy  
capabilities,
+ * if present, and allows different HW DMA drivers to register as  
providing

+ * this capability.
+ *
+ * Due to the fact we are accelerating what is already a  
relatively fast
+ * operation, the code goes to great lengths to avoid additional  
overhead,

+ * such as locking.
+ *
+ * LOCKING:
+ *
+ * The subsystem keeps two global lists, dma_device_list and  
dma_client_list.

+ * Both of these are protected by a spinlock, dma_list_lock.
+ *
+ * Each device has a channels list, which runs unlocked but is  
never modified

+ * once the device is registered, it's just setup by the driver.
+ *
+ * Each client has a channels list, it's only modified under the  
client-lock
+ * and in an RCU callback, so it's safe to read under rcu_read_lock 
().

+ *
+ * Each device has a kref, which is initialized to 1 when the  
device is
+ * registered. A kref_put is done for each class_device  
registered.  When the
+ * class_device is released, the coresponding kref_put is done in  
the release
+ * method. Every time one of the device's channels is allocated to  
a client,
+ * a kref_get occurs.  When the channel is freed, the coresponding  
kref_put

+ * happens. The device's release function does a completion, so
+ * unregister_device does a remove event, class_device_unregister,  
a kref_put
+ * for the first reference, then waits on the completion for all  
other

+ * references to finish.
+ *
+ * Each channel has an open-coded implementation of Rusty  
Russell's bigref,
+ * with a kref and a per_cpu local_t.  A single reference is set  
when on an
+ * ADDED event, and removed with a REMOVE event.  Net DMA client  
takes an
+ * extra reference per outstanding transaction.  The relase  
function does a

+ * kref_put on the device. -ChrisL
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/device.h
+#include linux/dmaengine.h
+#include linux/hardirq.h
+#include linux/spinlock.h
+#include linux/percpu.h
+#include linux/rcupdate.h
+
+static 

Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-30 Thread Andrew Grover
On 3/30/06, Kumar Gala [EMAIL PROTECTED] wrote:
 What is the utility of exporting memcpy_count, and bytes_transferred
 to userspace via sysfs?  Is this really for debug (and thus should be
 under debugfs?)

Wellit's true they're useful for debugging but I would put them in
the category of system statistics that shouldn't go in debugfs. I
think they are like /proc/interrupts' interrupt counts or the TX/RX
stats reported by ifconfig.

Regards -- Andy
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-30 Thread Kumar Gala


On Mar 30, 2006, at 12:36 PM, Andrew Grover wrote:


On 3/30/06, Kumar Gala [EMAIL PROTECTED] wrote:

What is the utility of exporting memcpy_count, and bytes_transferred
to userspace via sysfs?  Is this really for debug (and thus should be
under debugfs?)


Wellit's true they're useful for debugging but I would put them in
the category of system statistics that shouldn't go in debugfs. I
think they are like /proc/interrupts' interrupt counts or the TX/RX
stats reported by ifconfig.


Fair, but wouldn't it be better to have the association per client.

Maybe leave the one as a summary and have a dir per client with  
similar stats that are for each client and add a per channel summary  
at the top level as well.


- kumar

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] [I/OAT] DMA memcpy subsystem

2006-03-29 Thread Chris Leech
Provides an API for offloading memory copies to DMA devices

Signed-off-by: Chris Leech [EMAIL PROTECTED]
---

 drivers/Kconfig   |2 
 drivers/Makefile  |1 
 drivers/dma/Kconfig   |   13 +
 drivers/dma/Makefile  |1 
 drivers/dma/dmaengine.c   |  405 +
 include/linux/dmaengine.h |  337 +
 6 files changed, 759 insertions(+), 0 deletions(-)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 9f5c0da..f89ac05 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -72,4 +72,6 @@ source drivers/edac/Kconfig
 
 source drivers/rtc/Kconfig
 
+source drivers/dma/Kconfig
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 4249552..9b808a6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_SGI_SN)  += sn/
 obj-y  += firmware/
 obj-$(CONFIG_CRYPTO)   += crypto/
 obj-$(CONFIG_SUPERH)   += sh/
+obj-$(CONFIG_DMA_ENGINE)   += dma/
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
new file mode 100644
index 000..f9ac4bc
--- /dev/null
+++ b/drivers/dma/Kconfig
@@ -0,0 +1,13 @@
+#
+# DMA engine configuration
+#
+
+menu DMA Engine support
+
+config DMA_ENGINE
+   bool Support for DMA engines
+   ---help---
+ DMA engines offload copy operations from the CPU to dedicated
+ hardware, allowing the copies to happen asynchronously.
+
+endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
new file mode 100644
index 000..10b7391
--- /dev/null
+++ b/drivers/dma/Makefile
@@ -0,0 +1 @@
+obj-y += dmaengine.o
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
new file mode 100644
index 000..683456a
--- /dev/null
+++ b/drivers/dma/dmaengine.c
@@ -0,0 +1,405 @@
+/*
+ * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+/*
+ * This code implements the DMA subsystem. It provides a HW-neutral interface
+ * for other kernel code to use asynchronous memory copy capabilities,
+ * if present, and allows different HW DMA drivers to register as providing
+ * this capability.
+ *
+ * Due to the fact we are accelerating what is already a relatively fast
+ * operation, the code goes to great lengths to avoid additional overhead,
+ * such as locking.
+ *
+ * LOCKING:
+ *
+ * The subsystem keeps two global lists, dma_device_list and dma_client_list.
+ * Both of these are protected by a spinlock, dma_list_lock.
+ *
+ * Each device has a channels list, which runs unlocked but is never modified
+ * once the device is registered, it's just setup by the driver.
+ *
+ * Each client has a channels list, it's only modified under the client-lock
+ * and in an RCU callback, so it's safe to read under rcu_read_lock().
+ *
+ * Each device has a kref, which is initialized to 1 when the device is
+ * registered. A kref_put is done for each class_device registered.  When the
+ * class_device is released, the coresponding kref_put is done in the release
+ * method. Every time one of the device's channels is allocated to a client,
+ * a kref_get occurs.  When the channel is freed, the coresponding kref_put
+ * happens. The device's release function does a completion, so
+ * unregister_device does a remove event, class_device_unregister, a kref_put
+ * for the first reference, then waits on the completion for all other
+ * references to finish.
+ *
+ * Each channel has an open-coded implementation of Rusty Russell's bigref,
+ * with a kref and a per_cpu local_t.  A single reference is set when on an
+ * ADDED event, and removed with a REMOVE event.  Net DMA client takes an
+ * extra reference per outstanding transaction.  The relase function does a
+ * kref_put on the device. -ChrisL
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/device.h
+#include linux/dmaengine.h
+#include linux/hardirq.h
+#include linux/spinlock.h
+#include linux/percpu.h
+#include linux/rcupdate.h
+
+static DEFINE_SPINLOCK(dma_list_lock);
+static LIST_HEAD(dma_device_list);
+static LIST_HEAD(dma_client_list);
+
+/* --- sysfs implementation --- */
+
+static