]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ACPI: platform-msi: retrieve devid from IORT
authorHanjun Guo <hanjun.guo@linaro.org>
Tue, 7 Mar 2017 12:40:05 +0000 (20:40 +0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Thu, 30 Mar 2017 09:12:40 +0000 (10:12 +0100)
For devices connecting to an ITS, the devices need to identify themself
through a devid; this devid is represented in the IORT table in named
component node [1] for platform devices, so this patch adds code that
scans the IORT table to retrieve the devices devid.

Add an IORT interface to collect ITS devices devid to carry out platform
devices MSI mappings with IORT tables.

[1]: https://static.docs.arm.com/den0049/b/DEN0049B_IO_Remapping_Table.pdf

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
[lorenzo.pieralisi@arm.com: rewrote commit log/dropped ITS changes]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Wei Xu <xuwei5@hisilicon.com>
Tested-by: Sinan Kaya <okaya@codeaurora.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Tomasz Nowicki <tn@semihalf.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
drivers/acpi/arm64/iort.c
include/linux/acpi_iort.h

index 83cd59dcb8b3b750a7ebaf8fe4b32a6d3f99cc9b..fb95ceb3840da4aaa3e2741bdba39923c32bed6d 100644 (file)
@@ -467,6 +467,30 @@ u32 iort_msi_map_rid(struct device *dev, u32 req_id)
        return dev_id;
 }
 
+/**
+ * iort_pmsi_get_dev_id() - Get the device id for a device
+ * @dev: The device for which the mapping is to be done.
+ * @dev_id: The device ID found.
+ *
+ * Returns: 0 for successful find a dev id, -ENODEV on error
+ */
+int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id)
+{
+       int i;
+       struct acpi_iort_node *node;
+
+       node = iort_find_dev_node(dev);
+       if (!node)
+               return -ENODEV;
+
+       for (i = 0; i < node->mapping_count; i++) {
+               if (iort_node_map_platform_id(node, dev_id, IORT_MSI_TYPE, i))
+                       return 0;
+       }
+
+       return -ENODEV;
+}
+
 /**
  * iort_dev_find_its_id() - Find the ITS identifier for a device
  * @dev: The device.
index 77e08099e55404b53225e71f7bd0b9ca34caec4a..fd8b9698e1d15034cde8d18440517a30ef323785 100644 (file)
@@ -34,6 +34,7 @@ void acpi_iort_init(void);
 bool iort_node_match(u8 type);
 u32 iort_msi_map_rid(struct device *dev, u32 req_id);
 struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id);
+int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id);
 /* IOMMU interface */
 void iort_set_dma_mask(struct device *dev);
 const struct iommu_ops *iort_iommu_configure(struct device *dev);