2024-05-11 19:36:11

by Kiarash Hajian

[permalink] [raw]
Subject: [PATCH] drm/msm/adreno: request memory region

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 <[email protected]>
---
drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 8bea8ef26f77..aa83cb461a75 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -636,9 +636,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)

err:
if (!IS_ERR_OR_NULL(pdcptr))
- iounmap(pdcptr);
+ devm_iounmap(&pdev->dev,pdcptr);
if (!IS_ERR_OR_NULL(seqptr))
- iounmap(seqptr);
+ devm_iounmap(&pdev->dev,seqptr);
}

/*
@@ -1503,7 +1503,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);
@@ -1646,7 +1646,7 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
dev_pm_domain_detach(gmu->cxpd, false);

err_mmio:
- iounmap(gmu->mmio);
+ devm_iounmap(gmu->dev ,gmu->mmio);

/* Drop reference taken in of_find_device_by_node */
put_device(gmu->dev);
@@ -1825,9 +1825,9 @@ 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);
+ devm_iounmap(gmu->dev ,gmu->mmio);
if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc"))
- iounmap(gmu->rscc);
+ devm_iounmap(gmu->dev ,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 <[email protected]>



2024-05-11 19:50:22

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/adreno: request memory region

On Sat, 11 May 2024 at 22:35, Kiarash Hajian
<[email protected]> wrote:
>
> 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 <[email protected]>
> ---
> drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 8bea8ef26f77..aa83cb461a75 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -636,9 +636,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
>
> err:
> if (!IS_ERR_OR_NULL(pdcptr))
> - iounmap(pdcptr);
> + devm_iounmap(&pdev->dev,pdcptr);
> if (!IS_ERR_OR_NULL(seqptr))
> - iounmap(seqptr);
> + devm_iounmap(&pdev->dev,seqptr);

Is there any reason to keep devm_iounmap calls? IMO with the devres
management in place, there should be no need to unmap them manually.

> }
>
> /*
> @@ -1503,7 +1503,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);
> @@ -1646,7 +1646,7 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
> dev_pm_domain_detach(gmu->cxpd, false);
>
> err_mmio:
> - iounmap(gmu->mmio);
> + devm_iounmap(gmu->dev ,gmu->mmio);
>
> /* Drop reference taken in of_find_device_by_node */
> put_device(gmu->dev);
> @@ -1825,9 +1825,9 @@ 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);
> + devm_iounmap(gmu->dev ,gmu->mmio);
> if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc"))
> - iounmap(gmu->rscc);
> + devm_iounmap(gmu->dev ,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 <[email protected]>
>


--
With best wishes
Dmitry