[PATCH] iommu/sprd: disable clock on remove

From: Guangshuo Li

Date: Mon Sep 14 2026 - 09:56:18 EST


sprd_iommu_probe() enables the optional IOMMU gate clock through
sprd_iommu_clk_enable(), which obtains the clock with
devm_clk_get_optional() and explicitly calls clk_prepare_enable().

The probe error path correctly balances this operation with
sprd_iommu_clk_disable(), but the normal remove path does not disable
the clock. devm_clk_get_optional() only manages the clock reference and
does not balance the explicit clk_prepare_enable() performed by the
driver.

As a result, successfully probing and subsequently removing the driver
leaves the clock prepare and enable counts unbalanced.

Disable the clock after unregistering the IOMMU device, once teardown
that may require access to the IOMMU registers has completed.

This issue was found by manual code inspection.

Fixes: b23e4fc4e3fa ("iommu: add Unisoc IOMMU basic driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
---
drivers/iommu/sprd-iommu.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c
index c1a34445d244..65a970ad4c9f 100644
--- a/drivers/iommu/sprd-iommu.c
+++ b/drivers/iommu/sprd-iommu.c
@@ -524,6 +524,7 @@ static void sprd_iommu_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
iommu_device_sysfs_remove(&sdev->iommu);
iommu_device_unregister(&sdev->iommu);
+ sprd_iommu_clk_disable(sdev);
}

static struct platform_driver sprd_iommu_driver = {
--
2.43.0