drivers/arm-smmu-v3-nesting: Ensure devices are powered
Change-Id: I72413a9d4d565d27c34ce49c96b07ce0dab088ca
Signed-off-by: Mostafa Saleh <smostafa@google.com>
diff --git a/drivers/misc/pkvm/smmuv3_nesting.c b/drivers/misc/pkvm/smmuv3_nesting.c
index 3a09e53..6f941a8 100644
--- a/drivers/misc/pkvm/smmuv3_nesting.c
+++ b/drivers/misc/pkvm/smmuv3_nesting.c
@@ -82,6 +82,14 @@ static int smmuv3_describe_smmuv3(void)
return total_smmus;
}
+static struct platform_driver smmuv3_nesting_driver;
+
+static int smmuv3_nesting_probe(struct platform_device *pdev)
+{
+ /* Nothing to do, as rpm is not enabled, device should be on. */
+ return 0;
+}
+
static int smmuv3_nesting_init(void)
{
int ret;
@@ -89,6 +97,12 @@ static int smmuv3_nesting_init(void)
int atomic_pages = 6000; /* arbitary for now. */
int nr_smmus;
int nr_pages = 0;
+ bool registered;
+
+ ret = platform_driver_probe(&smmuv3_nesting_driver, smmuv3_nesting_probe);
+ registered = !ret;
+ if (ret)
+ pr_err("smmuv3_nesting: Couldn't probe power domains: %d\n", ret);
nr_smmus = smmuv3_describe_smmuv3();
if (nr_smmus == 0)
@@ -138,8 +152,12 @@ static int smmuv3_nesting_init(void)
__pkvm_topup_hyp_alloc(1);
kvm_nvhe_sym(smmu_cpu_stage_2) = smmu_cpu_stage_2;
- return kvm_iommu_init_hyp(ksym_ref_addr_nvhe(smmuv3_hyp_nesting_ops),
+ ret = kvm_iommu_init_hyp(ksym_ref_addr_nvhe(smmuv3_hyp_nesting_ops),
&atomic_mc, 0);
+
+ if (registered)
+ platform_driver_unregister(&smmuv3_nesting_driver);
+ return ret;
}
static pkvm_handle_t smmuv3_get_iommu_id(struct device *dev)
@@ -163,6 +181,18 @@ static int smmuv3_nesting_register(void)
return kvm_iommu_register_driver(&smmuv3_nesting_ops);
}
+static const struct of_device_id smmuv3_nested_of_match[] = {
+ { .compatible = "arm,smmu-v3-nested", },
+ { },
+};
+
+static struct platform_driver smmuv3_nesting_driver = {
+ .driver = {
+ .name = "smmuv3-nesting",
+ .of_match_table = smmuv3_nested_of_match,
+ },
+};
+
/*
* Register must be run before de-privliage before kvm_iommu_init_driver
* for module case, it should be loaded using pKVM early loading which