Skip to content

Commit 4c1d0ad

Browse files
lumagwilldeacon
authored andcommitted
iommu/arm-smmu-qcom: Move implementation data into match data
In preparation to rework of the implementation and configuration details, make qcom_smmu_create() accept new qcom_smmu_match_data structure pointer. Make implementation a field in this struct. Reviewed-by: Sai Prakash Ranjan <[email protected]> Tested-by: Sai Prakash Ranjan <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 6c84bbd commit 4c1d0ad

File tree

2 files changed

+44
-22
lines changed

2 files changed

+44
-22
lines changed

drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,18 @@ static const struct arm_smmu_impl qcom_adreno_smmu_impl = {
405405
};
406406

407407
static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu,
408-
const struct arm_smmu_impl *impl)
408+
const struct qcom_smmu_match_data *data)
409409
{
410+
const struct arm_smmu_impl *impl;
410411
struct qcom_smmu *qsmmu;
411412

413+
if (!data)
414+
return ERR_PTR(-EINVAL);
415+
416+
impl = data->impl;
417+
if (!impl)
418+
return smmu;
419+
412420
/* Check to make sure qcom_scm has finished probing */
413421
if (!qcom_scm_is_available())
414422
return ERR_PTR(-EPROBE_DEFER);
@@ -423,24 +431,32 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu,
423431
return &qsmmu->smmu;
424432
}
425433

434+
static const struct qcom_smmu_match_data qcom_smmu_data = {
435+
.impl = &qcom_smmu_impl,
436+
};
437+
438+
static const struct qcom_smmu_match_data qcom_adreno_smmu_data = {
439+
.impl = &qcom_adreno_smmu_impl,
440+
};
441+
426442
static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
427-
{ .compatible = "qcom,msm8998-smmu-v2" },
428-
{ .compatible = "qcom,qcm2290-smmu-500" },
429-
{ .compatible = "qcom,qdu1000-smmu-500" },
430-
{ .compatible = "qcom,sc7180-smmu-500" },
431-
{ .compatible = "qcom,sc7280-smmu-500" },
432-
{ .compatible = "qcom,sc8180x-smmu-500" },
433-
{ .compatible = "qcom,sc8280xp-smmu-500" },
434-
{ .compatible = "qcom,sdm630-smmu-v2" },
435-
{ .compatible = "qcom,sdm845-smmu-500" },
436-
{ .compatible = "qcom,sm6115-smmu-500" },
437-
{ .compatible = "qcom,sm6125-smmu-500" },
438-
{ .compatible = "qcom,sm6350-smmu-500" },
439-
{ .compatible = "qcom,sm6375-smmu-500" },
440-
{ .compatible = "qcom,sm8150-smmu-500" },
441-
{ .compatible = "qcom,sm8250-smmu-500" },
442-
{ .compatible = "qcom,sm8350-smmu-500" },
443-
{ .compatible = "qcom,sm8450-smmu-500" },
443+
{ .compatible = "qcom,msm8998-smmu-v2", .data = &qcom_smmu_data },
444+
{ .compatible = "qcom,qcm2290-smmu-500", .data = &qcom_smmu_data },
445+
{ .compatible = "qcom,qdu1000-smmu-500", .data = &qcom_smmu_data },
446+
{ .compatible = "qcom,sc7180-smmu-500", .data = &qcom_smmu_data },
447+
{ .compatible = "qcom,sc7280-smmu-500", .data = &qcom_smmu_data },
448+
{ .compatible = "qcom,sc8180x-smmu-500", .data = &qcom_smmu_data },
449+
{ .compatible = "qcom,sc8280xp-smmu-500", .data = &qcom_smmu_data },
450+
{ .compatible = "qcom,sdm630-smmu-v2", .data = &qcom_smmu_data },
451+
{ .compatible = "qcom,sdm845-smmu-500", .data = &qcom_smmu_data },
452+
{ .compatible = "qcom,sm6115-smmu-500", .data = &qcom_smmu_data },
453+
{ .compatible = "qcom,sm6125-smmu-500", .data = &qcom_smmu_data },
454+
{ .compatible = "qcom,sm6350-smmu-500", .data = &qcom_smmu_data },
455+
{ .compatible = "qcom,sm6375-smmu-500", .data = &qcom_smmu_data },
456+
{ .compatible = "qcom,sm8150-smmu-500", .data = &qcom_smmu_data },
457+
{ .compatible = "qcom,sm8250-smmu-500", .data = &qcom_smmu_data },
458+
{ .compatible = "qcom,sm8350-smmu-500", .data = &qcom_smmu_data },
459+
{ .compatible = "qcom,sm8450-smmu-500", .data = &qcom_smmu_data },
444460
{ }
445461
};
446462

@@ -455,12 +471,13 @@ static struct acpi_platform_list qcom_acpi_platlist[] = {
455471
struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu)
456472
{
457473
const struct device_node *np = smmu->dev->of_node;
474+
const struct of_device_id *match;
458475

459476
#ifdef CONFIG_ACPI
460477
if (np == NULL) {
461478
/* Match platform for ACPI boot */
462479
if (acpi_match_platform_list(qcom_acpi_platlist) >= 0)
463-
return qcom_smmu_create(smmu, &qcom_smmu_impl);
480+
return qcom_smmu_create(smmu, &qcom_smmu_data);
464481
}
465482
#endif
466483

@@ -471,10 +488,11 @@ struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu)
471488
* features if the order is changed.
472489
*/
473490
if (of_device_is_compatible(np, "qcom,adreno-smmu"))
474-
return qcom_smmu_create(smmu, &qcom_adreno_smmu_impl);
491+
return qcom_smmu_create(smmu, &qcom_adreno_smmu_data);
475492

476-
if (of_match_node(qcom_smmu_impl_of_match, np))
477-
return qcom_smmu_create(smmu, &qcom_smmu_impl);
493+
match = of_match_node(qcom_smmu_impl_of_match, np);
494+
if (match)
495+
return qcom_smmu_create(smmu, match->data);
478496

479497
return smmu;
480498
}

drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ struct qcom_smmu {
1414
u32 stall_enabled;
1515
};
1616

17+
struct qcom_smmu_match_data {
18+
const struct arm_smmu_impl *impl;
19+
};
20+
1721
#ifdef CONFIG_ARM_SMMU_QCOM_DEBUG
1822
void qcom_smmu_tlb_sync_debug(struct arm_smmu_device *smmu);
1923
const void *qcom_smmu_impl_data(struct arm_smmu_device *smmu);

0 commit comments

Comments
 (0)