diff mbox series

[PATCHv3,2/2] iommu/arm-smmu: Add SMMU clock

Message ID 1538605693-22073-3-git-send-email-thor.thayer@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series iommu/arm-smmu: Add Stratix10 SMMU Support | expand

Commit Message

Thor Thayer Oct. 3, 2018, 10:28 p.m. UTC
From: Thor Thayer <thor.thayer@linux.intel.com>

Add a clock to the SMMU structure. In the device tree case,
check for a clock node and enable the clock if found.

This patch is dependent upon the following patches that add
a device tree bulk clock function.
"[V6, 1/4] clk: bulk: add of_clk_bulk_get()"
https://patchwork.kernel.org/patch/10583133/
"[V6, 2/4] clk: add new APIs to operation on all available
clocks"
https://patchwork.kernel.org/patch/10583131/
"[V6, 3/4] clk: add managerged version of clk_bulk_get_all"
https://patchwork.kernel.org/patch/10583139/

Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
---
 drivers/iommu/arm-smmu.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Vivek Gautam Oct. 4, 2018, 6:49 p.m. UTC | #1
Hi Thor,


On 10/4/2018 3:58 AM, thor.thayer@linux.intel.com wrote:
> From: Thor Thayer <thor.thayer@linux.intel.com>
>
> Add a clock to the SMMU structure. In the device tree case,
> check for a clock node and enable the clock if found.
>
> This patch is dependent upon the following patches that add
> a device tree bulk clock function.
> "[V6, 1/4] clk: bulk: add of_clk_bulk_get()"
> https://patchwork.kernel.org/patch/10583133/
> "[V6, 2/4] clk: add new APIs to operation on all available
> clocks"
> https://patchwork.kernel.org/patch/10583131/
> "[V6, 3/4] clk: add managerged version of clk_bulk_get_all"
> https://patchwork.kernel.org/patch/10583139/
>
> Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
> ---
>   drivers/iommu/arm-smmu.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)

The clock part is already handled by one of the patch in the
runtime pm series of arm-smmu [1]. This patch should not be needed.

[1] https://patchwork.kernel.org/patch/10581899/

[...]

Regards
Vivek
Thor Thayer Oct. 4, 2018, 9 p.m. UTC | #2
Hi Vivek,

On 10/04/2018 01:49 PM, Vivek Gautam wrote:
> Hi Thor,
> 
> 
> On 10/4/2018 3:58 AM, thor.thayer@linux.intel.com wrote:
>> From: Thor Thayer <thor.thayer@linux.intel.com>
>>
>> Add a clock to the SMMU structure. In the device tree case,
>> check for a clock node and enable the clock if found.
>>
>> This patch is dependent upon the following patches that add
>> a device tree bulk clock function.
>> "[V6, 1/4] clk: bulk: add of_clk_bulk_get()"
>> https://patchwork.kernel.org/patch/10583133/
>> "[V6, 2/4] clk: add new APIs to operation on all available
>> clocks"
>> https://patchwork.kernel.org/patch/10583131/
>> "[V6, 3/4] clk: add managed version of clk_bulk_get_all"
>> https://patchwork.kernel.org/patch/10583139/
>>
>> Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
>> ---
>>   drivers/iommu/arm-smmu.c | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
> 
> The clock part is already handled by one of the patch in the
> runtime pm series of arm-smmu [1]. This patch should not be needed.
> 
> [1] https://patchwork.kernel.org/patch/10581899/
> 
> [...]
> 
> Regards
> Vivek
> 

Thanks. FYI, I had problems applying [v16,2/5] on [1] but was able to 
apply [v17,2/5] cleanly.

The bigger issue is that with your patchset I need to create a new 
structure for my variation of the ARM SMMUv2 due to the 
of_device_get_match_data() call in arm_smmu_device_dt_probe(). I want to 
use the default arm_mmu500 but it doesn't have a clock specified and I 
end up with num_clks of 0.

Creating a new smmu_match_data structure for each variant feels wrong 
because I have the clock data specified in my device tree. The 
of_clk_bulk_get() call handles this nicely but that patchset isn't 
getting much attention.

I'll investigate adding the of_clk_bulk_get() call on top of your 
patches. This may simplify your patches too since the additional 
structures in [v16,5/5] wouldn't be needed.

Thanks,

Thor

[1] git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git - next
diff mbox series

Patch

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 5a28ae892504..0f4596b42ca7 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -213,6 +213,8 @@  struct arm_smmu_device {
 
 	/* IOMMU core code handle */
 	struct iommu_device		iommu;
+	int				num_clks;
+	struct clk_bulk_data		*clks;
 };
 
 enum arm_smmu_context_fmt {
@@ -2038,6 +2040,17 @@  static int arm_smmu_device_dt_probe(struct platform_device *pdev,
 	const struct arm_smmu_match_data *data;
 	struct device *dev = &pdev->dev;
 	bool legacy_binding;
+	int ret;
+
+	/* If a clock is declared, enable it */
+	ret = devm_clk_bulk_get_all(smmu->dev, &smmu->clks);
+	if (IS_ERR(ret)) {
+		smmu->clks = NULL;
+		dev_dbg(dev, "cannot get smmu clock\n");
+	} else {
+		smmu->num_clks = ret;
+		clk_bulk_prepare_enable(smmu->num_clks, smmu->clks);
+	}
 
 	if (of_property_read_u32(dev->of_node, "#global-interrupts",
 				 &smmu->num_global_irqs)) {
@@ -2236,6 +2249,10 @@  static int arm_smmu_device_remove(struct platform_device *pdev)
 
 	/* Turn the thing off */
 	writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);
+
+	if (smmu->clks)
+		clk_bulk_disable_unprepare(smmu->num_clks, smmu->clks);
+
 	return 0;
 }
 
@@ -2248,6 +2265,9 @@  static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 {
 	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
 
+	if (smmu->clks)
+		clk_bulk_prepare_enable(smmu->num_clks, smmu->clks);
+
 	arm_smmu_device_reset(smmu);
 	return 0;
 }