2024-04-17 20:08:42

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 0/2] Small qcom_iommu cleanups

As it says on the can

Signed-off-by: Konrad Dybcio <[email protected]>
---
Konrad Dybcio (2):
iommu/qcom: Remove useless forward definition
iommu/qcom: Always consume all clocks

drivers/iommu/arm/arm-smmu/qcom_iommu.c | 54 +++++++++------------------------
1 file changed, 15 insertions(+), 39 deletions(-)
---
base-commit: 2b3d5988ae2cb5cd945ddbc653f0a71706231fdd
change-id: 20240416-topic-qcom_iommu-8ef262408c9e

Best regards,
--
Konrad Dybcio <[email protected]>



2024-04-17 20:13:13

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 2/2] iommu/qcom: Always consume all clocks

Some platforms provide more clocks than others, we already have the DT
schema to ensure sanity here plus these clocks simply need to be on.

Use devm_clk_bulk_get_all and get rid of some boilerplate.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 38 +++++++--------------------------
1 file changed, 8 insertions(+), 30 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index 3dca9293c509..ace69030a422 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -34,13 +34,6 @@

#define SMMU_INTR_SEL_NS 0x2000

-enum qcom_iommu_clk {
- CLK_IFACE,
- CLK_BUS,
- CLK_TBU,
- CLK_NUM,
-};
-
struct qcom_iommu_ctx {
struct device *dev;
void __iomem *base;
@@ -54,7 +47,8 @@ struct qcom_iommu_dev {
/* IOMMU core code handle */
struct iommu_device iommu;
struct device *dev;
- struct clk_bulk_data clks[CLK_NUM];
+ struct clk_bulk_data *clks;
+ int num_clks;
void __iomem *local_base;
u32 sec_id;
u8 max_asid;
@@ -781,7 +775,6 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
struct qcom_iommu_dev *qcom_iommu;
struct device *dev = &pdev->dev;
struct resource *res;
- struct clk *clk;
int ret, max_asid = 0;

/* find the max asid (which is 1:1 to ctx bank idx), so we know how
@@ -804,26 +797,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
return PTR_ERR(qcom_iommu->local_base);
}

- clk = devm_clk_get(dev, "iface");
- if (IS_ERR(clk)) {
- dev_err(dev, "failed to get iface clock\n");
- return PTR_ERR(clk);
- }
- qcom_iommu->clks[CLK_IFACE].clk = clk;
-
- clk = devm_clk_get(dev, "bus");
- if (IS_ERR(clk)) {
- dev_err(dev, "failed to get bus clock\n");
- return PTR_ERR(clk);
- }
- qcom_iommu->clks[CLK_BUS].clk = clk;
+ ret = devm_clk_bulk_get_all(dev, &qcom_iommu->clks);
+ if (ret <= 0)
+ return dev_err_probe(dev, ret, "Couldn't get clocks\n");

- clk = devm_clk_get_optional(dev, "tbu");
- if (IS_ERR(clk)) {
- dev_err(dev, "failed to get tbu clock\n");
- return PTR_ERR(clk);
- }
- qcom_iommu->clks[CLK_TBU].clk = clk;
+ qcom_iommu->num_clks = ret;

if (of_property_read_u32(dev->of_node, "qcom,iommu-secure-id",
&qcom_iommu->sec_id)) {
@@ -891,7 +869,7 @@ static int __maybe_unused qcom_iommu_resume(struct device *dev)
struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev);
int ret;

- ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks);
+ ret = clk_bulk_prepare_enable(qcom_iommu->num_clks, qcom_iommu->clks);
if (ret < 0)
return ret;

@@ -905,7 +883,7 @@ static int __maybe_unused qcom_iommu_suspend(struct device *dev)
{
struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev);

- clk_bulk_disable_unprepare(CLK_NUM, qcom_iommu->clks);
+ clk_bulk_disable_unprepare(qcom_iommu->num_clks, qcom_iommu->clks);

return 0;
}

--
2.44.0


2024-04-17 20:37:49

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH 2/2] iommu/qcom: Always consume all clocks

On Wed, Apr 17, 2024 at 10:07:00PM +0200, Konrad Dybcio wrote:
> Some platforms provide more clocks than others, we already have the DT
> schema to ensure sanity here plus these clocks simply need to be on.
>
> Use devm_clk_bulk_get_all and get rid of some boilerplate.
>
> Signed-off-by: Konrad Dybcio <[email protected]>

Reviewed-by: Bjorn Andersson <[email protected]>

Regards,
Bjorn