sysfs: use sysfs_attr_init in ASUS atk0110 driver
[safe/jmp/linux-2.6] / drivers / pci / dmar.c
index 56883fc..33ead97 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/tboot.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #define PREFIX "DMAR: "
 
@@ -320,7 +321,7 @@ found:
        for (bus = dev->bus; bus; bus = bus->parent) {
                struct pci_dev *bridge = bus->self;
 
-               if (!bridge || !bridge->is_pcie ||
+               if (!bridge || !pci_is_pcie(bridge) ||
                    bridge->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE)
                        return 0;
 
@@ -613,6 +614,8 @@ int __init dmar_table_init(void)
        return 0;
 }
 
+static int bios_warned;
+
 int __init check_zero_address(void)
 {
        struct acpi_table_dmar *dmar;
@@ -643,6 +646,7 @@ int __init check_zero_address(void)
                                     dmi_get_system_info(DMI_BIOS_VENDOR),
                                     dmi_get_system_info(DMI_BIOS_VERSION),
                                     dmi_get_system_info(DMI_PRODUCT_VERSION));
+                               bios_warned = 1;
                                goto failed;
                        }
 
@@ -662,6 +666,7 @@ int __init check_zero_address(void)
                                      dmi_get_system_info(DMI_BIOS_VENDOR),
                                      dmi_get_system_info(DMI_BIOS_VERSION),
                                      dmi_get_system_info(DMI_PRODUCT_VERSION));
+                               bios_warned = 1;
                                goto failed;
                        }
                }
@@ -700,8 +705,11 @@ void __init detect_intel_iommu(void)
                               "x2apic and Intr-remapping.\n");
 #endif
 #ifdef CONFIG_DMAR
-               if (ret && !no_iommu && !iommu_detected && !dmar_disabled)
+               if (ret && !no_iommu && !iommu_detected && !dmar_disabled) {
                        iommu_detected = 1;
+                       /* Make sure ACS will be enabled */
+                       pci_request_acs();
+               }
 #endif
 #ifdef CONFIG_X86
                if (ret)
@@ -722,6 +730,18 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
        int agaw = 0;
        int msagaw = 0;
 
+       if (!drhd->reg_base_addr) {
+               if (!bios_warned) {
+                       WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
+                            "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+                            dmi_get_system_info(DMI_BIOS_VENDOR),
+                            dmi_get_system_info(DMI_BIOS_VERSION),
+                            dmi_get_system_info(DMI_PRODUCT_VERSION));
+                       bios_warned = 1;
+               }
+               return -EINVAL;
+       }
+
        iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
        if (!iommu)
                return -ENOMEM;
@@ -738,13 +758,16 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
        iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG);
 
        if (iommu->cap == (uint64_t)-1 && iommu->ecap == (uint64_t)-1) {
-               /* Promote an attitude of violence to a BIOS engineer today */
-               WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
-                    "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
-                    drhd->reg_base_addr,
-                    dmi_get_system_info(DMI_BIOS_VENDOR),
-                    dmi_get_system_info(DMI_BIOS_VERSION),
-                    dmi_get_system_info(DMI_PRODUCT_VERSION));
+               if (!bios_warned) {
+                       /* Promote an attitude of violence to a BIOS engineer today */
+                       WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
+                            "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+                            drhd->reg_base_addr,
+                            dmi_get_system_info(DMI_BIOS_VENDOR),
+                            dmi_get_system_info(DMI_BIOS_VERSION),
+                            dmi_get_system_info(DMI_PRODUCT_VERSION));
+                       bios_warned = 1;
+               }
                goto err_unmap;
        }