mbox series

[0/1] drm/msm: request memory region

Message ID 20240405145049.9570-1-kiarash8112hajian@gmail.com
Headers show
Series drm/msm: request memory region | expand

Message

Kiarash Hajian April 5, 2024, 2:50 p.m. UTC
Kiarash Hajian (1):
  drm/msm: request memory region

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c |  5 +++++
 drivers/gpu/drm/msm/msm_io_utils.c    | 10 ++++++++++
 2 files changed, 15 insertions(+)


base-commit: c85af715cac0a951eea97393378e84bb49384734

Comments

Dmitry Baryshkov April 5, 2024, 3:25 p.m. UTC | #1
On Fri, 5 Apr 2024 at 17:51, Kiarash Hajian <kiarash8112hajian@gmail.com> 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 <kiarash8112hajian@gmail.com>
> ---
>  drivers/gpu/drm/msm/adreno/a6xx_gmu.c |  5 +++++
>  drivers/gpu/drm/msm/msm_io_utils.c    | 10 ++++++++++
>  2 files changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 8bea8ef26f77..17a5ef461406 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -1503,6 +1503,11 @@ static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev,
>                 return ERR_PTR(-EINVAL);
>         }
>
> +       if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), name)) {
> +               DRM_DEV_ERROR(&pdev->dev, "Unable to reserve the %s registers\n", name);
> +               return ERR_PTR(-EBUSY);
> +       }
> +
>         ret = ioremap(res->start, resource_size(res));

Change this to devm_ioremap_resource, please.

>         if (!ret) {
>                 DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", name);
> diff --git a/drivers/gpu/drm/msm/msm_io_utils.c b/drivers/gpu/drm/msm/msm_io_utils.c
> index afedd61c3e28..e236bdda348e 100644
> --- a/drivers/gpu/drm/msm/msm_io_utils.c
> +++ b/drivers/gpu/drm/msm/msm_io_utils.c
> @@ -59,6 +59,10 @@ void __iomem *msm_ioremap_mdss(struct platform_device *mdss_pdev,
>         res = platform_get_resource_byname(mdss_pdev, IORESOURCE_MEM, name);
>         if (!res)
>                 return ERR_PTR(-EINVAL);
> +
> +       if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), name)) {
> +               return ERR_PTR(-EBUSY);
> +       }
>
>         return devm_ioremap_resource(&pdev->dev, res);

NAK. Please take a look at the devm_ioremap_resource() soource code.

>  }
> @@ -83,6 +87,12 @@ static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *name
>
>         size = resource_size(res);
>
> +       if (!devm_request_mem_region(&pdev->dev, res->start, size, name)) {
> +               if (!quiet)
> +                       DRM_DEV_ERROR(&pdev->dev, "failed to reserve memory resource: %s\n", name);
> +               return ERR_PTR(-EBUSY);
> +       }
> +
>         ptr = devm_ioremap(&pdev->dev, res->start, size);

Please use devm_ioremap_resource() here.

>         if (!ptr) {
>                 if (!quiet)
> --
> 2.43.0
>