public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Chia-I Wu <olvaffe@gmail.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Christian König <christian.koenig@amd.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] drm/panthor: Add a new guard for our custom resume_and_get() PM helper
Date: Thu, 14 May 2026 11:39:54 -0700	[thread overview]
Message-ID: <CAPaKu7Sttfu4xapUwnk6WzskHVEqNuc8NOfpZch-Yp-OGd6bww@mail.gmail.com> (raw)
In-Reply-To: <20260513-panthor-guard-refactor-v1-6-f2d8c15a97ce@collabora.com>

On Wed, May 13, 2026 at 9:59 AM Boris Brezillon
<boris.brezillon@collabora.com> wrote:
>
> Overload the already existing pm_runtime_active_auto_try_enabled guard
> with our custom guard that force the state to suspened (and thus clear
> the runtime_error) in case the resume fails.
>
> Once done, we can replace the existing places where manual
> panthor_device_resume_and_get()+pm_runtime_put_autosuspend() were
> done by guards.
This patch also replaces a pm_runtime_put call by
pm_runtime_put_autosuspend, and removes redundant
pm_runtime_mark_last_busy calls. Can we add another patch for the
functionality change first?

>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
>  drivers/gpu/drm/panthor/panthor_device.h | 10 +++++++---
>  drivers/gpu/drm/panthor/panthor_drv.c    |  4 ++--
>  drivers/gpu/drm/panthor/panthor_sched.c  | 11 ++++-------
>  3 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h
> index 1aaf06df875b..51527d2e2f77 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.h
> +++ b/drivers/gpu/drm/panthor/panthor_device.h
> @@ -407,9 +407,10 @@ int panthor_device_mmap_io(struct panthor_device *ptdev,
>  int panthor_device_resume(struct device *dev);
>  int panthor_device_suspend(struct device *dev);
>
> -static inline int panthor_device_resume_and_get(struct panthor_device *ptdev)
> +static inline int panthor_device_resume_and_get(struct device *dev)
>  {
> -       int ret = pm_runtime_resume_and_get(ptdev->base.dev);
> +       struct panthor_device *ptdev = dev_get_drvdata(dev);
> +       int ret = pm_runtime_resume_and_get(dev);
>
>         /* If the resume failed, we need to clear the runtime_error, which
>          * can done by forcing the RPM state to suspended. If multiple
> @@ -424,11 +425,14 @@ static inline int panthor_device_resume_and_get(struct panthor_device *ptdev)
>          * something we can live with.
>          */
>         if (ret && atomic_cmpxchg(&ptdev->pm.recovery_needed, 1, 0) == 1)
> -               pm_runtime_set_suspended(ptdev->base.dev);
> +               pm_runtime_set_suspended(dev);
>
>         return ret;
>  }
>
> +DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled_or_suspend,
> +                 panthor_device_resume_and_get(_T), _RET == 0)
> +
>  enum drm_panthor_exception_type {
>         DRM_PANTHOR_EXCEPTION_OK = 0x00,
>         DRM_PANTHOR_EXCEPTION_TERMINATED = 0x04,
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index 789ddc0ff7ef..f2d60ff00896 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -824,7 +824,8 @@ static int panthor_query_timestamp_info(struct panthor_device *ptdev,
>                 (flags & DRM_PANTHOR_TIMESTAMP_DURATION) ||
>                 (timestamp_types >= 2);
>
> -       ret = panthor_device_resume_and_get(ptdev);
> +       ACQUIRE(pm_runtime_active_auto_try_enabled_or_suspend, pm_guard)(ptdev->base.dev);
> +       ret = ACQUIRE_ERR(pm_runtime_active_auto_try_enabled_or_suspend, &pm_guard);
>         if (ret)
>                 return ret;
>
> @@ -894,7 +895,6 @@ static int panthor_query_timestamp_info(struct panthor_device *ptdev,
>                 arg->cpu_timestamp_nsec = 0;
>         }
>
> -       pm_runtime_put(ptdev->base.dev);
>         return 0;
>  }
>
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index 9aa9941d2309..9afa38e87fc9 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -2630,13 +2630,12 @@ static void tick_work(struct work_struct *work)
>         if (ACQUIRE_ERR(drm_dev_access, &dev_guard))
>                 return;
>
> -       ret = panthor_device_resume_and_get(ptdev);
> +       ACQUIRE(pm_runtime_active_auto_try_enabled_or_suspend, pm_guard)(ptdev->base.dev);
> +       ret = ACQUIRE_ERR(pm_runtime_active_auto_try_enabled_or_suspend, &pm_guard);
>         if (drm_WARN_ON(&ptdev->base, ret))
>                 return;
>
>         tick(sched);
> -       pm_runtime_mark_last_busy(ptdev->base.dev);
> -       pm_runtime_put_autosuspend(ptdev->base.dev);
>  }
>
>  static int panthor_queue_eval_syncwait(struct panthor_group *group, u8 queue_idx)
> @@ -3359,7 +3358,8 @@ queue_run_job(struct drm_sched_job *sched_job)
>                 return dma_fence_get(job->done_fence);
>         }
>
> -       ret = panthor_device_resume_and_get(ptdev);
> +       ACQUIRE(pm_runtime_active_auto_try_enabled_or_suspend, pm_guard)(ptdev->base.dev);
> +       ret = ACQUIRE_ERR(pm_runtime_active_auto_try_enabled_or_suspend, &pm_guard);
>         if (drm_WARN_ON(&ptdev->base, ret))
>                 return ERR_PTR(ret);
>
> @@ -3367,9 +3367,6 @@ queue_run_job(struct drm_sched_job *sched_job)
>                 done_fence = queue_run_job_locked(job);
>         }
>
> -       pm_runtime_mark_last_busy(ptdev->base.dev);
> -       pm_runtime_put_autosuspend(ptdev->base.dev);
> -
>         return done_fence;
>  }
>
>
> --
> 2.54.0
>

  reply	other threads:[~2026-05-14 18:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 16:58 [PATCH 0/6] drm/panthor: Use guards Boris Brezillon
2026-05-13 16:58 ` [PATCH 1/6] drm/panthor: Driver-wide xxx_[un]lock -> [scoped_]guard replacement Boris Brezillon
2026-05-14 13:16   ` Steven Price
2026-05-14 17:09     ` Chia-I Wu
2026-05-16  1:40   ` Claude review: " Claude Code Review Bot
2026-05-13 16:58 ` [PATCH 2/6] dma-resv: Define guards for context-less dma_resv locks Boris Brezillon
2026-05-14 18:23   ` Chia-I Wu
2026-05-16  1:40   ` Claude review: " Claude Code Review Bot
2026-05-13 16:58 ` [PATCH 3/6] drm: Define a conditional guard for drm_dev_{enter,exit}() Boris Brezillon
2026-05-14 18:34   ` [PATCH 3/6] drm: Define a conditional guard for drm_dev_{enter, exit}() Chia-I Wu
2026-05-16  1:40   ` Claude review: drm: Define a conditional guard for drm_dev_{enter,exit}() Claude Code Review Bot
2026-05-13 16:58 ` [PATCH 4/6] drm/panthor: Use guards for resv locking Boris Brezillon
2026-05-14 18:35   ` Chia-I Wu
2026-05-16  1:40   ` Claude review: " Claude Code Review Bot
2026-05-13 16:58 ` [PATCH 5/6] drm/panthor: Use the drm_dev_access guard Boris Brezillon
2026-05-14 18:36   ` Chia-I Wu
2026-05-16  1:40   ` Claude review: " Claude Code Review Bot
2026-05-13 16:58 ` [PATCH 6/6] drm/panthor: Add a new guard for our custom resume_and_get() PM helper Boris Brezillon
2026-05-14 18:39   ` Chia-I Wu [this message]
2026-05-16  1:40   ` Claude review: " Claude Code Review Bot
2026-05-16  1:40 ` Claude review: drm/panthor: Use guards Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPaKu7Sttfu4xapUwnk6WzskHVEqNuc8NOfpZch-Yp-OGd6bww@mail.gmail.com \
    --to=olvaffe@gmail.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox