linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-qcom: create qcom_smmu_impl for ACPI boot
@ 2021-03-01  7:40 Shawn Guo
  2021-03-25 14:59 ` Will Deacon
  0 siblings, 1 reply; 8+ messages in thread
From: Shawn Guo @ 2021-03-01  7:40 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-arm-msm, Shawn Guo, Robin Murphy, linux-arm-kernel,
	Bjorn Andersson

Though qcom_adreno_smmu_impl is not used by ACPI boot right now,
qcom_smmu_impl is already required at least to boot up Lenovo Flex 5G
laptop.  Let's check asl_compiler_id in IORT header to ensure we are
running a QCOM SMMU and create qcom_smmu_impl for it.

!np is used to check ACPI boot, because fwnode of SMMU device is
a static allocation and thus has_acpi_companion() doesn't work here.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
index 98b3a1c2a181..5e8779483367 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  */
 
+#include <linux/acpi_iort.h>
 #include <linux/adreno-smmu-priv.h>
 #include <linux/of_device.h>
 #include <linux/qcom_scm.h>
@@ -339,10 +340,42 @@ static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
 	{ }
 };
 
+#ifdef CONFIG_ACPI
+static bool is_qcom_iort(struct arm_smmu_device *smmu)
+{
+	struct acpi_table_header *iort;
+	acpi_status status;
+	bool ret = false;
+
+	status = acpi_get_table(ACPI_SIG_IORT, 0, &iort);
+	if (ACPI_FAILURE(status)) {
+		dev_err(smmu->dev, "failed to get IORT\n");
+		goto done;
+	}
+
+	if (strncmp(iort->asl_compiler_id, "QCOM", 4) == 0) {
+		ret = true;
+		goto done;
+	}
+
+done:
+	acpi_put_table(iort);
+	return ret;
+}
+#else
+static bool is_qcom_iort(struct arm_smmu_device *smmu)
+{
+	return false;
+}
+#endif
+
 struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu)
 {
 	const struct device_node *np = smmu->dev->of_node;
 
+	if (!np && is_qcom_iort(smmu))
+		return qcom_smmu_create(smmu, &qcom_smmu_impl);
+
 	if (of_match_node(qcom_smmu_impl_of_match, np))
 		return qcom_smmu_create(smmu, &qcom_smmu_impl);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-04-08  2:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-01  7:40 [PATCH] iommu/arm-smmu-qcom: create qcom_smmu_impl for ACPI boot Shawn Guo
2021-03-25 14:59 ` Will Deacon
2021-03-25 17:02   ` Bjorn Andersson
2021-03-25 17:07     ` Robin Murphy
2021-03-28  8:44       ` Shawn Guo
2021-03-28  8:18     ` Shawn Guo
2021-04-06 16:23     ` Lorenzo Pieralisi
2021-04-08  2:05       ` Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).