mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pankaj Bansal <pankaj.bansal@nxp.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Hanjun Guo <guohanjun@huawei.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>, Varun Sethi <V.Sethi@nxp.com>,
	linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI/IORT: fix output id retrieval for platform devices
Date: Mon, 17 Feb 2020 19:45:04 +0530	[thread overview]
Message-ID: <20200217141504.4183-1-pankaj.bansal@nxp.com> (raw)

As per IORT spec if Single mapping flag is not defined for
a node, the output id ought to to be retrieved using input
id from an ID mapping.

Current code of output id retrieval for platform devices
ignored this case. fixed the same.

Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
---
 drivers/acpi/arm64/iort.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index ed3d2d1a7ae9..00e562dadd2a 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -358,7 +358,9 @@ static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in,
 	/* Single mapping does not care for input id */
 	if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) {
 		if (type == ACPI_IORT_NODE_NAMED_COMPONENT ||
-		    type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
+		    type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX ||
+		    type == ACPI_IORT_NODE_SMMU_V3 ||
+		    type == ACPI_IORT_NODE_PMCG) {
 			*rid_out = map->output_base;
 			return 0;
 		}
@@ -376,7 +378,8 @@ static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in,
 }
 
 static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node,
-					       u32 *id_out, int index)
+					       u32 id_in, u32 *id_out,
+					       int index)
 {
 	struct acpi_iort_node *parent;
 	struct acpi_iort_id_mapping *map;
@@ -398,15 +401,8 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node,
 	parent = ACPI_ADD_PTR(struct acpi_iort_node, iort_table,
 			       map->output_reference);
 
-	if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) {
-		if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT ||
-		    node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX ||
-		    node->type == ACPI_IORT_NODE_SMMU_V3 ||
-		    node->type == ACPI_IORT_NODE_PMCG) {
-			*id_out = map->output_base;
-			return parent;
-		}
-	}
+	if (!iort_id_map(map, node->type, id_in, id_out))
+		return parent;
 
 	return NULL;
 }
@@ -510,14 +506,14 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
 }
 
 static struct acpi_iort_node *iort_node_map_platform_id(
-		struct acpi_iort_node *node, u32 *id_out, u8 type_mask,
-		int index)
+		struct acpi_iort_node *node, u32 id_in, u32 *id_out,
+		u8 type_mask, int index)
 {
 	struct acpi_iort_node *parent;
 	u32 id;
 
 	/* step 1: retrieve the initial dev id */
-	parent = iort_node_get_id(node, &id, index);
+	parent = iort_node_get_id(node, id_in, &id, index);
 	if (!parent)
 		return NULL;
 
@@ -592,7 +588,8 @@ u32 iort_msi_map_rid(struct device *dev, u32 req_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.
+ * @dev_id: On function entry the input id for device.
+ *          On successful function exit, the output device ID found.
  *
  * Returns: 0 for successful find a dev id, -ENODEV on error
  */
@@ -608,11 +605,11 @@ int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id)
 	index = iort_get_id_mapping_index(node);
 	/* if there is a valid index, go get the dev_id directly */
 	if (index >= 0) {
-		if (iort_node_get_id(node, dev_id, index))
+		if (iort_node_get_id(node, *dev_id, dev_id, index))
 			return 0;
 	} else {
 		for (i = 0; i < node->mapping_count; i++) {
-			if (iort_node_map_platform_id(node, dev_id,
+			if (iort_node_map_platform_id(node, *dev_id, dev_id,
 						      IORT_MSI_TYPE, i))
 				return 0;
 		}
@@ -761,7 +758,7 @@ static struct irq_domain *iort_get_platform_device_domain(struct device *dev)
 
 	/* then find its msi parent node */
 	for (i = 0; i < node->mapping_count; i++) {
-		msi_parent = iort_node_map_platform_id(node, NULL,
+		msi_parent = iort_node_map_platform_id(node, 0, NULL,
 						       IORT_MSI_TYPE, i);
 		if (msi_parent)
 			break;
@@ -1038,7 +1035,8 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
 			return NULL;
 
 		do {
-			parent = iort_node_map_platform_id(node, &streamid,
+			parent = iort_node_map_platform_id(node, streamid,
+							   &streamid,
 							   IORT_IOMMU_TYPE,
 							   i++);
 
-- 
2.17.1


             reply	other threads:[~2020-02-17  8:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 14:15 Pankaj Bansal [this message]
2020-02-17 11:04 ` Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200217141504.4183-1-pankaj.bansal@nxp.com \
    --to=pankaj.bansal@nxp.com \
    --cc=V.Sethi@nxp.com \
    --cc=guohanjun@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®