iommu/arm-smmu-qcom: Move the qcom,adreno-smmu check into qcom_smmu_create
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Mon, 14 Nov 2022 17:06:31 +0000 (20:06 +0300)
committerWill Deacon <will@kernel.org>
Mon, 14 Nov 2022 18:09:38 +0000 (18:09 +0000)
Move special handling of qcom,adreno-smmu into qcom_smmu_create()
function. This allows us to further customize the Adreno SMMU
implementation.

Note, this also adds two entries to the qcom_smmu_impl_of_match table.
They were used with the qcom,adreno-smmu compat and were handled by the
removed clause.

Reviewed-by: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
Tested-by: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20221114170635.1406534-7-dmitry.baryshkov@linaro.org
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h

index a7bd49e..e611941 100644 (file)
@@ -407,13 +407,18 @@ static const struct arm_smmu_impl qcom_adreno_smmu_impl = {
 static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu,
                const struct qcom_smmu_match_data *data)
 {
+       const struct device_node *np = smmu->dev->of_node;
        const struct arm_smmu_impl *impl;
        struct qcom_smmu *qsmmu;
 
        if (!data)
                return ERR_PTR(-EINVAL);
 
-       impl = data->impl;
+       if (np && of_device_is_compatible(np, "qcom,adreno-smmu"))
+               impl = data->adreno_impl;
+       else
+               impl = data->impl;
+
        if (!impl)
                return smmu;
 
@@ -431,15 +436,22 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu,
        return &qsmmu->smmu;
 }
 
-static const struct qcom_smmu_match_data qcom_smmu_data = {
-       .impl = &qcom_smmu_impl,
+/*
+ * It is not yet possible to use MDP SMMU with the bypass quirk on the msm8996,
+ * there are not enough context banks.
+ */
+static const struct qcom_smmu_match_data msm8996_smmu_data = {
+       .impl = NULL,
+       .adreno_impl = &qcom_adreno_smmu_impl,
 };
 
-static const struct qcom_smmu_match_data qcom_adreno_smmu_data = {
-       .impl = &qcom_adreno_smmu_impl,
+static const struct qcom_smmu_match_data qcom_smmu_data = {
+       .impl = &qcom_smmu_impl,
+       .adreno_impl = &qcom_adreno_smmu_impl,
 };
 
 static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
+       { .compatible = "qcom,msm8996-smmu-v2", .data = &msm8996_smmu_data },
        { .compatible = "qcom,msm8998-smmu-v2", .data = &qcom_smmu_data },
        { .compatible = "qcom,qcm2290-smmu-500", .data = &qcom_smmu_data },
        { .compatible = "qcom,qdu1000-smmu-500", .data = &qcom_smmu_data  },
@@ -448,6 +460,7 @@ static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
        { .compatible = "qcom,sc8180x-smmu-500", .data = &qcom_smmu_data },
        { .compatible = "qcom,sc8280xp-smmu-500", .data = &qcom_smmu_data },
        { .compatible = "qcom,sdm630-smmu-v2", .data = &qcom_smmu_data },
+       { .compatible = "qcom,sdm845-smmu-v2", .data = &qcom_smmu_data },
        { .compatible = "qcom,sdm845-smmu-500", .data = &qcom_smmu_data },
        { .compatible = "qcom,sm6115-smmu-500", .data = &qcom_smmu_data },
        { .compatible = "qcom,sm6125-smmu-500", .data = &qcom_smmu_data },
@@ -481,15 +494,6 @@ struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu)
        }
 #endif
 
-       /*
-        * Do not change this order of implementation, i.e., first adreno
-        * smmu impl and then apss smmu since we can have both implementing
-        * arm,mmu-500 in which case we will miss setting adreno smmu specific
-        * features if the order is changed.
-        */
-       if (of_device_is_compatible(np, "qcom,adreno-smmu"))
-               return qcom_smmu_create(smmu, &qcom_adreno_smmu_data);
-
        match = of_match_node(qcom_smmu_impl_of_match, np);
        if (match)
                return qcom_smmu_create(smmu, match->data);
index 2424f10..424d8d3 100644 (file)
@@ -16,6 +16,7 @@ struct qcom_smmu {
 
 struct qcom_smmu_match_data {
        const struct arm_smmu_impl *impl;
+       const struct arm_smmu_impl *adreno_impl;
 };
 
 #ifdef CONFIG_ARM_SMMU_QCOM_DEBUG