Skip to content

Commit 0b4eeee

Browse files
Georgi Djakovwilldeacon
authored andcommitted
iommu/arm-smmu-qcom: Register the TBU driver in qcom_smmu_impl_init
Currently the TBU driver will only probe when CONFIG_ARM_SMMU_QCOM_DEBUG is enabled. The driver not probing would prevent the platform to reach sync_state and the system will remain in sub-optimal power consumption mode while waiting for all consumer drivers to probe. To address this, let's register the TBU driver in qcom_smmu_impl_init(), so that it can probe, but still enable its functionality only when the debug option in Kconfig is enabled. Reported-by: Dmitry Baryshkov <[email protected]> Closes: https://lore.kernel.org/r/CAA8EJppcXVu72OSo+OiYEiC1HQjP3qCwKMumOsUhcn6Czj0URg@mail.gmail.com Fixes: 414ecb0 ("iommu/arm-smmu-qcom-debug: Add support for TBUs") Signed-off-by: Georgi Djakov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 25c776d commit 0b4eeee

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ irqreturn_t qcom_smmu_context_fault(int irq, void *dev)
464464
return ret;
465465
}
466466

467-
static int qcom_tbu_probe(struct platform_device *pdev)
467+
int qcom_tbu_probe(struct platform_device *pdev)
468468
{
469469
struct of_phandle_args args = { .args_count = 2 };
470470
struct device_node *np = pdev->dev.of_node;
@@ -506,18 +506,3 @@ static int qcom_tbu_probe(struct platform_device *pdev)
506506

507507
return 0;
508508
}
509-
510-
static const struct of_device_id qcom_tbu_of_match[] = {
511-
{ .compatible = "qcom,sc7280-tbu" },
512-
{ .compatible = "qcom,sdm845-tbu" },
513-
{ }
514-
};
515-
516-
static struct platform_driver qcom_tbu_driver = {
517-
.driver = {
518-
.name = "qcom_tbu",
519-
.of_match_table = qcom_tbu_of_match,
520-
},
521-
.probe = qcom_tbu_probe,
522-
};
523-
builtin_platform_driver(qcom_tbu_driver);

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <linux/delay.h>
99
#include <linux/of_device.h>
1010
#include <linux/firmware/qcom/qcom_scm.h>
11+
#include <linux/platform_device.h>
12+
#include <linux/pm_runtime.h>
1113

1214
#include "arm-smmu.h"
1315
#include "arm-smmu-qcom.h"
@@ -562,10 +564,47 @@ static struct acpi_platform_list qcom_acpi_platlist[] = {
562564
};
563565
#endif
564566

567+
static int qcom_smmu_tbu_probe(struct platform_device *pdev)
568+
{
569+
struct device *dev = &pdev->dev;
570+
int ret;
571+
572+
if (IS_ENABLED(CONFIG_ARM_SMMU_QCOM_DEBUG)) {
573+
ret = qcom_tbu_probe(pdev);
574+
if (ret)
575+
return ret;
576+
}
577+
578+
if (dev->pm_domain) {
579+
pm_runtime_set_active(dev);
580+
pm_runtime_enable(dev);
581+
}
582+
583+
return 0;
584+
}
585+
586+
static const struct of_device_id qcom_smmu_tbu_of_match[] = {
587+
{ .compatible = "qcom,sc7280-tbu" },
588+
{ .compatible = "qcom,sdm845-tbu" },
589+
{ }
590+
};
591+
592+
static struct platform_driver qcom_smmu_tbu_driver = {
593+
.driver = {
594+
.name = "qcom_tbu",
595+
.of_match_table = qcom_smmu_tbu_of_match,
596+
},
597+
.probe = qcom_smmu_tbu_probe,
598+
};
599+
565600
struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu)
566601
{
567602
const struct device_node *np = smmu->dev->of_node;
568603
const struct of_device_id *match;
604+
static u8 tbu_registered;
605+
606+
if (!tbu_registered++)
607+
platform_driver_register(&qcom_smmu_tbu_driver);
569608

570609
#ifdef CONFIG_ACPI
571610
if (np == NULL) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ irqreturn_t qcom_smmu_context_fault(int irq, void *dev);
3434

3535
#ifdef CONFIG_ARM_SMMU_QCOM_DEBUG
3636
void qcom_smmu_tlb_sync_debug(struct arm_smmu_device *smmu);
37+
int qcom_tbu_probe(struct platform_device *pdev);
3738
#else
3839
static inline void qcom_smmu_tlb_sync_debug(struct arm_smmu_device *smmu) { }
40+
static inline int qcom_tbu_probe(struct platform_device *pdev) { return -EINVAL; }
3941
#endif
4042

4143
#endif /* _ARM_SMMU_QCOM_H */

0 commit comments

Comments
 (0)