Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1518209

[PATCH v7 15/16] drivers: acpi: iort: add single mapping function

From Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Newsgroups linux.kernel
Subject [PATCH v7 15/16] drivers: acpi: iort: add single mapping function
Date 2016-11-09 15:30 +0100
Message-ID <sBC30-8sr-21@gated-at.bofh.it> (permalink)
References <sBBTj-8ph-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The current IORT id mapping API requires components to provide
an input requester ID (a Bus-Device-Function (BDF) identifier for
PCI devices) to translate an input identifier to an output
identifier through an IORT range mapping.

Named components do not have an identifiable source ID therefore
their respective input/output mapping can only be defined in
IORT tables through single mappings, that provide a translation
that does not require any input identifier.

Current IORT interface for requester id mappings (iort_node_map_rid())
is not suitable for components that do not provide a requester id,
so it cannot be used for IORT named components.

Add an interface to the IORT API to enable retrieval of id
by allowing an indexed walk of the single mappings array for
a given component, therefore completing the IORT mapping API.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Hanjun Guo <hanjun.guo@linaro.org>
Tested-by: Tomasz Nowicki <tn@semihalf.com>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Cc: Tomasz Nowicki <tn@semihalf.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
---
 drivers/acpi/arm64/iort.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 62057c6..7d30605 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -318,6 +318,45 @@ static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in,
 	return 0;
 }
 
+static
+struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node,
+					u32 *id_out, u8 type_mask,
+					int index)
+{
+	struct acpi_iort_node *parent;
+	struct acpi_iort_id_mapping *map;
+
+	if (!node->mapping_offset || !node->mapping_count ||
+				     index >= node->mapping_count)
+		return NULL;
+
+	map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node,
+			   node->mapping_offset);
+
+	/* Firmware bug! */
+	if (!map->output_reference) {
+		pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
+		       node, node->type);
+		return NULL;
+	}
+
+	parent = ACPI_ADD_PTR(struct acpi_iort_node, iort_table,
+			       map->output_reference);
+
+	if (!(IORT_TYPE_MASK(parent->type) & type_mask))
+		return NULL;
+
+	if (map[index].flags & ACPI_IORT_ID_SINGLE_MAPPING) {
+		if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT ||
+		    node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
+			*id_out = map[index].output_base;
+			return parent;
+		}
+	}
+
+	return NULL;
+}
+
 static struct acpi_iort_node *iort_node_map_rid(struct acpi_iort_node *node,
 						u32 rid_in, u32 *rid_out,
 						u8 type_mask)
-- 
2.10.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v7 00/16] ACPI IORT ARM SMMU support Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
  [PATCH v7 01/16] drivers: acpi: add FWNODE_ACPI_STATIC fwnode type Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
    Re: [PATCH v7 01/16] drivers: acpi: add FWNODE_ACPI_STATIC fwnode type "Rafael J. Wysocki" <rafael@kernel.org> - 2016-11-10 00:40 +0100
  [PATCH v7 02/16] drivers: acpi: iort: introduce linker section for IORT entries probing Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
  [PATCH v7 16/16] drivers: acpi: iort: introduce iort_iommu_configure Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
  [PATCH v7 11/16] drivers: iommu: arm-smmu-v3: add IORT configuration Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
  [PATCH v7 08/16] drivers: acpi: iort: add node match function Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
  [PATCH v7 13/16] drivers: iommu: arm-smmu: add IORT configuration Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:20 +0100
  [PATCH v7 05/16] drivers: iommu: arm-smmu: convert struct device of_node to fwnode usage Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
    Re: [PATCH v7 05/16] drivers: iommu: arm-smmu: convert struct device  of_node to fwnode usage Robin Murphy <robin.murphy@arm.com> - 2016-11-09 15:50 +0100
  [PATCH v7 03/16] drivers: acpi: iort: add support for IOMMU fwnode registration Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
  [PATCH v7 15/16] drivers: acpi: iort: add single mapping function Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
  [PATCH v7 14/16] drivers: acpi: iort: replace rid map type with type mask Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
  [PATCH v7 06/16] drivers: iommu: arm-smmu-v3: convert struct device of_node to fwnode usage Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
    Re: [PATCH v7 06/16] drivers: iommu: arm-smmu-v3: convert struct  device of_node to fwnode usage Robin Murphy <robin.murphy@arm.com> - 2016-11-09 15:50 +0100
  [PATCH v7 12/16] drivers: iommu: arm-smmu: split probe functions into DT/generic portions Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
  [PATCH v7 10/16] drivers: iommu: arm-smmu-v3: split probe functions into DT/generic portions Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
  [PATCH v7 09/16] drivers: acpi: iort: add support for ARM SMMU platform devices creation Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
  [PATCH v7 07/16] drivers: acpi: implement acpi_dma_configure Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-09 15:30 +0100
    Re: [PATCH v7 07/16] drivers: acpi: implement acpi_dma_configure Robin Murphy <robin.murphy@arm.com> - 2016-11-09 16:50 +0100
  Re: [PATCH v7 00/16] ACPI IORT ARM SMMU support "Rafael J. Wysocki" <rafael@kernel.org> - 2016-11-10 00:40 +0100
    Re: [PATCH v7 00/16] ACPI IORT ARM SMMU support Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-10 12:00 +0100
  Re: [PATCH v7 00/16] ACPI IORT ARM SMMU support Hanjun Guo <hanjun.guo@linaro.org> - 2016-11-11 13:50 +0100

csiph-web