RE: [PATCH 6/7] DCA: Add Direct Cache Access driver

2007-07-20 Thread Nelson, Shannon
David Miller [mailto:[EMAIL PROTECTED] 
>
>> +static spinlock_t dca_lock;
> ...
>> +spin_lock_init(_lock);
>
>It's easier to use DEFINE_SPINLOCK().
>

Thanks - I'll adjust that in a future patch.
sln
--
==
Mr. Shannon Nelson LAN Access Division, Intel Corp.
[EMAIL PROTECTED]I don't speak for Intel
(503) 712-7659Parents can't afford to be squeamish.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 6/7] DCA: Add Direct Cache Access driver

2007-07-20 Thread Nelson, Shannon
David Miller [mailto:[EMAIL PROTECTED] 

 +static spinlock_t dca_lock;
 ...
 +spin_lock_init(dca_lock);

It's easier to use DEFINE_SPINLOCK().


Thanks - I'll adjust that in a future patch.
sln
--
==
Mr. Shannon Nelson LAN Access Division, Intel Corp.
[EMAIL PROTECTED]I don't speak for Intel
(503) 712-7659Parents can't afford to be squeamish.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/7] DCA: Add Direct Cache Access driver

2007-07-19 Thread David Miller
From: Shannon Nelson <[EMAIL PROTECTED]>
Date: Thu, 19 Jul 2007 17:45:17 -0700

> +static spinlock_t dca_lock;
 ...
> + spin_lock_init(_lock);

It's easier to use DEFINE_SPINLOCK().
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/7] DCA: Add Direct Cache Access driver

2007-07-19 Thread Shannon Nelson
Direct Cache Access (DCA) is a method for warming the CPU cache before data
is used, with the intent of lessening the impact of cache misses.  This
patch adds a manager and interface for matching up client requests for DCA
services with devices that offer DCA services.

In order to use DCA, a module must do bus writes with the appropriate tag
bits set to trigger a cache read for a specific CPU.  However, different
CPUs and chipsets can require different sets of tag bits, and the methods
for determining the correct bits may be simple hardcoding or may be a
hardware specific magic incantation.  This interface is a way for DCA
clients to find the correct tag bits for the targeted CPU without needing
to know the specifics.

Signed-off-by: Shannon Nelson <[EMAIL PROTECTED]>
---

 drivers/Kconfig |2 +
 drivers/Makefile|1 
 drivers/dca/Kconfig |   11 +++
 drivers/dca/Makefile|2 +
 drivers/dca/dca-core.c  |  170 +++
 drivers/dca/dca-sysfs.c |   88 
 include/linux/dca.h |   47 +
 7 files changed, 321 insertions(+), 0 deletions(-)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 7916f4b..98b7e10 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -80,6 +80,8 @@ source "drivers/rtc/Kconfig"
 
 source "drivers/dma/Kconfig"
 
+source "drivers/dca/Kconfig"
+
 source "drivers/auxdisplay/Kconfig"
 
 source "drivers/kvm/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 6d9d7fa..4e03de6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -82,5 +82,6 @@ obj-$(CONFIG_CRYPTO)  += crypto/
 obj-$(CONFIG_SUPERH)   += sh/
 obj-$(CONFIG_GENERIC_TIME) += clocksource/
 obj-$(CONFIG_DMA_ENGINE)   += dma/
+obj-$(CONFIG_DCA)  += dca/
 obj-$(CONFIG_HID)  += hid/
 obj-$(CONFIG_PPC_PS3)  += ps3/
diff --git a/drivers/dca/Kconfig b/drivers/dca/Kconfig
new file mode 100644
index 000..d901615
--- /dev/null
+++ b/drivers/dca/Kconfig
@@ -0,0 +1,11 @@
+#
+# DCA server configuration
+#
+
+config DCA
+   tristate "DCA support for clients and providers"
+   ---help---
+  This is a server to help modules that want to use Direct Cache
+ Access to find DCA providers that will supply correct CPU tags.
+   default m
+
diff --git a/drivers/dca/Makefile b/drivers/dca/Makefile
new file mode 100644
index 000..b2db56b
--- /dev/null
+++ b/drivers/dca/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_DCA) += dca.o
+dca-objs := dca-core.o dca-sysfs.o
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
new file mode 100644
index 000..864f469
--- /dev/null
+++ b/drivers/dca/dca-core.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright(c) 2007 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 driver supports an interface for DCA clients and providers to meet.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+MODULE_LICENSE("GPL");
+
+/* For now we're assuming a single, global, DCA provider for the system. */
+
+static spinlock_t dca_lock;
+
+struct dca_provider *global_dca = NULL;
+
+int dca_add_requester(struct device *dev)
+{
+   int err, slot;
+
+   if (!global_dca)
+   return -ENODEV;
+
+   spin_lock(_lock);
+   slot = global_dca->ops->add_requester(global_dca, dev);
+   spin_unlock(_lock);
+   if (slot < 0)
+   return slot;
+
+   err = dca_sysfs_add_req(global_dca, dev, slot);
+   if (err) {
+   spin_lock(_lock);
+   global_dca->ops->remove_requester(global_dca, dev);
+   spin_unlock(_lock);
+   return err;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(dca_add_requester);
+
+int dca_remove_requester(struct device *dev)
+{
+   int slot;
+   if (!global_dca)
+   return -ENODEV;
+
+   spin_lock(_lock);
+   slot = global_dca->ops->remove_requester(global_dca, dev);
+   spin_unlock(_lock);
+   if (slot < 0)
+   return slot;
+
+   dca_sysfs_remove_req(global_dca, slot);
+   return 0;
+}
+EXPORT_SYMBOL(dca_remove_requester);
+
+u8 dca_get_tag(int 

[PATCH 6/7] DCA: Add Direct Cache Access driver

2007-07-19 Thread Shannon Nelson
Direct Cache Access (DCA) is a method for warming the CPU cache before data
is used, with the intent of lessening the impact of cache misses.  This
patch adds a manager and interface for matching up client requests for DCA
services with devices that offer DCA services.

In order to use DCA, a module must do bus writes with the appropriate tag
bits set to trigger a cache read for a specific CPU.  However, different
CPUs and chipsets can require different sets of tag bits, and the methods
for determining the correct bits may be simple hardcoding or may be a
hardware specific magic incantation.  This interface is a way for DCA
clients to find the correct tag bits for the targeted CPU without needing
to know the specifics.

Signed-off-by: Shannon Nelson [EMAIL PROTECTED]
---

 drivers/Kconfig |2 +
 drivers/Makefile|1 
 drivers/dca/Kconfig |   11 +++
 drivers/dca/Makefile|2 +
 drivers/dca/dca-core.c  |  170 +++
 drivers/dca/dca-sysfs.c |   88 
 include/linux/dca.h |   47 +
 7 files changed, 321 insertions(+), 0 deletions(-)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 7916f4b..98b7e10 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -80,6 +80,8 @@ source drivers/rtc/Kconfig
 
 source drivers/dma/Kconfig
 
+source drivers/dca/Kconfig
+
 source drivers/auxdisplay/Kconfig
 
 source drivers/kvm/Kconfig
diff --git a/drivers/Makefile b/drivers/Makefile
index 6d9d7fa..4e03de6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -82,5 +82,6 @@ obj-$(CONFIG_CRYPTO)  += crypto/
 obj-$(CONFIG_SUPERH)   += sh/
 obj-$(CONFIG_GENERIC_TIME) += clocksource/
 obj-$(CONFIG_DMA_ENGINE)   += dma/
+obj-$(CONFIG_DCA)  += dca/
 obj-$(CONFIG_HID)  += hid/
 obj-$(CONFIG_PPC_PS3)  += ps3/
diff --git a/drivers/dca/Kconfig b/drivers/dca/Kconfig
new file mode 100644
index 000..d901615
--- /dev/null
+++ b/drivers/dca/Kconfig
@@ -0,0 +1,11 @@
+#
+# DCA server configuration
+#
+
+config DCA
+   tristate DCA support for clients and providers
+   ---help---
+  This is a server to help modules that want to use Direct Cache
+ Access to find DCA providers that will supply correct CPU tags.
+   default m
+
diff --git a/drivers/dca/Makefile b/drivers/dca/Makefile
new file mode 100644
index 000..b2db56b
--- /dev/null
+++ b/drivers/dca/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_DCA) += dca.o
+dca-objs := dca-core.o dca-sysfs.o
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
new file mode 100644
index 000..864f469
--- /dev/null
+++ b/drivers/dca/dca-core.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright(c) 2007 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 driver supports an interface for DCA clients and providers to meet.
+ */
+
+#include linux/kernel.h
+#include linux/notifier.h
+#include linux/device.h
+#include linux/dca.h
+
+MODULE_LICENSE(GPL);
+
+/* For now we're assuming a single, global, DCA provider for the system. */
+
+static spinlock_t dca_lock;
+
+struct dca_provider *global_dca = NULL;
+
+int dca_add_requester(struct device *dev)
+{
+   int err, slot;
+
+   if (!global_dca)
+   return -ENODEV;
+
+   spin_lock(dca_lock);
+   slot = global_dca-ops-add_requester(global_dca, dev);
+   spin_unlock(dca_lock);
+   if (slot  0)
+   return slot;
+
+   err = dca_sysfs_add_req(global_dca, dev, slot);
+   if (err) {
+   spin_lock(dca_lock);
+   global_dca-ops-remove_requester(global_dca, dev);
+   spin_unlock(dca_lock);
+   return err;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(dca_add_requester);
+
+int dca_remove_requester(struct device *dev)
+{
+   int slot;
+   if (!global_dca)
+   return -ENODEV;
+
+   spin_lock(dca_lock);
+   slot = global_dca-ops-remove_requester(global_dca, dev);
+   spin_unlock(dca_lock);
+   if (slot  0)
+   return slot;
+
+   dca_sysfs_remove_req(global_dca, slot);
+   return 0;
+}

Re: [PATCH 6/7] DCA: Add Direct Cache Access driver

2007-07-19 Thread David Miller
From: Shannon Nelson [EMAIL PROTECTED]
Date: Thu, 19 Jul 2007 17:45:17 -0700

 +static spinlock_t dca_lock;
 ...
 + spin_lock_init(dca_lock);

It's easier to use DEFINE_SPINLOCK().
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/