Devicetree
 help / color / mirror / Atom feed
From: Stefan Wahren <wahrenst@gmx.net>
To: "Maíra Canal" <mcanal@igalia.com>,
	"Melissa Wen" <mwen@igalia.com>, "Iago Toral" <itoral@igalia.com>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Nicolas Saenz Julienne" <nsaenz@kernel.org>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>
Cc: Phil Elwell <phil@raspberrypi.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	kernel-dev@igalia.com
Subject: Re: [PATCH v6 5/5] drm/v3d: Use V3D_SMS registers for power on/off and reset on V3D 7.x
Date: Thu, 27 Mar 2025 11:57:26 +0100	[thread overview]
Message-ID: <bffb4df1-1171-4a9b-9b73-af33136c620a@gmx.net> (raw)
In-Reply-To: <20250317-v3d-gpu-reset-fixes-v6-5-f3ee7717ed17@igalia.com>

Hi Maíra,

Am 18.03.25 um 02:01 schrieb Maíra Canal:
> In addition to the standard reset controller, V3D 7.x requires configuring
> the V3D_SMS registers for proper power on/off and reset. Add the new
> registers to `v3d_regs.h` and ensure they are properly configured during
> device probing, removal, and reset.
>
> This change fixes GPU reset issues on the Raspberry Pi 5 (BCM2712).
> Without exposing these registers, a GPU reset causes the GPU to hang,
> stopping any further job execution and freezing the desktop GUI. The same
> issue occurs when unloading and loading the v3d driver.
>
> Link: https://github.com/raspberrypi/linux/issues/6660
> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> ---
>   drivers/gpu/drm/v3d/v3d_drv.c  | 40 ++++++++++++++++++++++++++++++++++++++++
>   drivers/gpu/drm/v3d/v3d_drv.h  | 11 +++++++++++
>   drivers/gpu/drm/v3d/v3d_gem.c  | 17 +++++++++++++++++
>   drivers/gpu/drm/v3d/v3d_regs.h | 26 ++++++++++++++++++++++++++
>   4 files changed, 94 insertions(+)
>
> diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
> index c63f0ed1bd8a3d5511085e76ed2fbd6ee7df6f80..122848cdccc4a02039d9ea2e77aa2f377886b5d6 100644
> --- a/drivers/gpu/drm/v3d/v3d_drv.c
> +++ b/drivers/gpu/drm/v3d/v3d_drv.c
> @@ -263,6 +263,36 @@ static const struct of_device_id v3d_of_match[] = {
>   };
>   MODULE_DEVICE_TABLE(of, v3d_of_match);
>
> +static void
> +v3d_idle_sms(struct v3d_dev *v3d)
> +{
> +	if (v3d->ver < V3D_GEN_71)
> +		return;
> +
> +	V3D_SMS_WRITE(V3D_SMS_TEE_CS, V3D_SMS_CLEAR_POWER_OFF);
> +
> +	if (wait_for((V3D_GET_FIELD(V3D_SMS_READ(V3D_SMS_TEE_CS),
> +				    V3D_SMS_STATE) == V3D_SMS_IDLE), 100)) {
> +		DRM_ERROR("Failed to power up SMS\n");
> +	}
> +
> +	v3d_reset_sms(v3d);
> +}
> +
> +static void
> +v3d_power_off_sms(struct v3d_dev *v3d)
> +{
> +	if (v3d->ver < V3D_GEN_71)
> +		return;
> +
> +	V3D_SMS_WRITE(V3D_SMS_TEE_CS, V3D_SMS_POWER_OFF);
> +
> +	if (wait_for((V3D_GET_FIELD(V3D_SMS_READ(V3D_SMS_TEE_CS),
> +				    V3D_SMS_STATE) == V3D_SMS_POWER_OFF_STATE), 100)) {
> +		DRM_ERROR("Failed to power off SMS\n");
> +	}
> +}
> +
>   static int
>   map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
>   {
> @@ -300,6 +330,12 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
>   	if (ret)
>   		return ret;
>
> +	if (v3d->ver >= V3D_GEN_71) {
> +		ret = map_regs(v3d, &v3d->sms_regs, "sms");
> +		if (ret)
> +			return ret;
Is it correct, that BCM2712 now requires the SMS register and otherwise
the driver doesn't probe?

Just a note for the future: the devicetree is considered as an ABI [1],
so new kernels should still work with old DTB (no regression). For
Raspberry Pi OS, the kernel and DTB are always updated, but this doesn't
apply for Linux Mainline. AFAIK V3D doesn't work with Linux Mainline on
Raspberry Pi 5 yet, so this is just a theoretical problem.

Best regards

[1] - https://docs.kernel.org/devicetree/bindings/ABI.html

  reply	other threads:[~2025-03-27 10:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18  1:01 [PATCH v6 0/5] drm/v3d: Fix GPU reset issues on the Raspberry Pi 5 Maíra Canal
2025-03-18  1:01 ` [PATCH v6 1/5] drm/v3d: Associate a V3D tech revision to all supported devices Maíra Canal
2025-03-18 16:44   ` Stefan Wahren
2025-03-18 20:03   ` kernel test robot
2025-03-18  1:01 ` [PATCH v6 2/5] dt-bindings: gpu: v3d: Add per-compatible register restrictions Maíra Canal
2025-03-18  8:03   ` Krzysztof Kozlowski
2025-03-18  1:01 ` [PATCH v6 3/5] dt-bindings: gpu: v3d: Add SMS register to BCM2712 compatible Maíra Canal
2025-03-19 11:07   ` Stefan Wahren
2025-03-18  1:01 ` [PATCH v6 4/5] dt-bindings: gpu: v3d: Add V3D driver maintainer as DT maintainer Maíra Canal
2025-03-18  1:01 ` [PATCH v6 5/5] drm/v3d: Use V3D_SMS registers for power on/off and reset on V3D 7.x Maíra Canal
2025-03-27 10:57   ` Stefan Wahren [this message]
2025-03-27 13:52     ` Maíra Canal
2025-03-27 15:19       ` Stefan Wahren
2025-03-23 14:45 ` [PATCH v6 0/5] drm/v3d: Fix GPU reset issues on the Raspberry Pi 5 Maíra Canal

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=bffb4df1-1171-4a9b-9b73-af33136c620a@gmx.net \
    --to=wahrenst@gmx.net \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=itoral@igalia.com \
    --cc=kernel-dev@igalia.com \
    --cc=krzk+dt@kernel.org \
    --cc=mcanal@igalia.com \
    --cc=mwen@igalia.com \
    --cc=nsaenz@kernel.org \
    --cc=phil@raspberrypi.com \
    /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