Re: [PATCH v7 4/5] iommu/arm-smmu: add ACTLR data and support for SM8550

From: Pavan Kondeti
Date: Tue Jan 09 2024 - 23:36:06 EST


On Tue, Jan 09, 2024 at 05:12:19PM +0530, Bibek Kumar Patro wrote:
> +static const struct actlr_variant sm8550_actlr[] = {
> + { sm8550_apps_actlr_cfg, 0x15000000 },
> + { sm8550_gfx_actlr_cfg, 0x03da0000 },
> + {},
> +};
> +
> static struct qcom_smmu *to_qcom_smmu(struct arm_smmu_device *smmu)
> {
> return container_of(smmu, struct qcom_smmu, smmu);
> @@ -597,6 +673,14 @@ static const struct qcom_smmu_match_data sdm845_smmu_500_data = {
> /* Also no debug configuration. */
> };
>
> +
> +static const struct qcom_smmu_match_data sm8550_smmu_500_impl0_data = {
> + .impl = &qcom_smmu_500_impl,
> + .adreno_impl = &qcom_adreno_smmu_500_impl,
> + .cfg = &qcom_smmu_impl0_cfg,
> + .actlrvar = sm8550_actlr,
> +};
> +

I wish there is Rust like struct update syntax possible here. All we need
here is to update qcom_smmu_match_data::actlrvar member here to the generic
qcom_smmu_500_impl0_data struct data.

> static const struct qcom_smmu_match_data qcom_smmu_500_impl0_data = {
> .impl = &qcom_smmu_500_impl,
> .adreno_impl = &qcom_adreno_smmu_500_impl,
> @@ -631,6 +715,7 @@ static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
> { .compatible = "qcom,sm8250-smmu-500", .data = &qcom_smmu_500_impl0_data },
> { .compatible = "qcom,sm8350-smmu-500", .data = &qcom_smmu_500_impl0_data },
> { .compatible = "qcom,sm8450-smmu-500", .data = &qcom_smmu_500_impl0_data },
> + { .compatible = "qcom,sm8550-smmu-500", .data = &sm8550_smmu_500_impl0_data },
> { .compatible = "qcom,smmu-500", .data = &qcom_smmu_500_impl0_data },
> { }
> };

Given that ACTLR data is different across SoCs, would it be a good idea
to decouple it from the qcom_smmu_match_data struct and directly get it
via of_device_is_compatible() from context init functions. The ACTLR
data will have a compatible string associated with it, we lookup for the
device compatible in this table and select the ACTLR accordingly. This
way, we don't need to add more entries to qcom_smmu_impl_of_match and
keep using the "qcom,smmu-500" for driver match data.

I have made this suggestion to keep the rule introduced in commit
80b71080720e ("iommu/arm-smmu-qcom: Add generic qcom,smmu-500 match
entry") relavant. I will let Dmitry to provide the guidance here.

Thanks,
Pavan