diff mbox series

[1/3] drm/nouveau/devinit/tu102-: wait for GFW_BOOT_PROGRESS == COMPLETED

Message ID 20230130223715.1831509-1-bskeggs@redhat.com (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/nouveau/devinit/tu102-: wait for GFW_BOOT_PROGRESS == COMPLETED | expand

Commit Message

Ben Skeggs Jan. 30, 2023, 10:37 p.m. UTC
Starting from Turing, the driver is no longer responsible for initiating
DEVINIT when required as the GPU started loading a FW image from ROM and
executing DEVINIT itself after power-on.

However - we apparently still need to wait for it to complete.

This should correct some issues with runpm on some systems, where we get
control of the HW before it's been fully reinitialised after resume from
suspend.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
 .../drm/nouveau/nvkm/subdev/devinit/tu102.c   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Lyude Paul Jan. 30, 2023, 11:19 p.m. UTC | #1
For the whole series:

Reviewed-by: Lyude Paul <lyude@redhat.com>

Will push to drm-misc-fixes in just a moment

On Tue, 2023-01-31 at 08:37 +1000, Ben Skeggs wrote:
> Starting from Turing, the driver is no longer responsible for initiating
> DEVINIT when required as the GPU started loading a FW image from ROM and
> executing DEVINIT itself after power-on.
> 
> However - we apparently still need to wait for it to complete.
> 
> This should correct some issues with runpm on some systems, where we get
> control of the HW before it's been fully reinitialised after resume from
> suspend.
> 
> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> ---
>  .../drm/nouveau/nvkm/subdev/devinit/tu102.c   | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> index 634f64f88fc8..81a1ad2c88a7 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> @@ -65,10 +65,33 @@ tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
>  	return ret;
>  }
>  
> +static int
> +tu102_devinit_wait(struct nvkm_device *device)
> +{
> +	unsigned timeout = 50 + 2000;
> +
> +	do {
> +		if (nvkm_rd32(device, 0x118128) & 0x00000001) {
> +			if ((nvkm_rd32(device, 0x118234) & 0x000000ff) == 0xff)
> +				return 0;
> +		}
> +
> +		usleep_range(1000, 2000);
> +	} while (timeout--);
> +
> +	return -ETIMEDOUT;
> +}
> +
>  int
>  tu102_devinit_post(struct nvkm_devinit *base, bool post)
>  {
>  	struct nv50_devinit *init = nv50_devinit(base);
> +	int ret;
> +
> +	ret = tu102_devinit_wait(init->base.subdev.device);
> +	if (ret)
> +		return ret;
> +
>  	gm200_devinit_preos(init, post);
>  	return 0;
>  }
Ben Skeggs Jan. 30, 2023, 11:22 p.m. UTC | #2
On Tue, 31 Jan 2023 at 09:19, Lyude Paul <lyude@redhat.com> wrote:
>
> For the whole series:
>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
>
> Will push to drm-misc-fixes in just a moment
Thank you Lyude!  Much appreciated.

Ben.

>
> On Tue, 2023-01-31 at 08:37 +1000, Ben Skeggs wrote:
> > Starting from Turing, the driver is no longer responsible for initiating
> > DEVINIT when required as the GPU started loading a FW image from ROM and
> > executing DEVINIT itself after power-on.
> >
> > However - we apparently still need to wait for it to complete.
> >
> > This should correct some issues with runpm on some systems, where we get
> > control of the HW before it's been fully reinitialised after resume from
> > suspend.
> >
> > Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
> > ---
> >  .../drm/nouveau/nvkm/subdev/devinit/tu102.c   | 23 +++++++++++++++++++
> >  1 file changed, 23 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> > index 634f64f88fc8..81a1ad2c88a7 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> > @@ -65,10 +65,33 @@ tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
> >       return ret;
> >  }
> >
> > +static int
> > +tu102_devinit_wait(struct nvkm_device *device)
> > +{
> > +     unsigned timeout = 50 + 2000;
> > +
> > +     do {
> > +             if (nvkm_rd32(device, 0x118128) & 0x00000001) {
> > +                     if ((nvkm_rd32(device, 0x118234) & 0x000000ff) == 0xff)
> > +                             return 0;
> > +             }
> > +
> > +             usleep_range(1000, 2000);
> > +     } while (timeout--);
> > +
> > +     return -ETIMEDOUT;
> > +}
> > +
> >  int
> >  tu102_devinit_post(struct nvkm_devinit *base, bool post)
> >  {
> >       struct nv50_devinit *init = nv50_devinit(base);
> > +     int ret;
> > +
> > +     ret = tu102_devinit_wait(init->base.subdev.device);
> > +     if (ret)
> > +             return ret;
> > +
> >       gm200_devinit_preos(init, post);
> >       return 0;
> >  }
>
> --
> Cheers,
>  Lyude Paul (she/her)
>  Software Engineer at Red Hat
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
index 634f64f88fc8..81a1ad2c88a7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
@@ -65,10 +65,33 @@  tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
 	return ret;
 }
 
+static int
+tu102_devinit_wait(struct nvkm_device *device)
+{
+	unsigned timeout = 50 + 2000;
+
+	do {
+		if (nvkm_rd32(device, 0x118128) & 0x00000001) {
+			if ((nvkm_rd32(device, 0x118234) & 0x000000ff) == 0xff)
+				return 0;
+		}
+
+		usleep_range(1000, 2000);
+	} while (timeout--);
+
+	return -ETIMEDOUT;
+}
+
 int
 tu102_devinit_post(struct nvkm_devinit *base, bool post)
 {
 	struct nv50_devinit *init = nv50_devinit(base);
+	int ret;
+
+	ret = tu102_devinit_wait(init->base.subdev.device);
+	if (ret)
+		return ret;
+
 	gm200_devinit_preos(init, post);
 	return 0;
 }