All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Courbot <gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH] devinit/gf100-: detect if BIOS invoked devinit
Date: Thu, 11 Feb 2016 11:10:04 +0900	[thread overview]
Message-ID: <1455156604-32049-1-git-send-email-acourbot@nvidia.com> (raw)

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.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 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(-)

diff --git a/drm/nouveau/nvkm/subdev/devinit/gf100.c b/drm/nouveau/nvkm/subdev/devinit/gf100.c
index 22b0140..2923598 100644
--- a/drm/nouveau/nvkm/subdev/devinit/gf100.c
+++ b/drm/nouveau/nvkm/subdev/devinit/gf100.c
@@ -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,
diff --git a/drm/nouveau/nvkm/subdev/devinit/gm107.c b/drm/nouveau/nvkm/subdev/devinit/gm107.c
index 2be98bd..28ca01b 100644
--- a/drm/nouveau/nvkm/subdev/devinit/gm107.c
+++ b/drm/nouveau/nvkm/subdev/devinit/gm107.c
@@ -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,
diff --git a/drm/nouveau/nvkm/subdev/devinit/gm204.c b/drm/nouveau/nvkm/subdev/devinit/gm204.c
index 2b9c3f1..84451dd 100644
--- a/drm/nouveau/nvkm/subdev/devinit/gm204.c
+++ b/drm/nouveau/nvkm/subdev/devinit/gm204.c
@@ -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,
diff --git a/drm/nouveau/nvkm/subdev/devinit/nv50.h b/drm/nouveau/nvkm/subdev/devinit/nv50.h
index 5de70a8..25d2ae3 100644
--- a/drm/nouveau/nvkm/subdev/devinit/nv50.h
+++ b/drm/nouveau/nvkm/subdev/devinit/nv50.h
@@ -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

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

             reply	other threads:[~2016-02-11  2:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11  2:10 Alexandre Courbot [this message]
     [not found] ` <1455156604-32049-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-01-28  0:41   ` [PATCH] devinit/gf100-: detect if BIOS invoked devinit Ilia Mirkin

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=1455156604-32049-1-git-send-email-acourbot@nvidia.com \
    --to=gnurou-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.