mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: Karunika Choo <karunika.choo@arm.com>, dri-devel@lists.freedesktop.org
Cc: nd@arm.com, Boris Brezillon <boris.brezillon@collabora.com>,
	Liviu Dudau <liviu.dudau@arm.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-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/8] drm/panthor: Implement soft reset via PWR_CONTROL
Date: Fri, 7 Nov 2025 10:26:47 +0000	[thread overview]
Message-ID: <4d23e26a-17db-42f8-bbf2-78acbe6925b8@arm.com> (raw)
In-Reply-To: <20251027161334.854650-6-karunika.choo@arm.com>

On 27/10/2025 16:13, Karunika Choo wrote:
> Add helpers to issue reset commands through the PWR_CONTROL interface
> and wait for reset completion using IRQ signaling. This enables support
> for RESET_SOFT operations with timeout handling and status verification.
> 
> Signed-off-by: Karunika Choo <karunika.choo@arm.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
> v2:
>  * Dropped RESET_FAST implementation as it is not currently being used.
>  * Renamed reset_completed to reset_pending to align with underlying
>    logic and fixed the logic of its callers accordingly.
>  * Improved readability of panthor_pwr_reset() and removed inline
>    ternary expressions.
> ---
>  drivers/gpu/drm/panthor/panthor_pwr.c | 50 +++++++++++++++++++++++++++
>  drivers/gpu/drm/panthor/panthor_pwr.h |  2 ++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_pwr.c b/drivers/gpu/drm/panthor/panthor_pwr.c
> index cd529660a276..4edb818c7ac4 100644
> --- a/drivers/gpu/drm/panthor/panthor_pwr.c
> +++ b/drivers/gpu/drm/panthor/panthor_pwr.c
> @@ -3,6 +3,7 @@
> 
>  #include <linux/platform_device.h>
>  #include <linux/interrupt.h>
> +#include <linux/cleanup.h>
>  #include <linux/iopoll.h>
>  #include <linux/wait.h>
> 
> @@ -31,6 +32,8 @@
> 
>  #define PWR_RETRACT_TIMEOUT_US		(2ULL * USEC_PER_MSEC)
> 
> +#define PWR_RESET_TIMEOUT_MS		500
> +
>  /**
>   * struct panthor_pwr - PWR_CONTROL block management data.
>   */
> @@ -75,6 +78,43 @@ static void panthor_pwr_write_command(struct panthor_device *ptdev, u32 command,
>  	gpu_write(ptdev, PWR_COMMAND, command);
>  }
> 
> +static bool reset_irq_raised(struct panthor_device *ptdev)
> +{
> +	return gpu_read(ptdev, PWR_INT_RAWSTAT) & PWR_IRQ_RESET_COMPLETED;
> +}
> +
> +static bool reset_pending(struct panthor_device *ptdev)
> +{
> +	return (ptdev->pwr->pending_reqs & PWR_IRQ_RESET_COMPLETED);
> +}
> +
> +static int panthor_pwr_reset(struct panthor_device *ptdev, u32 reset_cmd)
> +{
> +	scoped_guard(spinlock_irqsave, &ptdev->pwr->reqs_lock) {
> +		if (reset_pending(ptdev)) {
> +			drm_WARN(&ptdev->base, 1, "Reset already pending");
> +		} else {
> +			ptdev->pwr->pending_reqs |= PWR_IRQ_RESET_COMPLETED;
> +			gpu_write(ptdev, PWR_INT_CLEAR, PWR_IRQ_RESET_COMPLETED);
> +			panthor_pwr_write_command(ptdev, reset_cmd, 0);
> +		}
> +	}
> +
> +	if (!wait_event_timeout(ptdev->pwr->reqs_acked, !reset_pending(ptdev),
> +				msecs_to_jiffies(PWR_RESET_TIMEOUT_MS))) {
> +		guard(spinlock_irqsave)(&ptdev->pwr->reqs_lock);
> +
> +		if (reset_pending(ptdev) && !reset_irq_raised(ptdev)) {
> +			drm_err(&ptdev->base, "RESET timed out (0x%x)", reset_cmd);
> +			return -ETIMEDOUT;
> +		}
> +
> +		ptdev->pwr->pending_reqs &= ~PWR_IRQ_RESET_COMPLETED;
> +	}
> +
> +	return 0;
> +}
> +
>  static const char *get_domain_name(u8 domain)
>  {
>  	switch (domain) {
> @@ -428,6 +468,16 @@ int panthor_pwr_init(struct panthor_device *ptdev)
>  	return 0;
>  }
> 
> +int panthor_pwr_reset_soft(struct panthor_device *ptdev)
> +{
> +	if (!(gpu_read64(ptdev, PWR_STATUS) & PWR_STATUS_ALLOW_SOFT_RESET)) {
> +		drm_err(&ptdev->base, "RESET_SOFT not allowed");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	return panthor_pwr_reset(ptdev, PWR_COMMAND_RESET_SOFT);
> +}
> +
>  void panthor_pwr_l2_power_off(struct panthor_device *ptdev)
>  {
>  	const u64 l2_allow_mask = PWR_STATUS_DOMAIN_ALLOWED(PWR_COMMAND_DOMAIN_L2);
> diff --git a/drivers/gpu/drm/panthor/panthor_pwr.h b/drivers/gpu/drm/panthor/panthor_pwr.h
> index 3c834059a860..adf1f6136abc 100644
> --- a/drivers/gpu/drm/panthor/panthor_pwr.h
> +++ b/drivers/gpu/drm/panthor/panthor_pwr.h
> @@ -10,6 +10,8 @@ void panthor_pwr_unplug(struct panthor_device *ptdev);
> 
>  int panthor_pwr_init(struct panthor_device *ptdev);
> 
> +int panthor_pwr_reset_soft(struct panthor_device *ptdev);
> +
>  void panthor_pwr_l2_power_off(struct panthor_device *ptdev);
> 
>  int panthor_pwr_l2_power_on(struct panthor_device *ptdev);
> --
> 2.49.0
> 


  reply	other threads:[~2025-11-07 10:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27 16:13 [PATCH v3 0/8] drm/panthor: Add support for Mali-G1 GPUs Karunika Choo
2025-10-27 16:13 ` [PATCH v3 1/8] drm/panthor: Add arch-specific panthor_hw binding Karunika Choo
2025-10-28 16:16   ` Liviu Dudau
2025-11-07  9:24     ` Steven Price
2025-10-27 16:13 ` [PATCH v3 2/8] drm/panthor: Add architecture-specific function operations Karunika Choo
2025-11-07  9:48   ` Steven Price
2025-10-27 16:13 ` [PATCH v3 3/8] drm/panthor: Introduce panthor_pwr API and power control framework Karunika Choo
2025-11-07 10:07   ` Steven Price
2025-10-27 16:13 ` [PATCH v3 4/8] drm/panthor: Implement L2 power on/off via PWR_CONTROL Karunika Choo
2025-11-07 10:18   ` Steven Price
2025-10-27 16:13 ` [PATCH v3 5/8] drm/panthor: Implement soft reset " Karunika Choo
2025-11-07 10:26   ` Steven Price [this message]
2025-10-27 16:13 ` [PATCH v3 6/8] drm/panthor: Support GLB_REQ.STATE field for Mali-G1 GPUs Karunika Choo
2025-11-07 10:50   ` Steven Price
2025-10-27 16:13 ` [PATCH v3 7/8] drm/panthor: Support 64-bit endpoint_req register for Mali-G1 Karunika Choo
2025-11-07 10:59   ` Steven Price
2025-10-27 16:13 ` [PATCH v3 8/8] drm/panthor: Add support for Mali-G1 GPUs Karunika Choo
2025-11-07 11:00   ` Steven Price
2025-11-07 11:05 ` [PATCH v3 0/8] " Boris Brezillon

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=4d23e26a-17db-42f8-bbf2-78acbe6925b8@arm.com \
    --to=steven.price@arm.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karunika.choo@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nd@arm.com \
    --cc=simona@ffwll.ch \
    --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

all inboxes | Powered by JetHome®