Re: [Intel IOMMU 01/10] DMAR detection and parsing logic

2007-07-04 Thread Peter Zijlstra
On Wed, 2007-07-04 at 03:04 -0700, Andrew Morton wrote:
> On Wed, 04 Jul 2007 11:18:56 +0200 Peter Zijlstra <[EMAIL PROTECTED]> wrote:
> 
> > On Tue, 2007-06-19 at 14:37 -0700, Keshavamurthy, Anil S wrote:
> > > plain text document attachment (dmar_detection.patch)
> > 
> > > +/**
> > > + * parse_dmar_table - parses the DMA reporting table
> > > + */
> > > +static int __init
> > > +parse_dmar_table(void)
> > > +{
> > > + struct acpi_table_dmar *dmar;
> > > + struct acpi_dmar_header *entry_header;
> > > + int ret = 0;
> > > +
> > > + dmar = (struct acpi_table_dmar *)dmar_tbl;
> > > +
> > > + if (!dmar->width) {
> >   ^^^
> > 
> > That goes *splat* on my opteron box.
> 
> This?
> 
> From: "Keshavamurthy, Anil S" <[EMAIL PROTECTED]>
> 
> Check for dmar_tbl pointer as this can be NULL on systems with no Intel
> VT-d support.
> 
> Signed-off-by: Anil S Keshavamurthy <[EMAIL PROTECTED]>
> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>

Ah, that does look sane, I'll test it whenever the next -mm comes
around.

-
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: [Intel IOMMU 01/10] DMAR detection and parsing logic

2007-07-04 Thread Andrew Morton
On Wed, 04 Jul 2007 11:18:56 +0200 Peter Zijlstra <[EMAIL PROTECTED]> wrote:

> On Tue, 2007-06-19 at 14:37 -0700, Keshavamurthy, Anil S wrote:
> > plain text document attachment (dmar_detection.patch)
> 
> > +/**
> > + * parse_dmar_table - parses the DMA reporting table
> > + */
> > +static int __init
> > +parse_dmar_table(void)
> > +{
> > +   struct acpi_table_dmar *dmar;
> > +   struct acpi_dmar_header *entry_header;
> > +   int ret = 0;
> > +
> > +   dmar = (struct acpi_table_dmar *)dmar_tbl;
> > +
> > +   if (!dmar->width) {
>   ^^^
> 
> That goes *splat* on my opteron box.

This?

From: "Keshavamurthy, Anil S" <[EMAIL PROTECTED]>

Check for dmar_tbl pointer as this can be NULL on systems with no Intel
VT-d support.

Signed-off-by: Anil S Keshavamurthy <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/pci/dmar.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN 
drivers/pci/dmar.c~intel-iommu-dmar-detection-and-parsing-logic-fix-intel-dmar-crash-on-amd-x86_64
 drivers/pci/dmar.c
--- 
a/drivers/pci/dmar.c~intel-iommu-dmar-detection-and-parsing-logic-fix-intel-dmar-crash-on-amd-x86_64
+++ a/drivers/pci/dmar.c
@@ -260,6 +260,8 @@ parse_dmar_table(void)
int ret = 0;
 
dmar = (struct acpi_table_dmar *)dmar_tbl;
+   if (!dmar)
+   return -ENODEV;
 
if (!dmar->width) {
printk (KERN_WARNING PREFIX "Zero: Invalid DMAR haw\n");
@@ -301,7 +303,7 @@ int __init dmar_table_init(void)
 
parse_dmar_table();
if (list_empty(_drhd_units)) {
-   printk(KERN_ERR PREFIX "No DMAR devices found\n");
+   printk(KERN_INFO PREFIX "No DMAR devices found\n");
return -ENODEV;
}
return 0;
_

-
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: [Intel IOMMU 01/10] DMAR detection and parsing logic

2007-07-04 Thread Peter Zijlstra
On Tue, 2007-06-19 at 14:37 -0700, Keshavamurthy, Anil S wrote:
> plain text document attachment (dmar_detection.patch)

> +/**
> + * parse_dmar_table - parses the DMA reporting table
> + */
> +static int __init
> +parse_dmar_table(void)
> +{
> + struct acpi_table_dmar *dmar;
> + struct acpi_dmar_header *entry_header;
> + int ret = 0;
> +
> + dmar = (struct acpi_table_dmar *)dmar_tbl;
> +
> + if (!dmar->width) {
  ^^^

That goes *splat* on my opteron box.

> + printk (KERN_WARNING PREFIX "Zero: Invalid DMAR haw\n");
> + return -EINVAL;
> + }
> +
> + printk (KERN_INFO PREFIX "Host address width %d\n",
> + dmar->width + 1);
> +
> + entry_header = (struct acpi_dmar_header *)(dmar + 1);
> + while (((unsigned long)entry_header) <
> + (((unsigned long)dmar) + dmar_tbl->length)) {
> + dmar_table_print_dmar_entry(entry_header);
> +
> + switch (entry_header->type) {
> + case ACPI_DMAR_TYPE_HARDWARE_UNIT:
> + ret = dmar_parse_one_drhd(entry_header);
> + break;
> + case ACPI_DMAR_TYPE_RESERVED_MEMORY:
> + ret = dmar_parse_one_rmrr(entry_header);
> + break;
> + default:
> + printk(KERN_WARNING PREFIX
> + "Unknown DMAR structure type\n");
> + ret = 0; /* for forward compatibility */
> + break;
> + }
> + if (ret)
> + break;
> +
> + entry_header = ((void *)entry_header + entry_header->length);
> + }
> + return ret;
> +}
> +

-
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: [Intel IOMMU 01/10] DMAR detection and parsing logic

2007-07-04 Thread Peter Zijlstra
On Tue, 2007-06-19 at 14:37 -0700, Keshavamurthy, Anil S wrote:
 plain text document attachment (dmar_detection.patch)

 +/**
 + * parse_dmar_table - parses the DMA reporting table
 + */
 +static int __init
 +parse_dmar_table(void)
 +{
 + struct acpi_table_dmar *dmar;
 + struct acpi_dmar_header *entry_header;
 + int ret = 0;
 +
 + dmar = (struct acpi_table_dmar *)dmar_tbl;
 +
 + if (!dmar-width) {
  ^^^

That goes *splat* on my opteron box.

 + printk (KERN_WARNING PREFIX Zero: Invalid DMAR haw\n);
 + return -EINVAL;
 + }
 +
 + printk (KERN_INFO PREFIX Host address width %d\n,
 + dmar-width + 1);
 +
 + entry_header = (struct acpi_dmar_header *)(dmar + 1);
 + while (((unsigned long)entry_header) 
 + (((unsigned long)dmar) + dmar_tbl-length)) {
 + dmar_table_print_dmar_entry(entry_header);
 +
 + switch (entry_header-type) {
 + case ACPI_DMAR_TYPE_HARDWARE_UNIT:
 + ret = dmar_parse_one_drhd(entry_header);
 + break;
 + case ACPI_DMAR_TYPE_RESERVED_MEMORY:
 + ret = dmar_parse_one_rmrr(entry_header);
 + break;
 + default:
 + printk(KERN_WARNING PREFIX
 + Unknown DMAR structure type\n);
 + ret = 0; /* for forward compatibility */
 + break;
 + }
 + if (ret)
 + break;
 +
 + entry_header = ((void *)entry_header + entry_header-length);
 + }
 + return ret;
 +}
 +

-
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: [Intel IOMMU 01/10] DMAR detection and parsing logic

2007-07-04 Thread Andrew Morton
On Wed, 04 Jul 2007 11:18:56 +0200 Peter Zijlstra [EMAIL PROTECTED] wrote:

 On Tue, 2007-06-19 at 14:37 -0700, Keshavamurthy, Anil S wrote:
  plain text document attachment (dmar_detection.patch)
 
  +/**
  + * parse_dmar_table - parses the DMA reporting table
  + */
  +static int __init
  +parse_dmar_table(void)
  +{
  +   struct acpi_table_dmar *dmar;
  +   struct acpi_dmar_header *entry_header;
  +   int ret = 0;
  +
  +   dmar = (struct acpi_table_dmar *)dmar_tbl;
  +
  +   if (!dmar-width) {
   ^^^
 
 That goes *splat* on my opteron box.

This?

From: Keshavamurthy, Anil S [EMAIL PROTECTED]

Check for dmar_tbl pointer as this can be NULL on systems with no Intel
VT-d support.

Signed-off-by: Anil S Keshavamurthy [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 drivers/pci/dmar.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN 
drivers/pci/dmar.c~intel-iommu-dmar-detection-and-parsing-logic-fix-intel-dmar-crash-on-amd-x86_64
 drivers/pci/dmar.c
--- 
a/drivers/pci/dmar.c~intel-iommu-dmar-detection-and-parsing-logic-fix-intel-dmar-crash-on-amd-x86_64
+++ a/drivers/pci/dmar.c
@@ -260,6 +260,8 @@ parse_dmar_table(void)
int ret = 0;
 
dmar = (struct acpi_table_dmar *)dmar_tbl;
+   if (!dmar)
+   return -ENODEV;
 
if (!dmar-width) {
printk (KERN_WARNING PREFIX Zero: Invalid DMAR haw\n);
@@ -301,7 +303,7 @@ int __init dmar_table_init(void)
 
parse_dmar_table();
if (list_empty(dmar_drhd_units)) {
-   printk(KERN_ERR PREFIX No DMAR devices found\n);
+   printk(KERN_INFO PREFIX No DMAR devices found\n);
return -ENODEV;
}
return 0;
_

-
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: [Intel IOMMU 01/10] DMAR detection and parsing logic

2007-07-04 Thread Peter Zijlstra
On Wed, 2007-07-04 at 03:04 -0700, Andrew Morton wrote:
 On Wed, 04 Jul 2007 11:18:56 +0200 Peter Zijlstra [EMAIL PROTECTED] wrote:
 
  On Tue, 2007-06-19 at 14:37 -0700, Keshavamurthy, Anil S wrote:
   plain text document attachment (dmar_detection.patch)
  
   +/**
   + * parse_dmar_table - parses the DMA reporting table
   + */
   +static int __init
   +parse_dmar_table(void)
   +{
   + struct acpi_table_dmar *dmar;
   + struct acpi_dmar_header *entry_header;
   + int ret = 0;
   +
   + dmar = (struct acpi_table_dmar *)dmar_tbl;
   +
   + if (!dmar-width) {
^^^
  
  That goes *splat* on my opteron box.
 
 This?
 
 From: Keshavamurthy, Anil S [EMAIL PROTECTED]
 
 Check for dmar_tbl pointer as this can be NULL on systems with no Intel
 VT-d support.
 
 Signed-off-by: Anil S Keshavamurthy [EMAIL PROTECTED]
 Signed-off-by: Andrew Morton [EMAIL PROTECTED]

Ah, that does look sane, I'll test it whenever the next -mm comes
around.

-
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/


[Intel IOMMU 01/10] DMAR detection and parsing logic

2007-06-19 Thread Keshavamurthy, Anil S
This patch adds support for early detection and parsing of DMAR's
(DMA Remapping ) reported to OS via ACPI tables.

DMA remapping(DMAR) devices support enables independent address
translations for Direct Memory Access(DMA) from Devices.
These DMA remapping devices are reported via ACPI tables
and includes pci device scope covered by these DMA
remapping device.

For detailed info on the specification of  "Intel(R) Virtualization 
Technology for Directed I/O Architecture" please see
http://www.intel.com/technology/virtualization/index.htm

Signed-off-by: Anil S Keshavamurthy <[EMAIL PROTECTED]>

---
 arch/x86_64/Kconfig   |   11 +
 drivers/pci/Makefile  |3 
 drivers/pci/dmar.c|  327 ++
 include/acpi/actbl1.h |   27 +++-
 include/linux/dmar.h  |   52 +++
 5 files changed, 413 insertions(+), 7 deletions(-)

Index: linux-2.6.22-rc4-mm2/arch/x86_64/Kconfig
===
--- linux-2.6.22-rc4-mm2.orig/arch/x86_64/Kconfig   2007-06-18 
15:45:39.0 -0700
+++ linux-2.6.22-rc4-mm2/arch/x86_64/Kconfig2007-06-19 13:05:03.0 
-0700
@@ -730,6 +730,17 @@
bool "Support mmconfig PCI config space access"
depends on PCI && ACPI
 
+config DMAR
+   bool "Support for DMA Remapping Devices (EXPERIMENTAL)"
+   depends on PCI_MSI && ACPI && EXPERIMENTAL
+   default y
+   help
+ DMA remapping(DMAR) devices support enables independent address
+ translations for Direct Memory Access(DMA) from Devices.
+ These DMA remapping devices are reported via ACPI tables
+ and includes pci device scope covered by these DMA
+ remapping device.
+
 source "drivers/pci/pcie/Kconfig"
 
 source "drivers/pci/Kconfig"
Index: linux-2.6.22-rc4-mm2/drivers/pci/Makefile
===
--- linux-2.6.22-rc4-mm2.orig/drivers/pci/Makefile  2007-06-18 
15:45:39.0 -0700
+++ linux-2.6.22-rc4-mm2/drivers/pci/Makefile   2007-06-19 13:43:14.0 
-0700
@@ -20,6 +20,9 @@
 # Build the Hypertransport interrupt support
 obj-$(CONFIG_HT_IRQ) += htirq.o
 
+# Build Intel IOMMU support
+obj-$(CONFIG_DMAR) += dmar.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
Index: linux-2.6.22-rc4-mm2/drivers/pci/dmar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.22-rc4-mm2/drivers/pci/dmar.c 2007-06-18 15:45:46.0 
-0700
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * Copyright (C) Ashok Raj <[EMAIL PROTECTED]>
+ * Copyright (C) Shaohua Li <[EMAIL PROTECTED]>
+ * Copyright (C) Anil S Keshavamurthy <[EMAIL PROTECTED]>
+ *
+ * This file implements early detection/parsing of DMA Remapping Devices
+ * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
+ * tables.
+ */
+
+#include 
+#include 
+
+#undef PREFIX
+#define PREFIX "DMAR:"
+
+/* No locks are needed as DMA remapping hardware unit
+ * list is constructed at boot time and hotplug of
+ * these units are not supported by the architecture.
+ */
+LIST_HEAD(dmar_drhd_units);
+LIST_HEAD(dmar_rmrr_units);
+
+static struct acpi_table_header * __initdata dmar_tbl;
+
+static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
+{
+   /*
+* add INCLUDE_ALL at the tail, so scan the list will find it at
+* the very end.
+*/
+   if (drhd->include_all)
+   list_add_tail(>list, _drhd_units);
+   else
+   list_add(>list, _drhd_units);
+}
+
+static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
+{
+   list_add(>list, _rmrr_units);
+}
+
+static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
*scope,
+  struct pci_dev **dev, u16 segment)
+{
+   struct pci_bus *bus;
+   struct pci_dev *pdev = NULL;
+   struct acpi_dmar_pci_path *path;
+   int count;
+
+   bus = pci_find_bus(segment, scope->bus);
+   path = (struct acpi_dmar_pci_path *)(scope + 1);
+   count = (scope->length - sizeof(struct acpi_dmar_device_scope))
+   / sizeof(struct acpi_dmar_pci_path);
+

[Intel IOMMU 01/10] DMAR detection and parsing logic

2007-06-19 Thread Keshavamurthy, Anil S
This patch adds support for early detection and parsing of DMAR's
(DMA Remapping ) reported to OS via ACPI tables.

DMA remapping(DMAR) devices support enables independent address
translations for Direct Memory Access(DMA) from Devices.
These DMA remapping devices are reported via ACPI tables
and includes pci device scope covered by these DMA
remapping device.

For detailed info on the specification of  Intel(R) Virtualization 
Technology for Directed I/O Architecture please see
http://www.intel.com/technology/virtualization/index.htm

Signed-off-by: Anil S Keshavamurthy [EMAIL PROTECTED]

---
 arch/x86_64/Kconfig   |   11 +
 drivers/pci/Makefile  |3 
 drivers/pci/dmar.c|  327 ++
 include/acpi/actbl1.h |   27 +++-
 include/linux/dmar.h  |   52 +++
 5 files changed, 413 insertions(+), 7 deletions(-)

Index: linux-2.6.22-rc4-mm2/arch/x86_64/Kconfig
===
--- linux-2.6.22-rc4-mm2.orig/arch/x86_64/Kconfig   2007-06-18 
15:45:39.0 -0700
+++ linux-2.6.22-rc4-mm2/arch/x86_64/Kconfig2007-06-19 13:05:03.0 
-0700
@@ -730,6 +730,17 @@
bool Support mmconfig PCI config space access
depends on PCI  ACPI
 
+config DMAR
+   bool Support for DMA Remapping Devices (EXPERIMENTAL)
+   depends on PCI_MSI  ACPI  EXPERIMENTAL
+   default y
+   help
+ DMA remapping(DMAR) devices support enables independent address
+ translations for Direct Memory Access(DMA) from Devices.
+ These DMA remapping devices are reported via ACPI tables
+ and includes pci device scope covered by these DMA
+ remapping device.
+
 source drivers/pci/pcie/Kconfig
 
 source drivers/pci/Kconfig
Index: linux-2.6.22-rc4-mm2/drivers/pci/Makefile
===
--- linux-2.6.22-rc4-mm2.orig/drivers/pci/Makefile  2007-06-18 
15:45:39.0 -0700
+++ linux-2.6.22-rc4-mm2/drivers/pci/Makefile   2007-06-19 13:43:14.0 
-0700
@@ -20,6 +20,9 @@
 # Build the Hypertransport interrupt support
 obj-$(CONFIG_HT_IRQ) += htirq.o
 
+# Build Intel IOMMU support
+obj-$(CONFIG_DMAR) += dmar.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
Index: linux-2.6.22-rc4-mm2/drivers/pci/dmar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.22-rc4-mm2/drivers/pci/dmar.c 2007-06-18 15:45:46.0 
-0700
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * Copyright (C) Ashok Raj [EMAIL PROTECTED]
+ * Copyright (C) Shaohua Li [EMAIL PROTECTED]
+ * Copyright (C) Anil S Keshavamurthy [EMAIL PROTECTED]
+ *
+ * This file implements early detection/parsing of DMA Remapping Devices
+ * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
+ * tables.
+ */
+
+#include linux/pci.h
+#include linux/dmar.h
+
+#undef PREFIX
+#define PREFIX DMAR:
+
+/* No locks are needed as DMA remapping hardware unit
+ * list is constructed at boot time and hotplug of
+ * these units are not supported by the architecture.
+ */
+LIST_HEAD(dmar_drhd_units);
+LIST_HEAD(dmar_rmrr_units);
+
+static struct acpi_table_header * __initdata dmar_tbl;
+
+static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
+{
+   /*
+* add INCLUDE_ALL at the tail, so scan the list will find it at
+* the very end.
+*/
+   if (drhd-include_all)
+   list_add_tail(drhd-list, dmar_drhd_units);
+   else
+   list_add(drhd-list, dmar_drhd_units);
+}
+
+static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
+{
+   list_add(rmrr-list, dmar_rmrr_units);
+}
+
+static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
*scope,
+  struct pci_dev **dev, u16 segment)
+{
+   struct pci_bus *bus;
+   struct pci_dev *pdev = NULL;
+   struct acpi_dmar_pci_path *path;
+   int count;
+
+   bus = pci_find_bus(segment, scope-bus);
+   path = (struct acpi_dmar_pci_path *)(scope + 1);
+   count = (scope-length - sizeof(struct acpi_dmar_device_scope))
+   / sizeof(struct 

[Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-06 Thread anil . s . keshavamurthy
This patch adds support for early detection and parsing of DMAR's
reported to OS via ACPI tables.

Signed-off-by: Anil S Keshavamurthy <[EMAIL PROTECTED]>
---
 arch/x86_64/Kconfig   |   11 +
 drivers/pci/Makefile  |3 
 drivers/pci/dmar.c|  318 ++
 include/acpi/actbl1.h |   27 +++-
 include/linux/dmar.h  |   52 
 5 files changed, 404 insertions(+), 7 deletions(-)

Index: linux-2.6.22-rc3/arch/x86_64/Kconfig
===
--- linux-2.6.22-rc3.orig/arch/x86_64/Kconfig   2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/arch/x86_64/Kconfig2007-06-04 12:33:15.0 
-0700
@@ -716,6 +716,17 @@
bool "Support mmconfig PCI config space access"
depends on PCI && ACPI
 
+config DMAR
+   bool "Support for DMA Remapping Devices (EXPERIMENTAL)"
+   depends on PCI_MSI && ACPI && EXPERIMENTAL
+   default y
+   help
+ DMA remapping(DMAR) devices support enables independent address
+ translations for Direct Memory Access(DMA) from Devices.
+ These DMA remapping devices are reported via ACPI tables
+ and includes pci device scope covered by these DMA
+ remapping device.
+
 source "drivers/pci/pcie/Kconfig"
 
 source "drivers/pci/Kconfig"
Index: linux-2.6.22-rc3/drivers/pci/Makefile
===
--- linux-2.6.22-rc3.orig/drivers/pci/Makefile  2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/drivers/pci/Makefile   2007-06-04 12:33:15.0 
-0700
@@ -20,6 +20,9 @@
 # Build the Hypertransport interrupt support
 obj-$(CONFIG_HT_IRQ) += htirq.o
 
+# Build Intel IOMMU support
+obj-$(CONFIG_DMAR) += dmar.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
Index: linux-2.6.22-rc3/drivers/pci/dmar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.22-rc3/drivers/pci/dmar.c 2007-06-04 12:33:15.0 -0700
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * Copyright (C) Ashok Raj <[EMAIL PROTECTED]>
+ * Copyright (C) Shaohua Li <[EMAIL PROTECTED]>
+ *
+ * This file implements early detection/parsing of DMA Remapping Devices
+ * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
+ * tables.
+ */
+
+#include 
+#include 
+
+#undef PREFIX
+#define PREFIX "DMAR:"
+
+/* No locks are needed as DMA remapping hardware unit
+ * list is constructed at boot time and hotplug of
+ * these units are not supported by the architecture.
+ */
+LIST_HEAD(dmar_drhd_units);
+LIST_HEAD(dmar_rmrr_units);
+
+static struct acpi_table_header * __initdata dmar_tbl;
+
+static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
+{
+   /*
+* add INCLUDE_ALL at the tail, so scan the list will find it at
+* the very end.
+*/
+   if (drhd->include_all)
+   list_add_tail(>list, _drhd_units);
+   else
+   list_add(>list, _drhd_units);
+}
+
+static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
+{
+   list_add(>list, _rmrr_units);
+}
+
+static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
*scope,
+  struct pci_dev **dev, u16 segment)
+{
+   struct pci_bus *bus;
+   struct pci_dev *pdev = NULL;
+   struct acpi_dmar_pci_path *path;
+   int count;
+
+   bus = pci_find_bus(segment, scope->bus);
+   path = (struct acpi_dmar_pci_path *)(scope + 1);
+   count = (scope->length - sizeof(struct acpi_dmar_device_scope))
+   /sizeof(struct acpi_dmar_pci_path);
+
+   while (count) {
+   if (pdev)
+   pci_dev_put(pdev);
+   /*
+* Some BIOSes list non-exist devices in DMAR table, just
+* ignore it
+*/
+   if (!bus) {
+   printk(KERN_WARNING
+   PREFIX "Device scope bus [%d] not found\n",
+   scope->bus);
+   break;
+   }
+   pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn));
+   

[Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-06 Thread anil . s . keshavamurthy
This patch adds support for early detection and parsing of DMAR's
reported to OS via ACPI tables.

Signed-off-by: Anil S Keshavamurthy [EMAIL PROTECTED]
---
 arch/x86_64/Kconfig   |   11 +
 drivers/pci/Makefile  |3 
 drivers/pci/dmar.c|  318 ++
 include/acpi/actbl1.h |   27 +++-
 include/linux/dmar.h  |   52 
 5 files changed, 404 insertions(+), 7 deletions(-)

Index: linux-2.6.22-rc3/arch/x86_64/Kconfig
===
--- linux-2.6.22-rc3.orig/arch/x86_64/Kconfig   2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/arch/x86_64/Kconfig2007-06-04 12:33:15.0 
-0700
@@ -716,6 +716,17 @@
bool Support mmconfig PCI config space access
depends on PCI  ACPI
 
+config DMAR
+   bool Support for DMA Remapping Devices (EXPERIMENTAL)
+   depends on PCI_MSI  ACPI  EXPERIMENTAL
+   default y
+   help
+ DMA remapping(DMAR) devices support enables independent address
+ translations for Direct Memory Access(DMA) from Devices.
+ These DMA remapping devices are reported via ACPI tables
+ and includes pci device scope covered by these DMA
+ remapping device.
+
 source drivers/pci/pcie/Kconfig
 
 source drivers/pci/Kconfig
Index: linux-2.6.22-rc3/drivers/pci/Makefile
===
--- linux-2.6.22-rc3.orig/drivers/pci/Makefile  2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/drivers/pci/Makefile   2007-06-04 12:33:15.0 
-0700
@@ -20,6 +20,9 @@
 # Build the Hypertransport interrupt support
 obj-$(CONFIG_HT_IRQ) += htirq.o
 
+# Build Intel IOMMU support
+obj-$(CONFIG_DMAR) += dmar.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
Index: linux-2.6.22-rc3/drivers/pci/dmar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.22-rc3/drivers/pci/dmar.c 2007-06-04 12:33:15.0 -0700
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * Copyright (C) Ashok Raj [EMAIL PROTECTED]
+ * Copyright (C) Shaohua Li [EMAIL PROTECTED]
+ *
+ * This file implements early detection/parsing of DMA Remapping Devices
+ * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
+ * tables.
+ */
+
+#include linux/pci.h
+#include linux/dmar.h
+
+#undef PREFIX
+#define PREFIX DMAR:
+
+/* No locks are needed as DMA remapping hardware unit
+ * list is constructed at boot time and hotplug of
+ * these units are not supported by the architecture.
+ */
+LIST_HEAD(dmar_drhd_units);
+LIST_HEAD(dmar_rmrr_units);
+
+static struct acpi_table_header * __initdata dmar_tbl;
+
+static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
+{
+   /*
+* add INCLUDE_ALL at the tail, so scan the list will find it at
+* the very end.
+*/
+   if (drhd-include_all)
+   list_add_tail(drhd-list, dmar_drhd_units);
+   else
+   list_add(drhd-list, dmar_drhd_units);
+}
+
+static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
+{
+   list_add(rmrr-list, dmar_rmrr_units);
+}
+
+static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
*scope,
+  struct pci_dev **dev, u16 segment)
+{
+   struct pci_bus *bus;
+   struct pci_dev *pdev = NULL;
+   struct acpi_dmar_pci_path *path;
+   int count;
+
+   bus = pci_find_bus(segment, scope-bus);
+   path = (struct acpi_dmar_pci_path *)(scope + 1);
+   count = (scope-length - sizeof(struct acpi_dmar_device_scope))
+   /sizeof(struct acpi_dmar_pci_path);
+
+   while (count) {
+   if (pdev)
+   pci_dev_put(pdev);
+   /*
+* Some BIOSes list non-exist devices in DMAR table, just
+* ignore it
+*/
+   if (!bus) {
+   printk(KERN_WARNING
+   PREFIX Device scope bus [%d] not found\n,
+   scope-bus);
+   break;
+   }
+   pdev = pci_get_slot(bus, PCI_DEVFN(path-dev, 

Re: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Keshavamurthy, Anil S
On Mon, Jun 04, 2007 at 07:03:56PM -0400, Jeff Garzik wrote:
> 
> Is there no way at all, other than ACPI, to find this stuff?
This is as clean as possible without letting ACPI to parse this
DMA remapping unit. The only thing we might be using is the
acpi data struct.

-Anil
-
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: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Jeff Garzik

Is there no way at all, other than ACPI, to find this stuff?

We would prefer to avoid hardware if the hardware enumeration is sane.

Jeff



-
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: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Keshavamurthy, Anil S
On Mon, Jun 04, 2007 at 06:54:21PM -0400, Jeff Garzik wrote:
> On Mon, Jun 04, 2007 at 02:02:43PM -0700, [EMAIL PROTECTED] wrote:
> > --- linux-2.6.22-rc3.orig/drivers/pci/Makefile  2007-06-04 
> > 12:28:13.0 -0700
> > +++ linux-2.6.22-rc3/drivers/pci/Makefile   2007-06-04 12:33:15.0 
> > -0700
> > @@ -20,6 +20,9 @@
> >  # Build the Hypertransport interrupt support
> >  obj-$(CONFIG_HT_IRQ) += htirq.o
> >  
> > +# Build Intel IOMMU support
> > +obj-$(CONFIG_DMAR) += dmar.o
> 
> It's not Intel IOMMU support though, is it?
Yes, it is Intel IOMMU support.

> 
> It's x86 PCI IOMMU support (as opposed to x86 GART IOMMU).
> 
> I just want to avoid Intel branding on something that will not be
> specific to Intel-manufacured products in the long term.

This DMAR (DMA Remapping unit) is Intel specific and
its spec is available at www.intel.com/technology/virtualization

-Anil
-
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: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Jeff Garzik
On Mon, Jun 04, 2007 at 02:02:43PM -0700, [EMAIL PROTECTED] wrote:
> --- linux-2.6.22-rc3.orig/drivers/pci/Makefile2007-06-04 
> 12:28:13.0 -0700
> +++ linux-2.6.22-rc3/drivers/pci/Makefile 2007-06-04 12:33:15.0 
> -0700
> @@ -20,6 +20,9 @@
>  # Build the Hypertransport interrupt support
>  obj-$(CONFIG_HT_IRQ) += htirq.o
>  
> +# Build Intel IOMMU support
> +obj-$(CONFIG_DMAR) += dmar.o

It's not Intel IOMMU support though, is it?

It's x86 PCI IOMMU support (as opposed to x86 GART IOMMU).

I just want to avoid Intel branding on something that will not be
specific to Intel-manufacured products in the long term.



> Index: linux-2.6.22-rc3/drivers/pci/dmar.c
> ===
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ linux-2.6.22-rc3/drivers/pci/dmar.c   2007-06-04 12:33:15.0 
> -0700
> @@ -0,0 +1,318 @@
> +/*
> + * Copyright (c) 2006, Intel Corporation.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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.
> + *
> + *   Copyright (C) Ashok Raj <[EMAIL PROTECTED]>
> + *   Copyright (C) Shaohua Li <[EMAIL PROTECTED]>
> + *
> + *   This file implements early detection/parsing of DMA Remapping Devices
> + * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
> + * tables.
> + */
> +
> +#include 
> +#include 
> +
> +#undef PREFIX
> +#define PREFIX "DMAR:"
> +
> +/* No locks are needed as DMA remapping hardware unit
> + * list is constructed at boot time and hotplug of
> + * these units are not supported by the architecture.
> + */
> +LIST_HEAD(dmar_drhd_units);
> +LIST_HEAD(dmar_rmrr_units);
> +
> +static struct acpi_table_header * __initdata dmar_tbl;
> +
> +static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
> +{
> + /*
> +  * add INCLUDE_ALL at the tail, so scan the list will find it at
> +  * the very end.
> +  */
> + if (drhd->include_all)
> + list_add_tail(>list, _drhd_units);
> + else
> + list_add(>list, _drhd_units);
> +}
> +
> +static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
> +{
> + list_add(>list, _rmrr_units);
> +}
> +
> +static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
> *scope,
> +struct pci_dev **dev, u16 segment)
> +{
> + struct pci_bus *bus;
> + struct pci_dev *pdev = NULL;
> + struct acpi_dmar_pci_path *path;
> + int count;
> +
> + bus = pci_find_bus(segment, scope->bus);
> + path = (struct acpi_dmar_pci_path *)(scope + 1);
> + count = (scope->length - sizeof(struct acpi_dmar_device_scope))
> + /sizeof(struct acpi_dmar_pci_path);

add a space.

But overall this casting and typed-struct pointer addition is a bit
fragile.  No comment (I haven't read enough yet) whether it is needed or
not.




> +
> + while (count) {
> + if (pdev)
> + pci_dev_put(pdev);
> + /*
> +  * Some BIOSes list non-exist devices in DMAR table, just
> +  * ignore it
> +  */
> + if (!bus) {
> + printk(KERN_WARNING
> + PREFIX "Device scope bus [%d] not found\n",
> + scope->bus);
> + break;
> + }
> + pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn));
> + if (!pdev) {
> + printk(KERN_WARNING PREFIX
> + "Device scope device [%04x:%02x:%02x.%02x] not found\n",
> + segment, bus->number, path->dev, path->fn);
> + break;
> + }
> + path ++;
> + count --;
> + bus = pdev->subordinate;
> + }
> + if (!pdev) {
> + printk(KERN_WARNING PREFIX
> + "Device scope device [%04x:%02x:%02x.%02x] not found\n",
> + segment, scope->bus, path->dev, path->fn);
> + *dev = NULL;
> + return 0;
> + }
> + if ((scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT && 
> pdev->subordinate)
> +|| (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE && 
> !pdev->subordinate)) {
> + pci_dev_put(pdev);
> + printk(KERN_WARNING PREFIX "Device scope type 

[Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread anil . s . keshavamurthy
This patch adds support for early detection and parsing of DMAR's
reported to OS via ACPI tables.

Signed-off-by: Anil S Keshavamurthy <[EMAIL PROTECTED]>
---
 arch/x86_64/Kconfig   |   11 +
 drivers/pci/Makefile  |3 
 drivers/pci/dmar.c|  318 ++
 include/acpi/actbl1.h |   27 +++-
 include/linux/dmar.h  |   52 
 5 files changed, 404 insertions(+), 7 deletions(-)

Index: linux-2.6.22-rc3/arch/x86_64/Kconfig
===
--- linux-2.6.22-rc3.orig/arch/x86_64/Kconfig   2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/arch/x86_64/Kconfig2007-06-04 12:33:15.0 
-0700
@@ -716,6 +716,17 @@
bool "Support mmconfig PCI config space access"
depends on PCI && ACPI
 
+config DMAR
+   bool "Support for DMA Remapping Devices (EXPERIMENTAL)"
+   depends on PCI_MSI && ACPI && EXPERIMENTAL
+   default y
+   help
+ DMA remapping(DMAR) devices support enables independent address
+ translations for Direct Memory Access(DMA) from Devices.
+ These DMA remapping devices are reported via ACPI tables
+ and includes pci device scope covered by these DMA
+ remapping device.
+
 source "drivers/pci/pcie/Kconfig"
 
 source "drivers/pci/Kconfig"
Index: linux-2.6.22-rc3/drivers/pci/Makefile
===
--- linux-2.6.22-rc3.orig/drivers/pci/Makefile  2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/drivers/pci/Makefile   2007-06-04 12:33:15.0 
-0700
@@ -20,6 +20,9 @@
 # Build the Hypertransport interrupt support
 obj-$(CONFIG_HT_IRQ) += htirq.o
 
+# Build Intel IOMMU support
+obj-$(CONFIG_DMAR) += dmar.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
Index: linux-2.6.22-rc3/drivers/pci/dmar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.22-rc3/drivers/pci/dmar.c 2007-06-04 12:33:15.0 -0700
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * Copyright (C) Ashok Raj <[EMAIL PROTECTED]>
+ * Copyright (C) Shaohua Li <[EMAIL PROTECTED]>
+ *
+ * This file implements early detection/parsing of DMA Remapping Devices
+ * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
+ * tables.
+ */
+
+#include 
+#include 
+
+#undef PREFIX
+#define PREFIX "DMAR:"
+
+/* No locks are needed as DMA remapping hardware unit
+ * list is constructed at boot time and hotplug of
+ * these units are not supported by the architecture.
+ */
+LIST_HEAD(dmar_drhd_units);
+LIST_HEAD(dmar_rmrr_units);
+
+static struct acpi_table_header * __initdata dmar_tbl;
+
+static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
+{
+   /*
+* add INCLUDE_ALL at the tail, so scan the list will find it at
+* the very end.
+*/
+   if (drhd->include_all)
+   list_add_tail(>list, _drhd_units);
+   else
+   list_add(>list, _drhd_units);
+}
+
+static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
+{
+   list_add(>list, _rmrr_units);
+}
+
+static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
*scope,
+  struct pci_dev **dev, u16 segment)
+{
+   struct pci_bus *bus;
+   struct pci_dev *pdev = NULL;
+   struct acpi_dmar_pci_path *path;
+   int count;
+
+   bus = pci_find_bus(segment, scope->bus);
+   path = (struct acpi_dmar_pci_path *)(scope + 1);
+   count = (scope->length - sizeof(struct acpi_dmar_device_scope))
+   /sizeof(struct acpi_dmar_pci_path);
+
+   while (count) {
+   if (pdev)
+   pci_dev_put(pdev);
+   /*
+* Some BIOSes list non-exist devices in DMAR table, just
+* ignore it
+*/
+   if (!bus) {
+   printk(KERN_WARNING
+   PREFIX "Device scope bus [%d] not found\n",
+   scope->bus);
+   break;
+   }
+   pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn));
+   

[Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread anil . s . keshavamurthy
This patch adds support for early detection and parsing of DMAR's
reported to OS via ACPI tables.

Signed-off-by: Anil S Keshavamurthy [EMAIL PROTECTED]
---
 arch/x86_64/Kconfig   |   11 +
 drivers/pci/Makefile  |3 
 drivers/pci/dmar.c|  318 ++
 include/acpi/actbl1.h |   27 +++-
 include/linux/dmar.h  |   52 
 5 files changed, 404 insertions(+), 7 deletions(-)

Index: linux-2.6.22-rc3/arch/x86_64/Kconfig
===
--- linux-2.6.22-rc3.orig/arch/x86_64/Kconfig   2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/arch/x86_64/Kconfig2007-06-04 12:33:15.0 
-0700
@@ -716,6 +716,17 @@
bool Support mmconfig PCI config space access
depends on PCI  ACPI
 
+config DMAR
+   bool Support for DMA Remapping Devices (EXPERIMENTAL)
+   depends on PCI_MSI  ACPI  EXPERIMENTAL
+   default y
+   help
+ DMA remapping(DMAR) devices support enables independent address
+ translations for Direct Memory Access(DMA) from Devices.
+ These DMA remapping devices are reported via ACPI tables
+ and includes pci device scope covered by these DMA
+ remapping device.
+
 source drivers/pci/pcie/Kconfig
 
 source drivers/pci/Kconfig
Index: linux-2.6.22-rc3/drivers/pci/Makefile
===
--- linux-2.6.22-rc3.orig/drivers/pci/Makefile  2007-06-04 12:28:13.0 
-0700
+++ linux-2.6.22-rc3/drivers/pci/Makefile   2007-06-04 12:33:15.0 
-0700
@@ -20,6 +20,9 @@
 # Build the Hypertransport interrupt support
 obj-$(CONFIG_HT_IRQ) += htirq.o
 
+# Build Intel IOMMU support
+obj-$(CONFIG_DMAR) += dmar.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
Index: linux-2.6.22-rc3/drivers/pci/dmar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.22-rc3/drivers/pci/dmar.c 2007-06-04 12:33:15.0 -0700
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * Copyright (C) Ashok Raj [EMAIL PROTECTED]
+ * Copyright (C) Shaohua Li [EMAIL PROTECTED]
+ *
+ * This file implements early detection/parsing of DMA Remapping Devices
+ * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
+ * tables.
+ */
+
+#include linux/pci.h
+#include linux/dmar.h
+
+#undef PREFIX
+#define PREFIX DMAR:
+
+/* No locks are needed as DMA remapping hardware unit
+ * list is constructed at boot time and hotplug of
+ * these units are not supported by the architecture.
+ */
+LIST_HEAD(dmar_drhd_units);
+LIST_HEAD(dmar_rmrr_units);
+
+static struct acpi_table_header * __initdata dmar_tbl;
+
+static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
+{
+   /*
+* add INCLUDE_ALL at the tail, so scan the list will find it at
+* the very end.
+*/
+   if (drhd-include_all)
+   list_add_tail(drhd-list, dmar_drhd_units);
+   else
+   list_add(drhd-list, dmar_drhd_units);
+}
+
+static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
+{
+   list_add(rmrr-list, dmar_rmrr_units);
+}
+
+static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
*scope,
+  struct pci_dev **dev, u16 segment)
+{
+   struct pci_bus *bus;
+   struct pci_dev *pdev = NULL;
+   struct acpi_dmar_pci_path *path;
+   int count;
+
+   bus = pci_find_bus(segment, scope-bus);
+   path = (struct acpi_dmar_pci_path *)(scope + 1);
+   count = (scope-length - sizeof(struct acpi_dmar_device_scope))
+   /sizeof(struct acpi_dmar_pci_path);
+
+   while (count) {
+   if (pdev)
+   pci_dev_put(pdev);
+   /*
+* Some BIOSes list non-exist devices in DMAR table, just
+* ignore it
+*/
+   if (!bus) {
+   printk(KERN_WARNING
+   PREFIX Device scope bus [%d] not found\n,
+   scope-bus);
+   break;
+   }
+   pdev = pci_get_slot(bus, PCI_DEVFN(path-dev, 

Re: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Jeff Garzik
On Mon, Jun 04, 2007 at 02:02:43PM -0700, [EMAIL PROTECTED] wrote:
 --- linux-2.6.22-rc3.orig/drivers/pci/Makefile2007-06-04 
 12:28:13.0 -0700
 +++ linux-2.6.22-rc3/drivers/pci/Makefile 2007-06-04 12:33:15.0 
 -0700
 @@ -20,6 +20,9 @@
  # Build the Hypertransport interrupt support
  obj-$(CONFIG_HT_IRQ) += htirq.o
  
 +# Build Intel IOMMU support
 +obj-$(CONFIG_DMAR) += dmar.o

It's not Intel IOMMU support though, is it?

It's x86 PCI IOMMU support (as opposed to x86 GART IOMMU).

I just want to avoid Intel branding on something that will not be
specific to Intel-manufacured products in the long term.



 Index: linux-2.6.22-rc3/drivers/pci/dmar.c
 ===
 --- /dev/null 1970-01-01 00:00:00.0 +
 +++ linux-2.6.22-rc3/drivers/pci/dmar.c   2007-06-04 12:33:15.0 
 -0700
 @@ -0,0 +1,318 @@
 +/*
 + * Copyright (c) 2006, Intel Corporation.
 + *
 + * This program is free software; you can redistribute it and/or modify it
 + * under the terms and conditions of the GNU General Public License,
 + * version 2, as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope 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.
 + *
 + *   Copyright (C) Ashok Raj [EMAIL PROTECTED]
 + *   Copyright (C) Shaohua Li [EMAIL PROTECTED]
 + *
 + *   This file implements early detection/parsing of DMA Remapping Devices
 + * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI
 + * tables.
 + */
 +
 +#include linux/pci.h
 +#include linux/dmar.h
 +
 +#undef PREFIX
 +#define PREFIX DMAR:
 +
 +/* No locks are needed as DMA remapping hardware unit
 + * list is constructed at boot time and hotplug of
 + * these units are not supported by the architecture.
 + */
 +LIST_HEAD(dmar_drhd_units);
 +LIST_HEAD(dmar_rmrr_units);
 +
 +static struct acpi_table_header * __initdata dmar_tbl;
 +
 +static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
 +{
 + /*
 +  * add INCLUDE_ALL at the tail, so scan the list will find it at
 +  * the very end.
 +  */
 + if (drhd-include_all)
 + list_add_tail(drhd-list, dmar_drhd_units);
 + else
 + list_add(drhd-list, dmar_drhd_units);
 +}
 +
 +static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr)
 +{
 + list_add(rmrr-list, dmar_rmrr_units);
 +}
 +
 +static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope 
 *scope,
 +struct pci_dev **dev, u16 segment)
 +{
 + struct pci_bus *bus;
 + struct pci_dev *pdev = NULL;
 + struct acpi_dmar_pci_path *path;
 + int count;
 +
 + bus = pci_find_bus(segment, scope-bus);
 + path = (struct acpi_dmar_pci_path *)(scope + 1);
 + count = (scope-length - sizeof(struct acpi_dmar_device_scope))
 + /sizeof(struct acpi_dmar_pci_path);

add a space.

But overall this casting and typed-struct pointer addition is a bit
fragile.  No comment (I haven't read enough yet) whether it is needed or
not.




 +
 + while (count) {
 + if (pdev)
 + pci_dev_put(pdev);
 + /*
 +  * Some BIOSes list non-exist devices in DMAR table, just
 +  * ignore it
 +  */
 + if (!bus) {
 + printk(KERN_WARNING
 + PREFIX Device scope bus [%d] not found\n,
 + scope-bus);
 + break;
 + }
 + pdev = pci_get_slot(bus, PCI_DEVFN(path-dev, path-fn));
 + if (!pdev) {
 + printk(KERN_WARNING PREFIX
 + Device scope device [%04x:%02x:%02x.%02x] not found\n,
 + segment, bus-number, path-dev, path-fn);
 + break;
 + }
 + path ++;
 + count --;
 + bus = pdev-subordinate;
 + }
 + if (!pdev) {
 + printk(KERN_WARNING PREFIX
 + Device scope device [%04x:%02x:%02x.%02x] not found\n,
 + segment, scope-bus, path-dev, path-fn);
 + *dev = NULL;
 + return 0;
 + }
 + if ((scope-entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT  
 pdev-subordinate)
 +|| (scope-entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE  
 !pdev-subordinate)) {
 + pci_dev_put(pdev);
 + printk(KERN_WARNING PREFIX Device scope type does not match 
 for %s\n, pci_name(pdev));
 + return -EINVAL;
 + }
 + *dev = pdev;
 + 

Re: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Keshavamurthy, Anil S
On Mon, Jun 04, 2007 at 06:54:21PM -0400, Jeff Garzik wrote:
 On Mon, Jun 04, 2007 at 02:02:43PM -0700, [EMAIL PROTECTED] wrote:
  --- linux-2.6.22-rc3.orig/drivers/pci/Makefile  2007-06-04 
  12:28:13.0 -0700
  +++ linux-2.6.22-rc3/drivers/pci/Makefile   2007-06-04 12:33:15.0 
  -0700
  @@ -20,6 +20,9 @@
   # Build the Hypertransport interrupt support
   obj-$(CONFIG_HT_IRQ) += htirq.o
   
  +# Build Intel IOMMU support
  +obj-$(CONFIG_DMAR) += dmar.o
 
 It's not Intel IOMMU support though, is it?
Yes, it is Intel IOMMU support.

 
 It's x86 PCI IOMMU support (as opposed to x86 GART IOMMU).
 
 I just want to avoid Intel branding on something that will not be
 specific to Intel-manufacured products in the long term.

This DMAR (DMA Remapping unit) is Intel specific and
its spec is available at www.intel.com/technology/virtualization

-Anil
-
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: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Jeff Garzik

Is there no way at all, other than ACPI, to find this stuff?

We would prefer to avoid hardware if the hardware enumeration is sane.

Jeff



-
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: [Intel-IOMMU 01/10] DMAR detection and parsing logic

2007-06-04 Thread Keshavamurthy, Anil S
On Mon, Jun 04, 2007 at 07:03:56PM -0400, Jeff Garzik wrote:
 
 Is there no way at all, other than ACPI, to find this stuff?
This is as clean as possible without letting ACPI to parse this
DMA remapping unit. The only thing we might be using is the
acpi data struct.

-Anil
-
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/