Skip to contentSkip to conversation

devinit/gf100-: detect if BIOS invoked devinit

PATCH In review Alexandre Courbot 2 participants 2 messages Feb 11, 2016 – Jan 28, 2017 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devinit/gf100-: detect if BIOS invoked devinit

It is not advisable to perform devinit if it has already been done. VBIOS will very likely have invoked devinit if the GPU is the primary graphics device, but there is no accurate way to detect this fact yet.

This patch adds such a method for gf100 and later chips, by means of the NV_PTOP_SCRATCH1_DEVINIT_COMPLETED bit. This bit is set to 1 by devinit, and reset to 0 when the GPU is powered.

---
 drm/nouveau/nvkm/subdev/devinit/gf100.c | 14 +++++++++++++-
 drm/nouveau/nvkm/subdev/devinit/gm107.c |  2 +-
 drm/nouveau/nvkm/subdev/devinit/gm204.c |  4 +++-
 drm/nouveau/nvkm/subdev/devinit/nv50.h  |  1 +
 4 files changed, 18 insertions(+), 3 deletions(-)
drm/nouveau/nvkm/subdev/devinit/gf100.c +13 -1
index 22b0140..2923598 100644
@@ -90,9 +90,21 @@ gf100_devinit_disable(struct nvkm_devinit *init)
 	return disable;
 }
 
+void
+gf100_devinit_preinit(struct nvkm_devinit *base)
+{
+	struct nv50_devinit *init = nv50_devinit(base);
+	struct nvkm_subdev *subdev = &init->base.subdev;
+	struct nvkm_device *device = subdev->device;
+
+	/* This bit is set by devinit, and flips back to 0 on suspend */
+	if (!base->post)
+		base->post = ((nvkm_rd32(device, 0x2240c) & BIT(1)) == 0);
+}
+
 static const struct nvkm_devinit_func
 gf100_devinit = {
-	.preinit = nv50_devinit_preinit,
+	.preinit = gf100_devinit_preinit,
 	.init = nv50_devinit_init,
 	.post = nv04_devinit_post,
 	.pll_set = gf100_devinit_pll_set,
drm/nouveau/nvkm/subdev/devinit/gm107.c +1 -1
index 2be98bd..28ca01b 100644
@@ -46,7 +46,7 @@ gm107_devinit_disable(struct nvkm_devinit *init)
 
 static const struct nvkm_devinit_func
 gm107_devinit = {
-	.preinit = nv50_devinit_preinit,
+	.preinit = gf100_devinit_preinit,
 	.init = nv50_devinit_init,
 	.post = nv04_devinit_post,
 	.pll_set = gf100_devinit_pll_set,
drm/nouveau/nvkm/subdev/devinit/gm204.c +3 -1
index 2b9c3f1..84451dd 100644
@@ -162,11 +162,13 @@ gm204_devinit_post(struct nvkm_devinit *base, bool post)
 
 	/* load and execute some other ucode image (bios therm?) */
 	return pmu_load(init, 0x01, post, NULL, NULL);
+
+
 }
 
 static const struct nvkm_devinit_func
 gm204_devinit = {
-	.preinit = nv50_devinit_preinit,
+	.preinit = gf100_devinit_preinit,
 	.init = nv50_devinit_init,
 	.post = gm204_devinit_post,
 	.pll_set = gf100_devinit_pll_set,
drm/nouveau/nvkm/subdev/devinit/nv50.h +1 -0
index 5de70a8..25d2ae3 100644
@@ -20,6 +20,7 @@ int  gf100_devinit_ctor(struct nvkm_object *, struct nvkm_object *,
 			struct nvkm_oclass *, void *, u32,
 			struct nvkm_object **);
 int  gf100_devinit_pll_set(struct nvkm_devinit *, u32, u32);
+void gf100_devinit_preinit(struct nvkm_devinit *);
 
 u64  gm107_devinit_disable(struct nvkm_devinit *);
 #endif
Signature · 6 lines
2.7.1

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1455156604-32049-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 9 lines · Alexandre Courbot

It is not advisable to perform devinit if it has already been done. VBIOS will very likely have invoked devinit if the GPU is the primary graphics device, but there is no accurate way to detect this fact yet.

This patch adds such a method for gf100 and later chips, by means of the NV_PTOP_SCRATCH1_DEVINIT_COMPLETED bit. This bit is set to 1 by devinit, and reset to 0 when the GPU is powered.

Does this patch bring any tangible benefits for pre-maxwell? Some VBIOSes[1], namely a bunch of GF104 and at least one GK107 shipped without setting this bit as part of the VBIOS init script sequence. Perhaps others, as it's not like we have a 100% complete VBIOS repo. This causes nouveau to re-run the VBIOS, with apparently rather negative effects on at least the GF104's in question. Perhaps this is only necessary starting GM200? Or something else? Can we add the rdvgac thing to the gf100 heuristic like it's used on nv50?

Cheers,

-ilia

[1] https://bugs.freedesktop.org/show_bug.cgi?id=97620#c27

Quoted 81 lines
---
 drm/nouveau/nvkm/subdev/devinit/gf100.c | 14 +++++++++++++-
 drm/nouveau/nvkm/subdev/devinit/gm107.c |  2 +-
 drm/nouveau/nvkm/subdev/devinit/gm204.c |  4 +++-
 drm/nouveau/nvkm/subdev/devinit/nv50.h  |  1 +
 4 files changed, 18 insertions(+), 3 deletions(-)
drm/nouveau/nvkm/subdev/devinit/gf100.c +13 -1
index 22b0140..2923598 100644
@@ -90,9 +90,21 @@ gf100_devinit_disable(struct nvkm_devinit *init)
        return disable;
 }
 
+void
+gf100_devinit_preinit(struct nvkm_devinit *base)
+{
+       struct nv50_devinit *init = nv50_devinit(base);
+       struct nvkm_subdev *subdev = &init->base.subdev;
+       struct nvkm_device *device = subdev->device;
+
+       /* This bit is set by devinit, and flips back to 0 on suspend */
+       if (!base->post)
+               base->post = ((nvkm_rd32(device, 0x2240c) & BIT(1)) == 0);
+}
+
 static const struct nvkm_devinit_func
 gf100_devinit = {
-       .preinit = nv50_devinit_preinit,
+       .preinit = gf100_devinit_preinit,
        .init = nv50_devinit_init,
        .post = nv04_devinit_post,
        .pll_set = gf100_devinit_pll_set,
drm/nouveau/nvkm/subdev/devinit/gm107.c +1 -1
index 2be98bd..28ca01b 100644
@@ -46,7 +46,7 @@ gm107_devinit_disable(struct nvkm_devinit *init)
 
 static const struct nvkm_devinit_func
 gm107_devinit = {
-       .preinit = nv50_devinit_preinit,
+       .preinit = gf100_devinit_preinit,
        .init = nv50_devinit_init,
        .post = nv04_devinit_post,
        .pll_set = gf100_devinit_pll_set,
drm/nouveau/nvkm/subdev/devinit/gm204.c +3 -1
index 2b9c3f1..84451dd 100644
@@ -162,11 +162,13 @@ gm204_devinit_post(struct nvkm_devinit *base, bool post)
 
        /* load and execute some other ucode image (bios therm?) */
        return pmu_load(init, 0x01, post, NULL, NULL);
+
+
 }
 
 static const struct nvkm_devinit_func
 gm204_devinit = {
-       .preinit = nv50_devinit_preinit,
+       .preinit = gf100_devinit_preinit,
        .init = nv50_devinit_init,
        .post = gm204_devinit_post,
        .pll_set = gf100_devinit_pll_set,
drm/nouveau/nvkm/subdev/devinit/nv50.h +1 -1
index 5de70a8..25d2ae3 100644
@@ -20,6 +20,7 @@ int  gf100_devinit_ctor(struct nvkm_object *, struct nvkm_object *,
                        struct nvkm_oclass *, void *, u32,
                        struct nvkm_object **);
 int  gf100_devinit_pll_set(struct nvkm_devinit *, u32, u32);
+void gf100_devinit_preinit(struct nvkm_devinit *);
 
 u64  gm107_devinit_disable(struct nvkm_devinit *);
 #endif
--

2.7.1

Quoted 4 lines

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau