ACPI/IORT: Parse SSID property of named component node
[linux-2.6-microblaze.git] / drivers / acpi / arm64 / iort.c
index 33f7198..9f0a9f9 100644 (file)
@@ -11,6 +11,7 @@
 #define pr_fmt(fmt)    "ACPI: IORT: " fmt
 
 #include <linux/acpi_iort.h>
+#include <linux/bitfield.h>
 #include <linux/iommu.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -850,9 +851,9 @@ static inline bool iort_iommu_driver_enabled(u8 type)
 {
        switch (type) {
        case ACPI_IORT_NODE_SMMU_V3:
-               return IS_BUILTIN(CONFIG_ARM_SMMU_V3);
+               return IS_ENABLED(CONFIG_ARM_SMMU_V3);
        case ACPI_IORT_NODE_SMMU:
-               return IS_BUILTIN(CONFIG_ARM_SMMU);
+               return IS_ENABLED(CONFIG_ARM_SMMU);
        default:
                pr_warn("IORT node type %u does not describe an SMMU\n", type);
                return false;
@@ -924,6 +925,20 @@ static int iort_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)
        return iort_iommu_xlate(info->dev, parent, streamid);
 }
 
+static void iort_named_component_init(struct device *dev,
+                                     struct acpi_iort_node *node)
+{
+       struct acpi_iort_named_component *nc;
+       struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
+
+       if (!fwspec)
+               return;
+
+       nc = (struct acpi_iort_named_component *)node->node_data;
+       fwspec->num_pasid_bits = FIELD_GET(ACPI_IORT_NC_PASID_BITS,
+                                          nc->node_flags);
+}
+
 /**
  * iort_iommu_configure - Set-up IOMMU configuration for a device.
  *
@@ -978,6 +993,9 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
                        if (parent)
                                err = iort_iommu_xlate(dev, parent, streamid);
                } while (parent && !err);
+
+               if (!err)
+                       iort_named_component_init(dev, node);
        }
 
        /*