mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Akhil P Oommen <akhilpo@oss.qualcomm.com>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
	dri-devel@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	Anna Maniscalco <anna.maniscalco2000@gmail.com>,
	Sean Paul <sean@poorly.run>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Jessica Zhang <jesszhan0024@gmail.com>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v7 15/16] drm/msm/a6xx: Append SEL regs to dyn pwrup reglist
Date: Wed, 20 May 2026 14:09:52 +0530	[thread overview]
Message-ID: <83ff0d14-1cad-4ca5-a512-05773c36cd8d@oss.qualcomm.com> (raw)
In-Reply-To: <20260518190735.16236-16-robin.clark@oss.qualcomm.com>

On 5/19/2026 12:36 AM, Rob Clark wrote:
> This is needed so that SEL reg values are restored on exit from IFPC.
> 
> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
> Reviewed-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>
> ---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 82 +++++++++++++++++++++++++--
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 11 +++-
>  drivers/gpu/drm/msm/adreno/a8xx_gpu.c |  1 +
>  3 files changed, 87 insertions(+), 7 deletions(-)
> 

<< snip >>

>  static void
>  a6xx_perfcntr_configure(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
>  			const struct msm_perfcntr_stream *stream)
>  {
> +	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> +	struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
>  	enum adreno_pipe pipe = PIPE_NONE;
> +	uint32_t *reglist = NULL;
> +	uint32_t *reglist_sel_start;
> +
> +	if (to_adreno_gpu(gpu)->info->family >= ADRENO_7XX_GEN1) {
> +		WARN_ON(!a6xx_gpu->pwrup_reglist_emitted);
> +
> +		struct cpu_gpu_lock *lock = a6xx_gpu->pwrup_reglist_ptr;
> +		int off = (2 * lock->ifpc_list_len) +
> +			  (2 * lock->preemption_list_len) +
> +			  (3 * a6xx_gpu->dynamic_sel_reglist_offset);
> +
> +		reglist = (uint32_t *)&lock->regs[0];
> +		reglist += off;
> +		reglist_sel_start = reglist;
> +
> +		/* Clear any previously configured SEL reg entries: */
> +		lock->dynamic_list_len = a6xx_gpu->dynamic_sel_reglist_offset;
> +
> +		/*
> +		 * Ensure CP sees the dynamic_list_len update before we
> +		 * start modifying the SEL entries:
> +		 */
> +		wmb();

dma_wmb() is a lighter barrier and provides the same ordering for memory
writes visible to devices.

> +	}
>  
>  	for (unsigned i = 0; i < stream->nr_groups; i++) {
>  		unsigned group_idx = msm_perfcntr_group_idx(stream, i);
> @@ -2567,17 +2617,15 @@ a6xx_perfcntr_configure(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
>  
>  		const struct msm_perfcntr_counter *counter = &group->counters[base];
>  		unsigned nr = group_state->allocated_counters;
> -		OUT_PKT4(ring, counter->select_reg, nr);
> -		for (unsigned c = 0; c < nr; c++)
> -			OUT_RING(ring, group_state->countables[c]);
> +		perfcntr_select(ring, pipe, counter->select_reg,
> +				group_state->countables, nr, &reglist);
>  
>  		for (unsigned s = 0; s < ARRAY_SIZE(counter->slice_select_regs); s++) {
>  			if (!counter->slice_select_regs[s])
>  				break;
>  
> -			OUT_PKT4(ring, counter->slice_select_regs[s], nr);
> -			for (unsigned c = 0; c < nr; c++)
> -				OUT_RING(ring, group_state->countables[c]);
> +			perfcntr_select(ring, pipe, counter->slice_select_regs[s],
> +					group_state->countables, nr, &reglist);
>  		}
>  	}
>  
> @@ -2591,6 +2639,28 @@ a6xx_perfcntr_configure(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
>  	OUT_RING(ring, upper_32_bits(rbmemptr(ring, perfcntr_fence)));
>  	OUT_RING(ring, stream->sel_fence);
>  
> +	/*
> +	 * Update the pwrup reglist size before flushing.  Kgsl does a shared-
> +	 * memory spinlock dance with SQE to avoid racing with IFPC exit.  But
> +	 * we can skip that since the ringbuffer programming will be executed
> +	 * by SQE after dynamic reglist size is updated.  So even if we lose
> +	 * the race, the register programming in the rb will overwrite/correct
> +	 * the SEL regs restored by SQE on IFPC exit, before sampling begins.
> +	 */
> +	if (reglist) {
> +		struct cpu_gpu_lock *lock = a6xx_gpu->pwrup_reglist_ptr;
> +		unsigned nr_regs = (reglist - reglist_sel_start) / 3;
> +
> +		/*
> +		 * Ensure CP sees updates to the pwrup_reglist before it
> +		 * sees the new (increased) length:
> +		 */
> +		wmb();

Same as above.

-Akhil



  reply	other threads:[~2026-05-20  8:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 19:06 [PATCH v7 00/16] drm/msm: Add PERFCNTR_CONFIG ioctl Rob Clark
2026-05-18 19:06 ` [PATCH v7 01/16] drm/msm: Remove obsolete perf infrastructure Rob Clark
2026-05-18 19:06 ` [PATCH v7 02/16] drm/msm: Allow CAP_PERFMON for setting SYSPROF Rob Clark
2026-05-18 19:06 ` [PATCH v7 03/16] drm/msm/adreno: Sync registers from mesa Rob Clark
2026-05-18 19:06 ` [PATCH v7 04/16] drm/msm/registers: Sync gen_header.py " Rob Clark
2026-05-18 19:06 ` [PATCH v7 05/16] drm/msm/registers: Add perfcntr json Rob Clark
2026-05-20  8:36   ` Akhil P Oommen
2026-05-20 12:30     ` Rob Clark
2026-05-20 13:47       ` Rob Clark
2026-05-18 19:06 ` [PATCH v7 06/16] drm/msm: Add a6xx+ perfcntr tables Rob Clark
2026-05-18 19:06 ` [PATCH v7 07/16] drm/msm: Add sysprof accessors Rob Clark
2026-05-18 19:06 ` [PATCH v7 08/16] drm/msm/a6xx: Add yield & flush helper Rob Clark
2026-05-18 19:06 ` [PATCH v7 09/16] drm/msm: Add per-context perfcntr state Rob Clark
2026-05-18 19:06 ` [PATCH v7 10/16] drm/msm: Add basic perfcntr infrastructure Rob Clark
2026-05-18 19:06 ` [PATCH v7 11/16] drm/msm/a6xx+: Add support to configure perfcntrs Rob Clark
2026-05-18 19:06 ` [PATCH v7 12/16] drm/msm/a8xx: Add perfcntr flush sequence Rob Clark
2026-05-18 19:06 ` [PATCH v7 13/16] drm/msm: Add PERFCNTR_CONFIG ioctl Rob Clark
2026-05-18 19:06 ` [PATCH v7 14/16] drm/msm/a6xx: Increase pwrup_reglist size Rob Clark
2026-05-18 19:06 ` [PATCH v7 15/16] drm/msm/a6xx: Append SEL regs to dyn pwrup reglist Rob Clark
2026-05-20  8:39   ` Akhil P Oommen [this message]
2026-05-18 19:06 ` [PATCH v7 16/16] drm/msm/a6xx: Allow IFPC with perfcntr stream Rob Clark
2026-05-20  8:44 ` [PATCH v7 00/16] drm/msm: Add PERFCNTR_CONFIG ioctl Akhil P Oommen

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=83ff0d14-1cad-4ca5-a512-05773c36cd8d@oss.qualcomm.com \
    --to=akhilpo@oss.qualcomm.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=airlied@gmail.com \
    --cc=anna.maniscalco2000@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    /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®