dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/msm/a6xx: Use CX AO Counter register for timestamp on a750 GPUs
Date: Tue, 08 Sep 2026 13:37:29 +0000	[thread overview]
Message-ID: <20260908133730.018851F00ACF@smtp.kernel.org> (raw)
In-Reply-To: <20260908-topic-sm8650-gmu-a750-timestamp-reg-v1-2-284880d6e68b@linaro.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The lockless 64-bit counter read loop will spin indefinitely on A750 GPUs, causing a hard CPU hang, because the high and low register offsets for the CX AO counter are swapped in their XML definitions.
--

commit cf31c6e4a536e6c06c20aa83c73f0af1762a7d51
Author: Neil Armstrong <neil.armstrong@linaro.org>

drm/msm/a6xx: Use CX AO Counter register for timestamp on a750 GPUs

The a750 uses the CX AO Counters instead of the GMU_ALWAYS_ON_COUNTER
register on A6xx and other A7xx GPUs, use it when running a A750 GPU.

> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index f9de9329dee39..081e79ea46528 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -23,9 +23,15 @@ static u64 a6xx_gmu_get_timestamp(struct msm_gpu *gpu)
>  	u64 count_hi, count_lo, temp;
>  
>  	do {
> -		count_hi = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H);
> -		count_lo = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L);
> -		temp = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H);
> +		if (adreno_is_a750_family(adreno_gpu)) {
> +			count_hi = gmu_read(&a6xx_gpu->gmu, REG_A7XX_GMU_CX_AO_COUNTER_H);
> +			count_lo = gmu_read(&a6xx_gpu->gmu, REG_A7XX_GMU_CX_AO_COUNTER_L);
> +			temp = gmu_read(&a6xx_gpu->gmu, REG_A7XX_GMU_CX_AO_COUNTER_H);
> +		} else {
> +			count_hi = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H);
> +			count_lo = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L);
> +			temp = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H);
> +		}
>  	} while (unlikely(count_hi != temp));
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Critical]
Could this cause an infinite loop on A750 GPUs?

In drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml, the register offsets
for the A750 CX AO counter appear to be swapped:

	<reg32 offset="0x1f880" name="GMU_CX_AO_COUNTER_H" variants="A7XX"/>
	<reg32 offset="0x1f881" name="GMU_CX_AO_COUNTER_L" variants="A7XX"/>

Since the H offset points to the lower 32 bits (0x1f880), this loop will
read the fast-changing lower 32 bits into count_hi and temp. Because these
bits change rapidly, won't the comparison (count_hi != temp) almost always
evaluate to true, causing a hard CPU hang in a6xx_gmu_get_timestamp()?

>  
>  	return (count_hi << 32) | count_lo;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-topic-sm8650-gmu-a750-timestamp-reg-v1-0-284880d6e68b@linaro.org?part=2

  reply	other threads:[~2026-09-08 13:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 13:24 [PATCH 0/2] drm/msm/a6xx: use correct timestamp counter on A750 GPU Neil Armstrong
2026-09-08 13:24 ` [PATCH 1/2] drm/msm/a6xx: Add CX AO Counter registers used for a750 GPUs Neil Armstrong
2026-09-08 13:38   ` sashiko-bot
2026-09-08 13:39   ` Neil Armstrong
2026-09-08 13:24 ` [PATCH 2/2] drm/msm/a6xx: Use CX AO Counter register for timestamp on " Neil Armstrong
2026-09-08 13:37   ` sashiko-bot [this message]
2026-09-09  9:06   ` Konrad Dybcio
2026-09-09  9:32     ` Neil Armstrong
2026-09-09 13:24       ` Connor Abbott
2026-09-09 14:29         ` Neil Armstrong
2026-09-09 14:31           ` Connor Abbott
2026-09-09 18:31   ` Akhil P Oommen
2026-09-10  6:57     ` Neil Armstrong

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=20260908133730.018851F00ACF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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