The driver's memory regions are currently just ioremap()ed, but not
reserved through a request. That's not a bug, but having the request is
a little more robust.

Implement the region-request through the corresponding managed
devres-function.

Signed-off-by: Kiarash Hajian <kiarash8112haj...@gmail.com>
---
Changes in v4:
- Combine v3 commits into a singel commit
- Link to v3: 
https://lore.kernel.org/r/20240512-msm-adreno-memory-region-v3-0-0a728ad45...@gmail.com

Changes in v3:
- Remove redundant devm_iounmap calls, relying on devres for automatic resource 
cleanup.

Changes in v2:
- update the subject prefix to "drm/msm/a6xx:", to match the majority of other 
changes to this file.
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 8bea8ef26f77..cf0b3b3d8f34 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -524,9 +524,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
        uint32_t pdc_address_offset;
        bool pdc_in_aop = false;
 
-       if (IS_ERR(pdcptr))
-               goto err;
-
        if (adreno_is_a650(adreno_gpu) ||
            adreno_is_a660_family(adreno_gpu) ||
            adreno_is_a7xx(adreno_gpu))
@@ -540,8 +537,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 
        if (!pdc_in_aop) {
                seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
-               if (IS_ERR(seqptr))
-                       goto err;
        }
 
        /* Disable SDE clock gating */
@@ -633,12 +628,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
        wmb();
 
        a6xx_rpmh_stop(gmu);
-
-err:
-       if (!IS_ERR_OR_NULL(pdcptr))
-               iounmap(pdcptr);
-       if (!IS_ERR_OR_NULL(seqptr))
-               iounmap(seqptr);
 }
 
 /*
@@ -1503,7 +1492,7 @@ static void __iomem *a6xx_gmu_get_mmio(struct 
platform_device *pdev,
                return ERR_PTR(-EINVAL);
        }
 
-       ret = ioremap(res->start, resource_size(res));
+       ret = devm_ioremap_resource(&pdev->dev, res);
        if (!ret) {
                DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", 
name);
                return ERR_PTR(-EINVAL);
@@ -1613,13 +1602,11 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, 
struct device_node *node)
        gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu");
        if (IS_ERR(gmu->mmio)) {
                ret = PTR_ERR(gmu->mmio);
-               goto err_mmio;
        }
 
        gmu->cxpd = dev_pm_domain_attach_by_name(gmu->dev, "cx");
        if (IS_ERR(gmu->cxpd)) {
                ret = PTR_ERR(gmu->cxpd);
-               goto err_mmio;
        }
 
        if (!device_link_add(gmu->dev, gmu->cxpd, DL_FLAG_PM_RUNTIME)) {
@@ -1635,7 +1622,6 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, 
struct device_node *node)
        gmu->gxpd = dev_pm_domain_attach_by_name(gmu->dev, "gx");
        if (IS_ERR(gmu->gxpd)) {
                ret = PTR_ERR(gmu->gxpd);
-               goto err_mmio;
        }
 
        gmu->initialized = true;
@@ -1645,9 +1631,6 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, 
struct device_node *node)
 detach_cxpd:
        dev_pm_domain_detach(gmu->cxpd, false);
 
-err_mmio:
-       iounmap(gmu->mmio);
-
        /* Drop reference taken in of_find_device_by_node */
        put_device(gmu->dev);
 
@@ -1825,9 +1808,6 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct 
device_node *node)
        dev_pm_domain_detach(gmu->cxpd, false);
 
 err_mmio:
-       iounmap(gmu->mmio);
-       if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc"))
-               iounmap(gmu->rscc);
        free_irq(gmu->gmu_irq, gmu);
        free_irq(gmu->hfi_irq, gmu);
 

---
base-commit: cf87f46fd34d6c19283d9625a7822f20d90b64a4
change-id: 20240511-msm-adreno-memory-region-2bcb1c958621

Best regards,
-- 
Kiarash Hajian <kiarash8112haj...@gmail.com>

Reply via email to