[PATCH 04/10] drm/msm/gpu: Convert the GPU show function to use the GPU state

Chris Wilson chris at chris-wilson.co.uk
Fri Apr 6 10:53:01 UTC 2018


Quoting Jordan Crouse (2018-04-05 23:00:50)
> diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c
> index ba74cb4f94df..fd535dab3d5b 100644
> --- a/drivers/gpu/drm/msm/msm_debugfs.c
> +++ b/drivers/gpu/drm/msm/msm_debugfs.c
> @@ -25,13 +25,22 @@ static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)
>  {
>         struct msm_drm_private *priv = dev->dev_private;
>         struct msm_gpu *gpu = priv->gpu;
> +       struct msm_gpu_state *state;
>  
> -       if (gpu) {
> -               seq_printf(m, "%s Status:\n", gpu->name);
> -               pm_runtime_get_sync(&gpu->pdev->dev);
> -               gpu->funcs->show(gpu, m);
> -               pm_runtime_put_sync(&gpu->pdev->dev);
> -       }
> +       if (!gpu)
> +               return 0;
> +
> +       pm_runtime_get_sync(&gpu->pdev->dev);
> +       state = gpu->funcs->gpu_state_get(gpu);
> +       pm_runtime_put_sync(&gpu->pdev->dev);
> +
> +       if (IS_ERR(state))
> +               return PTR_ERR(state);
> +
> +       seq_printf(m, "%s Status:\n", gpu->name);
> +       gpu->funcs->show(gpu, state, m);
> +
> +       gpu->funcs->gpu_state_put(state);

Ah. This be trickier than it appears thanks to how seq_file tries to
keep the interface simple :)

For a large buffer, seq_file will call the show multiple times to
convert it into a single string, which it then iterates over. (iirc)

Ideally, you grab the error state on open, and then use the
drm_printer_iterator you have to feed the chunks to seqfs. At a minimum,
I do recommend you stick the get into the seq_open callback, as my
memory says the show will be called multiple times.
-Chris


More information about the dri-devel mailing list