All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liviu Dudau <liviu.dudau@arm.com>
To: Karunika Choo <karunika.choo@arm.com>
Cc: dri-devel@lists.freedesktop.org, nd@arm.com,
	Boris Brezillon <boris.brezillon@collabora.com>,
	Steven Price <steven.price@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 v2 7/8] drm/panthor: Use a local iomem base for firmware control registers
Date: Wed, 15 Apr 2026 13:22:51 +0100	[thread overview]
Message-ID: <ad-DG-F1qcmPDtzy@e142607> (raw)
In-Reply-To: <20260412142951.2309135-8-karunika.choo@arm.com>

On Sun, Apr 12, 2026 at 03:29:50PM +0100, Karunika Choo wrote:
> Add an MCU_CONTROL-local iomem pointer to struct panthor_fw and use it
> for firmware control and status register accesses.
> 
> Job interrupt accesses continue to go through the IRQ-local base, while
> doorbell writes stay on the device-wide mapping because they live
> outside the MCU control window. This keeps firmware register accesses
> scoped to the component that owns them.
> 
> No functional change intended.
> 
> v2:
> - Pick up Ack from Boris.
> 
> Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
> Signed-off-by: Karunika Choo <karunika.choo@arm.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/panthor/panthor_fw.c      | 20 +++++++++++++-------
>  drivers/gpu/drm/panthor/panthor_fw_regs.h | 11 ++++-------
>  2 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c
> index 73ef07a37e22..986151681b24 100644
> --- a/drivers/gpu/drm/panthor/panthor_fw.c
> +++ b/drivers/gpu/drm/panthor/panthor_fw.c
> @@ -234,6 +234,9 @@ struct panthor_fw_iface {
>   * struct panthor_fw - Firmware management
>   */
>  struct panthor_fw {
> +	/** @iomem: CPU mapping of MCU_CONTROL iomem region */
> +	void __iomem *iomem;
> +
>  	/** @vm: MCU VM. */
>  	struct panthor_vm *vm;
>  
> @@ -1069,7 +1072,7 @@ static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 status)
>  	if (tracepoint_enabled(gpu_job_irq))
>  		start = ktime_get_ns();
>  
> -	gpu_write(ptdev->iomem, JOB_INT_CLEAR, status);
> +	gpu_write(ptdev->fw->irq.iomem, INT_CLEAR, status);
>  
>  	if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF))
>  		ptdev->fw->booted = true;
> @@ -1092,18 +1095,19 @@ PANTHOR_IRQ_HANDLER(job, panthor_job_irq_handler);
>  
>  static int panthor_fw_start(struct panthor_device *ptdev)
>  {
> +	struct panthor_fw *fw = ptdev->fw;
>  	bool timedout = false;
>  
>  	ptdev->fw->booted = false;
>  	panthor_job_irq_enable_events(&ptdev->fw->irq, ~0);
>  	panthor_job_irq_resume(&ptdev->fw->irq);
> -	gpu_write(ptdev->iomem, MCU_CONTROL, MCU_CONTROL_AUTO);
> +	gpu_write(fw->iomem, MCU_CONTROL, MCU_CONTROL_AUTO);
>  
>  	if (!wait_event_timeout(ptdev->fw->req_waitqueue,
>  				ptdev->fw->booted,
>  				msecs_to_jiffies(1000))) {
>  		if (!ptdev->fw->booted &&
> -		    !(gpu_read(ptdev->iomem, JOB_INT_STAT) & JOB_INT_GLOBAL_IF))
> +		    !(gpu_read(fw->irq.iomem, INT_STAT) & JOB_INT_GLOBAL_IF))
>  			timedout = true;
>  	}
>  
> @@ -1114,7 +1118,7 @@ static int panthor_fw_start(struct panthor_device *ptdev)
>  			[MCU_STATUS_HALT] = "halt",
>  			[MCU_STATUS_FATAL] = "fatal",
>  		};
> -		u32 status = gpu_read(ptdev->iomem, MCU_STATUS);
> +		u32 status = gpu_read(fw->iomem, MCU_STATUS);
>  
>  		drm_err(&ptdev->base, "Failed to boot MCU (status=%s)",
>  			status < ARRAY_SIZE(status_str) ? status_str[status] : "unknown");
> @@ -1126,10 +1130,11 @@ static int panthor_fw_start(struct panthor_device *ptdev)
>  
>  static void panthor_fw_stop(struct panthor_device *ptdev)
>  {
> +	struct panthor_fw *fw = ptdev->fw;
>  	u32 status;
>  
> -	gpu_write(ptdev->iomem, MCU_CONTROL, MCU_CONTROL_DISABLE);
> -	if (gpu_read_poll_timeout(ptdev->iomem, MCU_STATUS, status,
> +	gpu_write(fw->iomem, MCU_CONTROL, MCU_CONTROL_DISABLE);
> +	if (gpu_read_poll_timeout(fw->iomem, MCU_STATUS, status,
>  				  status == MCU_STATUS_DISABLED, 10, 100000))
>  		drm_err(&ptdev->base, "Failed to stop MCU");
>  }
> @@ -1139,7 +1144,7 @@ static bool panthor_fw_mcu_halted(struct panthor_device *ptdev)
>  	struct panthor_fw_global_iface *glb_iface = panthor_fw_get_glb_iface(ptdev);
>  	bool halted;
>  
> -	halted = gpu_read(ptdev->iomem, MCU_STATUS) == MCU_STATUS_HALT;
> +	halted = gpu_read(ptdev->fw->iomem, MCU_STATUS) == MCU_STATUS_HALT;
>  
>  	if (panthor_fw_has_glb_state(ptdev))
>  		halted &= (GLB_STATE_GET(glb_iface->output->ack) == GLB_STATE_HALT);
> @@ -1461,6 +1466,7 @@ int panthor_fw_init(struct panthor_device *ptdev)
>  	if (!fw)
>  		return -ENOMEM;
>  
> +	fw->iomem = ptdev->iomem + MCU_CONTROL_BASE;
>  	ptdev->fw = fw;
>  	init_waitqueue_head(&fw->req_waitqueue);
>  	INIT_LIST_HEAD(&fw->sections);
> diff --git a/drivers/gpu/drm/panthor/panthor_fw_regs.h b/drivers/gpu/drm/panthor/panthor_fw_regs.h
> index eeb41aff249b..b2e59cfc22b0 100644
> --- a/drivers/gpu/drm/panthor/panthor_fw_regs.h
> +++ b/drivers/gpu/drm/panthor/panthor_fw_regs.h
> @@ -4,23 +4,20 @@
>  #ifndef __PANTHOR_FW_REGS_H__
>  #define __PANTHOR_FW_REGS_H__
>  
> -#define MCU_CONTROL					0x700
> +#define MCU_CONTROL_BASE				0x700
> +
> +#define MCU_CONTROL					0x0
>  #define   MCU_CONTROL_ENABLE				1
>  #define   MCU_CONTROL_AUTO				2
>  #define   MCU_CONTROL_DISABLE				0
>  
> -#define MCU_STATUS					0x704
> +#define MCU_STATUS					0x4
>  #define   MCU_STATUS_DISABLED				0
>  #define   MCU_STATUS_ENABLED				1
>  #define   MCU_STATUS_HALT				2
>  #define   MCU_STATUS_FATAL				3
>  
>  #define JOB_INT_BASE					0x1000
> -
> -#define JOB_INT_RAWSTAT					0x1000
> -#define JOB_INT_CLEAR					0x1004
> -#define JOB_INT_MASK					0x1008
> -#define JOB_INT_STAT					0x100c
>  #define   JOB_INT_GLOBAL_IF				BIT(31)
>  #define   JOB_INT_CSG_IF(x)				BIT(x)
>  
> -- 
> 2.43.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

  reply	other threads:[~2026-04-15 12:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-12 14:29 [PATCH v2 0/8] drm/panthor: Localize register access by component Karunika Choo
2026-04-12 14:29 ` [PATCH v2 1/8] drm/panthor: Pass an iomem pointer to GPU register access helpers Karunika Choo
2026-04-15 11:46   ` Liviu Dudau
2026-04-12 14:29 ` [PATCH v2 2/8] drm/panthor: Split register definitions by components Karunika Choo
2026-04-13  7:43   ` Boris Brezillon
2026-04-15 11:47   ` Liviu Dudau
2026-04-12 14:29 ` [PATCH v2 3/8] drm/panthor: Replace cross-component register accesses with helpers Karunika Choo
2026-04-13  7:44   ` Boris Brezillon
2026-04-15 11:48   ` Liviu Dudau
2026-04-12 14:29 ` [PATCH v2 4/8] drm/panthor: Store IRQ register base iomem pointer in panthor_irq Karunika Choo
2026-04-13  7:46   ` Boris Brezillon
2026-04-15 12:16   ` Liviu Dudau
2026-04-22  9:34   ` Steven Price
2026-04-22 16:08     ` Karunika Choo
2026-04-24 10:38       ` Steven Price
2026-04-24 11:03         ` Boris Brezillon
2026-04-24 11:20           ` Steven Price
2026-04-24 12:09             ` Boris Brezillon
2026-04-27 16:08               ` Karunika Choo
2026-04-12 14:29 ` [PATCH v2 5/8] drm/panthor: Use a local iomem base for GPU registers Karunika Choo
2026-04-15 12:19   ` Liviu Dudau
2026-04-12 14:29 ` [PATCH v2 6/8] drm/panthor: Use a local iomem base for PWR registers Karunika Choo
2026-04-13  7:51   ` Boris Brezillon
2026-04-15 12:21   ` Liviu Dudau
2026-04-12 14:29 ` [PATCH v2 7/8] drm/panthor: Use a local iomem base for firmware control registers Karunika Choo
2026-04-15 12:22   ` Liviu Dudau [this message]
2026-04-12 14:29 ` [PATCH v2 8/8] drm/panthor: Use a local iomem base for MMU AS registers Karunika Choo
2026-04-15 12:23   ` Liviu Dudau
2026-04-22  9:34 ` [PATCH v2 0/8] drm/panthor: Localize register access by component Steven Price

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=ad-DG-F1qcmPDtzy@e142607 \
    --to=liviu.dudau@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=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nd@arm.com \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.