Skip to contentSkip to conversation

Improve GK20A and introduce GM20B support

PATCH New Alexandre Courbot 4 participants 12 messages Jun 18, 2015 – Jun 19, 2015 4 messages not in the archive Tegra architecture support

lore
Share & tools
lore
#0 lore raw

cover Improve GK20A and introduce GM20B support

Hello everyone,

GM20B is the GPU of the upcoming Tegra X1 SoC. This series adds initial support for it, based on a rework of the already-supported GK20A. It also introduces support for NVIDIA-provided firmware files, which is why I have added a few NVIDIA people who are relevant to this discussion.

The first patch adds support for loading the FECS and GPCCS firmwares from firmware files officially released by NVIDIA. As you know such firmwares will soon become a necessity for newer GPUs because some falcons will require signed firmware to operate. In addition there is no reverse-engineered version of the GK20A firmwares yet, so since an external file is needed anyway, it may as well be provided officially. NVIDIA plans to release firmwares as one file per binary to keep things simple. The layout will be nvidia/<gpu>/<firmware>.bin, so for GK20A FECS/GPCCS we have:

nvidia/gk20a/fecs_inst.bin (aka fuc409c)
nvidia/gk20a/fecs_data.bin (aka fuc409d)
nvidia/gk20a/gpccs_inst.bin (aka fuc41ac)
nvidia/gk20a/gpccs_data.bin (aka fuc41ad)

All firmware files listed in this patchset are clean for release, and I am just waiting for a community ack of the layout to send a patch to linux-firmware.

The second patch reworks existing GK20A support to make it closer to what our nvgpu driver does. Support so far was heavily based on GK104, which somehow made me feel uneasy - and quite scared after I looked more closely at what nvgpu does. In particular the GK104 MMIO bundles differed significantly from what nvgpu does. This change aligns things and (probably less significant, but still safer) reorders the initialization sequence to match the one of nvgpu.

You will note that the MMIO bundles now come as firmware files of their own. I am not sure the community will be pleased with an increase of firmware files, however the rationale for this is as follows:
- These initialization sequences are related to the firmwares, so it makes sense to distribute them under the same medium
- If NVIDIA needs to update the firmwares for some reason, it can atomically update the MMIO bundles and provide a coherent set, instead of having to introduce versioning into the firmware and driver
- For IP reasons, I as an NVIDIA employee cannot extract these register sequences and link them into Nouveau
- These are just a bunch of register address/value pairs anyway

The new firmware files introduced are:

nvidia/gk20a/sw_nonctx.bin (gr_pack_mmio) nvidia/gk20a/sw_ctx.bin (grctx_pack_hub, grctx_pack_gpc, grctx_pack_zcull,
grctx_pack_tpc, grctx_pack_ppc)
nvidia/gk20a/sw_bundle_init.bin (grctx_pack_icmd) nvidia/gk20a/sw_method_init.bin (grctx_pack_mthd)

Third patch is trivial and adds the GM20B FIFO device.

Fourth patch adds GM20B GR based on the reworked GK20A support. GM20B will rely on the same firmware files as GK20A (also clean for release). Note that this is not full support yet for released devices, which will require secure boot. This will be my focus once this patchset is merged (Deepak got a working version, but there is still a lot of work to do on it before it is upstreamable).

The last two patches recognize GM20B at the device and platform level. Nothing really exciting.

I hope the addition of firmware files will not become too controversial. If it does, I have good arguments to support it. ;) Besides the GK20A rework that probably few people care about, the point is the addition of a basic layout for the firmwares that NVIDIA will officially release to finally support secure boot, and I would like to make sure we get this right.

Thanks,
Alex.

Alexandre Courbot (6):
gr: support for NVIDIA-provided firmwares gr/gk20a: use same initialization sequence as nvgpu
fifo: add GM20B fifo
gr: add GM20B support
device: recognize GM20B
platform: recognize GM20B

 drm/nouveau/include/nvkm/engine/fifo.h |   1 +
 drm/nouveau/include/nvkm/engine/gr.h   |   1 +
 drm/nouveau/nouveau_platform.c         |   1 +
 drm/nouveau/nvkm/engine/device/gm100.c |  20 ++
 drm/nouveau/nvkm/engine/fifo/Kbuild    |   1 +
 drm/nouveau/nvkm/engine/fifo/gk104.h   |   4 +
 drm/nouveau/nvkm/engine/fifo/gm204.c   |   2 +-
 drm/nouveau/nvkm/engine/fifo/gm20b.c   |  34 ++++
 drm/nouveau/nvkm/engine/gr/Kbuild      |   2 +
 drm/nouveau/nvkm/engine/gr/ctxgf100.h  |   7 +
 drm/nouveau/nvkm/engine/gr/ctxgk20a.c  |  65 +++++--
 drm/nouveau/nvkm/engine/gr/ctxgm107.c  |   2 +-
 drm/nouveau/nvkm/engine/gr/ctxgm204.c  |   4 +-
 drm/nouveau/nvkm/engine/gr/ctxgm20b.c  | 110 +++++++++++
 drm/nouveau/nvkm/engine/gr/gf100.c     |  70 +++++--
 drm/nouveau/nvkm/engine/gr/gf100.h     |  18 ++
 drm/nouveau/nvkm/engine/gr/gk20a.c     | 336 +++++++++++++++++++++++++++++++--
 drm/nouveau/nvkm/engine/gr/gk20a.h     |  35 ++++
 drm/nouveau/nvkm/engine/gr/gm20b.c     |  84 +++++++++
 19 files changed, 748 insertions(+), 49 deletions(-)
 create mode 100644 drm/nouveau/nvkm/engine/fifo/gm20b.c
 create mode 100644 drm/nouveau/nvkm/engine/gr/ctxgm20b.c
 create mode 100644 drm/nouveau/nvkm/engine/gr/gk20a.h
 create mode 100644 drm/nouveau/nvkm/engine/gr/gm20b.c
Signature · 6 lines
2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 1/6 gr: support for NVIDIA-provided firmwares

In reply to a message not in the archive

NVIDIA will officially start providing signed firmwares through linux-firmware. Change the GR firmware lookup function to look them up in addition to the extracted firmwares.

---
 drm/nouveau/nvkm/engine/gr/gf100.c | 66 +++++++++++++++++++++++++++++---------
 1 file changed, 51 insertions(+), 15 deletions(-)
drm/nouveau/nvkm/engine/gr/gf100.c +51 -15
index ca11ddb..39d482f 100644
@@ -1544,26 +1544,62 @@ gf100_gr_dtor_fw(struct gf100_gr_fuc *fuc)
 	fuc->data = NULL;
 }
 
+/**
+ * gf100_gr_ctor_fw - helper for loading external GR firmwares
+ *
+ * A firmware can either be officially provided by NVIDIA (in which case it will
+ * use a "NVIDIA name", or be extracted from the binary blob (and use a
+ * "Nouveau name". The fwname and nvfwname are to be given the Nouveau and
+ * NVIDIA names of a given firmware, respectively. This function will then
+ * try to load the NVIDIA firmware, then the extracted one, in that order.
+ *
+ */
 int
 gf100_gr_ctor_fw(struct gf100_gr_priv *priv, const char *fwname,
-		 struct gf100_gr_fuc *fuc)
+		 const char *nvfwname, struct gf100_gr_fuc *fuc)
 {
 	struct nvkm_device *device = nv_device(priv);
 	const struct firmware *fw;
-	char f[32];
-	int ret;
+	char f[64];
+	int ret = -EINVAL;
+	int i;
 
-	snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset, fwname);
-	ret = request_firmware(&fw, f, nv_device_base(device));
-	if (ret) {
-		snprintf(f, sizeof(f), "nouveau/%s", fwname);
-		ret = request_firmware(&fw, f, nv_device_base(device));
-		if (ret) {
-			nv_error(priv, "failed to load %s\n", fwname);
-			return ret;
+	/*
+	 * NVIDIA firmware name provided - try to load it
+	 * We try this first since most chips that require external firmware
+	 * are supported by NVIDIA
+	 */
+	if (nvfwname) {
+		snprintf(f, sizeof(f), "nvidia/%s/%s.bin", device->cname,
+			 nvfwname);
+		i = strlen(f);
+		while (i) {
+			--i;
+			f[i] = tolower(f[i]);
 		}
+		ret = request_firmware_direct(&fw, f, nv_device_base(device));
+		if (!ret)
+			goto found;
+	}
+
+	/* Nouveau firmware name provided - try to load it */
+	if (fwname) {
+		snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset,
+			 fwname);
+		ret = request_firmware_direct(&fw, f, nv_device_base(device));
+		if (!ret)
+			goto found;
+
+		snprintf(f, sizeof(f), "nouveau/%s", fwname);
+		ret = request_firmware_direct(&fw, f, nv_device_base(device));
+		if (!ret)
+			goto found;
 	}
 
+	nv_error(priv, "failed to load %s / %s\n", fwname, nvfwname);
+	return ret;
+
+found:
 	fuc->size = fw->size;
 	fuc->data = kmemdup(fw->data, fuc->size, GFP_KERNEL);
 	release_firmware(fw);
@@ -1615,10 +1651,10 @@ gf100_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
 	if (use_ext_fw) {
 		nv_info(priv, "using external firmware\n");
-		if (gf100_gr_ctor_fw(priv, "fuc409c", &priv->fuc409c) ||
-		    gf100_gr_ctor_fw(priv, "fuc409d", &priv->fuc409d) ||
-		    gf100_gr_ctor_fw(priv, "fuc41ac", &priv->fuc41ac) ||
-		    gf100_gr_ctor_fw(priv, "fuc41ad", &priv->fuc41ad))
+		if (gf100_gr_ctor_fw(priv, "fuc409c", "fecs_inst", &priv->fuc409c) ||
+		    gf100_gr_ctor_fw(priv, "fuc409d", "fecs_data", &priv->fuc409d) ||
+		    gf100_gr_ctor_fw(priv, "fuc41ac", "gpccs_inst", &priv->fuc41ac) ||
+		    gf100_gr_ctor_fw(priv, "fuc41ad", "gpccs_data", &priv->fuc41ad))
 			return -ENODEV;
 		priv->firmware = true;
 	}
Signature · 6 lines
2.4.3

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#11 lore raw

PATCH 2/6 gr/gk20a: use same initialization sequence as nvgpu

In reply to a message not in the archive

GK20A's initialization was based on GK104, but differences exist in the way the initial context is built and the initialization process itself.

This patch follows the same initialization sequence as nvgpu performs to avoid bad surprises. Since the register bundles initialization also differ considerably from GK104, the register packs are now loaded from firmware files, again similarly to what is done with nvgpu.

---
 drm/nouveau/nvkm/engine/gr/ctxgk20a.c |  65 +++++--
 drm/nouveau/nvkm/engine/gr/gf100.c    |   3 +-
 drm/nouveau/nvkm/engine/gr/gf100.h    |  12 ++
 drm/nouveau/nvkm/engine/gr/gk20a.c    | 336 ++++++++++++++++++++++++++++++++--
 drm/nouveau/nvkm/engine/gr/gk20a.h    |  35 ++++
 5 files changed, 421 insertions(+), 30 deletions(-)
 create mode 100644 drm/nouveau/nvkm/engine/gr/gk20a.h
drm/nouveau/nvkm/engine/gr/ctxgk20a.c +50 -15
index 2f241f6..3fe080e 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -19,14 +19,56 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
+
 #include "ctxgf100.h"
+#include "gk20a.h"
+
+#include <subdev/mc.h>
+
+static void
+gk20a_grctx_generate_main(struct gf100_gr_priv *priv, struct gf100_grctx *info)
+{
+	struct gf100_grctx_oclass *oclass = (void *)nv_engine(priv)->cclass;
+	int idle_timeout_save;
+	int i;
+
+	gf100_gr_mmio(priv, priv->fuc_sw_ctx);
+
+	gf100_gr_wait_idle(priv);
+
+	idle_timeout_save = nv_rd32(priv, 0x404154);
+	nv_wr32(priv, 0x404154, 0x00000000);
+
+	oclass->attrib(info);
+
+	oclass->unkn(priv);
+
+	gf100_grctx_generate_tpcid(priv);
+	gf100_grctx_generate_r406028(priv);
+	gk104_grctx_generate_r418bb8(priv);
+	gf100_grctx_generate_r406800(priv);
+
+	for (i = 0; i < 8; i++)
+		nv_wr32(priv, 0x4064d0 + (i * 0x04), 0x00000000);
+
+	nv_wr32(priv, 0x405b00, (priv->tpc_total << 8) | priv->gpc_nr);
+
+	gk104_grctx_generate_rop_active_fbps(priv);
+
+	nv_mask(priv, 0x5044b0, 0x8000000, 0x8000000);
+
+	gf100_gr_wait_idle(priv);
+
+	nv_wr32(priv, 0x404154, idle_timeout_save);
+	gf100_gr_wait_idle(priv);
+
+	gf100_gr_mthd(priv, priv->fuc_method);
+	gf100_gr_wait_idle(priv);
 
-static const struct gf100_gr_pack
-gk20a_grctx_pack_mthd[] = {
-	{ gk104_grctx_init_a097_0, 0xa297 },
-	{ gf100_grctx_init_902d_0, 0x902d },
-	{}
-};
+	gf100_gr_icmd(priv, priv->fuc_bundle);
+	oclass->pagepool(info);
+	oclass->bundle(info);
+}
 
 struct nvkm_oclass *
 gk20a_grctx_oclass = &(struct gf100_grctx_oclass) {
@@ -39,15 +81,8 @@ gk20a_grctx_oclass = &(struct gf100_grctx_oclass) {
 		.rd32 = _nvkm_gr_context_rd32,
 		.wr32 = _nvkm_gr_context_wr32,
 	},
-	.main  = gk104_grctx_generate_main,
+	.main  = gk20a_grctx_generate_main,
 	.unkn  = gk104_grctx_generate_unkn,
-	.hub   = gk104_grctx_pack_hub,
-	.gpc   = gk104_grctx_pack_gpc,
-	.zcull = gf100_grctx_pack_zcull,
-	.tpc   = gk104_grctx_pack_tpc,
-	.ppc   = gk104_grctx_pack_ppc,
-	.icmd  = gk104_grctx_pack_icmd,
-	.mthd  = gk20a_grctx_pack_mthd,
 	.bundle = gk104_grctx_generate_bundle,
 	.bundle_size = 0x1800,
 	.bundle_min_gpm_fifo_depth = 0x62,
drm/nouveau/nvkm/engine/gr/gf100.c +2 -1
index 39d482f..d5c148f 100644
@@ -1537,7 +1537,7 @@ gf100_gr_init(struct nvkm_object *object)
 	return gf100_gr_init_ctxctl(priv);
 }
 
-static void
+void
 gf100_gr_dtor_fw(struct gf100_gr_fuc *fuc)
 {
 	kfree(fuc->data);
@@ -1719,6 +1719,7 @@ gf100_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 		break;
 	case 0xd7:
 	case 0xd9: /* 1/0/0/0, 1 */
+	case 0xea: /* gk20a */
 		priv->magic_not_rop_nr = 0x01;
 		break;
 	}
drm/nouveau/nvkm/engine/gr/gf100.h +12 -0
index c9533fd..af4d70f 100644
@@ -76,6 +76,15 @@ struct gf100_gr_priv {
 	struct gf100_gr_fuc fuc41ad;
 	bool firmware;
 
+	/*
+	 * Used if the register packs are loaded from NVIDIA fw instead of
+	 * using hardcoded arrays.
+	 */
+	struct gf100_gr_pack *fuc_sw_nonctx;
+	struct gf100_gr_pack *fuc_sw_ctx;
+	struct gf100_gr_pack *fuc_bundle;
+	struct gf100_gr_pack *fuc_method;
+
 	struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT];
 	struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT];
 
@@ -116,6 +125,9 @@ void gf100_gr_context_dtor(struct nvkm_object *);
 
 void gf100_gr_ctxctl_debug(struct gf100_gr_priv *);
 
+void gf100_gr_dtor_fw(struct gf100_gr_fuc *);
+int  gf100_gr_ctor_fw(struct gf100_gr_priv *, const char *, const char *,
+		      struct gf100_gr_fuc *);
 u64  gf100_gr_units(struct nvkm_gr *);
 int  gf100_gr_ctor(struct nvkm_object *, struct nvkm_object *,
 		     struct nvkm_oclass *, void *data, u32 size,
drm/nouveau/nvkm/engine/gr/gk20a.c +322 -14

354 lines not on this page · raw message

drm/nouveau/nvkm/engine/gr/gk20a.h new file +35 -0
new file mode 100644
index 0000000..b369585
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __GK20A_GR_H__
+#define __GK20A_GR_H__
+
+#include "gf100.h"
+
+struct gk20a_gr_oclass {
+	struct gf100_gr_oclass gf100;
+
+	void (*init_gpc_mmu)(struct gf100_gr_priv *);
+	void (*set_hww_esr_report_mask)(struct gf100_gr_priv *);
+};
+
+#endif
Signature · 1 line
2.4.3
#12 lore raw

PATCH 3/6 fifo: add GM20B fifo

In reply to a message not in the archive

GM20B has a 512-channels FIFO similar to GK104.

---
 drm/nouveau/include/nvkm/engine/fifo.h |  1 +
 drm/nouveau/nvkm/engine/fifo/Kbuild    |  1 +
 drm/nouveau/nvkm/engine/fifo/gk104.h   |  4 ++++
 drm/nouveau/nvkm/engine/fifo/gm204.c   |  2 +-
 drm/nouveau/nvkm/engine/fifo/gm20b.c   | 34 ++++++++++++++++++++++++++++++++++
 5 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 drm/nouveau/nvkm/engine/fifo/gm20b.c
drm/nouveau/include/nvkm/engine/fifo.h +1 -0
index 97cdeab..9100b80 100644
@@ -117,6 +117,7 @@ extern struct nvkm_oclass *gk104_fifo_oclass;
 extern struct nvkm_oclass *gk20a_fifo_oclass;
 extern struct nvkm_oclass *gk208_fifo_oclass;
 extern struct nvkm_oclass *gm204_fifo_oclass;
+extern struct nvkm_oclass *gm20b_fifo_oclass;
 
 int  nvkm_fifo_uevent_ctor(struct nvkm_object *, void *, u32,
 			   struct nvkm_notify *);
drm/nouveau/nvkm/engine/fifo/Kbuild +1 -0
index 42891cb..dc81a8b 100644
@@ -10,3 +10,4 @@ nvkm-y += nvkm/engine/fifo/gk104.o
 nvkm-y += nvkm/engine/fifo/gk20a.o
 nvkm-y += nvkm/engine/fifo/gk208.o
 nvkm-y += nvkm/engine/fifo/gm204.o
+nvkm-y += nvkm/engine/fifo/gm20b.o
drm/nouveau/nvkm/engine/fifo/gk104.h +4 -0
index 318d30d..b77d75f 100644
@@ -15,4 +15,8 @@ struct gk104_fifo_impl {
 };
 
 extern struct nvkm_ofuncs gk104_fifo_chan_ofuncs;
+
+int  gm204_fifo_ctor(struct nvkm_object *, struct nvkm_object *,
+		    struct nvkm_oclass *, void *, u32,
+		    struct nvkm_object **);
 #endif
drm/nouveau/nvkm/engine/fifo/gm204.c +1 -1
index 749d525..7596587 100644
@@ -31,7 +31,7 @@ gm204_fifo_sclass[] = {
 	{}
 };
 
-static int
+int
 gm204_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 		struct nvkm_oclass *oclass, void *data, u32 size,
 		struct nvkm_object **pobject)
drm/nouveau/nvkm/engine/fifo/gm20b.c new file +34 -0
new file mode 100644
index 0000000..4abf547
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include "gk104.h"
+
+struct nvkm_oclass *
+gm20b_fifo_oclass = &(struct gk104_fifo_impl) {
+	.base.handle = NV_ENGINE(FIFO, 0x2b),
+	.base.ofuncs = &(struct nvkm_ofuncs) {
+		.ctor = gm204_fifo_ctor,
+		.dtor = gk104_fifo_dtor,
+		.init = gk104_fifo_init,
+		.fini = gk104_fifo_fini,
+	},
+	.channels = 512,
+}.base;
Signature · 6 lines
2.4.3

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#14 lore raw

PATCH 4/6 gr: add GM20B support

In reply to Alexandre Courbot

Add support for GM20B's graphics engine, based on GK20A. Note that this code alone will not allow the engine to initialize on released devices which require PMU-assisted secure boot.

---
 drm/nouveau/include/nvkm/engine/gr.h  |   1 +
 drm/nouveau/nvkm/engine/gr/Kbuild     |   2 +
 drm/nouveau/nvkm/engine/gr/ctxgf100.h |   7 +++
 drm/nouveau/nvkm/engine/gr/ctxgm107.c |   2 +-
 drm/nouveau/nvkm/engine/gr/ctxgm204.c |   4 +-
 drm/nouveau/nvkm/engine/gr/ctxgm20b.c | 110 ++++++++++++++++++++++++++++++++++
 drm/nouveau/nvkm/engine/gr/gf100.c    |   1 +
 drm/nouveau/nvkm/engine/gr/gf100.h    |   6 ++
 drm/nouveau/nvkm/engine/gr/gk20a.c    |   6 +-
 drm/nouveau/nvkm/engine/gr/gm20b.c    |  84 ++++++++++++++++++++++++++
 10 files changed, 217 insertions(+), 6 deletions(-)
 create mode 100644 drm/nouveau/nvkm/engine/gr/ctxgm20b.c
 create mode 100644 drm/nouveau/nvkm/engine/gr/gm20b.c
drm/nouveau/include/nvkm/engine/gr.h +1 -0
index 7cbe202..c772497 100644
@@ -74,6 +74,7 @@ extern struct nvkm_oclass *gk208_gr_oclass;
 extern struct nvkm_oclass *gm107_gr_oclass;
 extern struct nvkm_oclass *gm204_gr_oclass;
 extern struct nvkm_oclass *gm206_gr_oclass;
+extern struct nvkm_oclass *gm20b_gr_oclass;
 
 #include <core/enum.h>
 
drm/nouveau/nvkm/engine/gr/Kbuild +2 -0
index 2e1b92f..e91b4df 100644
@@ -14,6 +14,7 @@ nvkm-y += nvkm/engine/gr/ctxgk208.o
 nvkm-y += nvkm/engine/gr/ctxgm107.o
 nvkm-y += nvkm/engine/gr/ctxgm204.o
 nvkm-y += nvkm/engine/gr/ctxgm206.o
+nvkm-y += nvkm/engine/gr/ctxgm20b.o
 nvkm-y += nvkm/engine/gr/nv04.o
 nvkm-y += nvkm/engine/gr/nv10.o
 nvkm-y += nvkm/engine/gr/nv20.o
@@ -38,3 +39,4 @@ nvkm-y += nvkm/engine/gr/gk208.o
 nvkm-y += nvkm/engine/gr/gm107.o
 nvkm-y += nvkm/engine/gr/gm204.o
 nvkm-y += nvkm/engine/gr/gm206.o
+nvkm-y += nvkm/engine/gr/gm20b.o
drm/nouveau/nvkm/engine/gr/ctxgf100.h +7 -0
index 3676a33..f89ab37 100644
@@ -91,6 +91,10 @@ void gk104_grctx_generate_r418bb8(struct gf100_gr_priv *);
 void gk104_grctx_generate_rop_active_fbps(struct gf100_gr_priv *);
 
 
+void gm107_grctx_generate_bundle(struct gf100_grctx *);
+void gm107_grctx_generate_pagepool(struct gf100_grctx *);
+void gm107_grctx_generate_attrib(struct gf100_grctx *);
+
 extern struct nvkm_oclass *gk110_grctx_oclass;
 extern struct nvkm_oclass *gk110b_grctx_oclass;
 extern struct nvkm_oclass *gk208_grctx_oclass;
@@ -102,8 +106,11 @@ void gm107_grctx_generate_attrib(struct gf100_grctx *);
 
 extern struct nvkm_oclass *gm204_grctx_oclass;
 void gm204_grctx_generate_main(struct gf100_gr_priv *, struct gf100_grctx *);
+void gm204_grctx_generate_tpcid(struct gf100_gr_priv *);
+void gm204_grctx_generate_405b60(struct gf100_gr_priv *);
 
 extern struct nvkm_oclass *gm206_grctx_oclass;
+extern struct nvkm_oclass *gm20b_grctx_oclass;
 
 /* context init value lists */
 
drm/nouveau/nvkm/engine/gr/ctxgm107.c +1 -1
index fbeaae3..6bf2fd1 100644
@@ -931,7 +931,7 @@ gm107_grctx_generate_attrib(struct gf100_grctx *info)
 	}
 }
 
-static void
+void
 gm107_grctx_generate_tpcid(struct gf100_gr_priv *priv)
 {
 	int gpc, tpc, id;
drm/nouveau/nvkm/engine/gr/ctxgm204.c +2 -2
index ea8e661..efc76bf 100644
@@ -918,7 +918,7 @@ gm204_grctx_pack_ppc[] = {
  * PGRAPH context implementation
  ******************************************************************************/
 
-static void
+void
 gm204_grctx_generate_tpcid(struct gf100_gr_priv *priv)
 {
 	int gpc, tpc, id;
@@ -943,7 +943,7 @@ gm204_grctx_generate_rop_active_fbps(struct gf100_gr_priv *priv)
 	nv_mask(priv, 0x408958, 0x0000000f, fbp_count); /* crop */
 }
 
-static void
+void
 gm204_grctx_generate_405b60(struct gf100_gr_priv *priv)
 {
 	const u32 dist_nr = DIV_ROUND_UP(priv->tpc_total, 4);
drm/nouveau/nvkm/engine/gr/ctxgm20b.c new file +110 -0

111 lines not on this page · raw message

drm/nouveau/nvkm/engine/gr/gf100.c +1 -0
index d5c148f..359501f 100644
@@ -1720,6 +1720,7 @@ gf100_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	case 0xd7:
 	case 0xd9: /* 1/0/0/0, 1 */
 	case 0xea: /* gk20a */
+	case 0x12b: /* gm20b */
 		priv->magic_not_rop_nr = 0x01;
 		break;
 	}
drm/nouveau/nvkm/engine/gr/gf100.h +6 -0
index af4d70f..719c7ab 100644
@@ -141,6 +141,12 @@ int  gk104_gr_ctor(struct nvkm_object *, struct nvkm_object *,
 		     struct nvkm_object **);
 int  gk104_gr_init(struct nvkm_object *);
 
+int  gk20a_gr_ctor(struct nvkm_object *, struct nvkm_object *,
+		     struct nvkm_oclass *, void *data, u32 size,
+		     struct nvkm_object **);
+void gk20a_gr_dtor(struct nvkm_object *);
+int  gk20a_gr_init(struct nvkm_object *);
+
 int  gm204_gr_init(struct nvkm_object *);
 
 extern struct nvkm_ofuncs gf100_fermi_ofuncs;
drm/nouveau/nvkm/engine/gr/gk20a.c +3 -3
index 65f1089..0c6bf83 100644
@@ -154,7 +154,7 @@ gk20a_gr_av_to_method(struct gf100_gr_fuc *fuc)
 	return pack;
 }
 
-static int
+int
 gk20a_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	      struct nvkm_oclass *oclass, void *data, u32 size,
 	      struct nvkm_object **pobject)
@@ -204,7 +204,7 @@ gk20a_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	return 0;
 }
 
-static void
+void
 gk20a_gr_dtor(struct nvkm_object *object)
 {
 	struct gf100_gr_priv *priv = (void *)object;
@@ -240,7 +240,7 @@ gk20a_gr_set_hww_esr_report_mask(struct gf100_gr_priv *priv)
 	nv_wr32(priv, 0x419e4c, 0x7f);
 }
 
-static int
+int
 gk20a_gr_init(struct nvkm_object *object)
 {
 	struct gk20a_gr_oclass *oclass = (void *)object->oclass;
drm/nouveau/nvkm/engine/gr/gm20b.c new file +84 -0

84 lines not on this page · raw message

Signature · 6 lines
2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH 5/6 device: recognize GM20B

In reply to a message not in the archive

Recognize GM20B and assign the right engines and subdevs.

---
 drm/nouveau/nvkm/engine/device/gm100.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drm/nouveau/nvkm/engine/device/gm100.c +20 -0
index 70abf1e..a51b3ce 100644
@@ -181,6 +181,26 @@ gm100_identify(struct nvkm_device *device)
 		device->oclass[NVDEV_ENGINE_MSPPP  ] = &gf100_msppp_oclass;
 #endif
 		break;
+	case 0x12b:
+		device->cname = "GM20B";
+
+		device->oclass[NVDEV_SUBDEV_MC     ] =  gk20a_mc_oclass;
+		device->oclass[NVDEV_SUBDEV_MMU    ] = &gf100_mmu_oclass;
+		device->oclass[NVDEV_SUBDEV_BUS    ] =  gf100_bus_oclass;
+		device->oclass[NVDEV_SUBDEV_FUSE   ] = &gm107_fuse_oclass;
+		device->oclass[NVDEV_SUBDEV_TIMER  ] = &gk20a_timer_oclass;
+		device->oclass[NVDEV_SUBDEV_FB     ] =  gk20a_fb_oclass;
+		device->oclass[NVDEV_SUBDEV_LTC    ] =  gm107_ltc_oclass;
+		device->oclass[NVDEV_SUBDEV_IBUS   ] = &gk20a_ibus_oclass;
+		device->oclass[NVDEV_SUBDEV_INSTMEM] = gk20a_instmem_oclass;
+		device->oclass[NVDEV_SUBDEV_MMU    ] = &gf100_mmu_oclass;
+		device->oclass[NVDEV_SUBDEV_BAR    ] = &gk20a_bar_oclass;
+		device->oclass[NVDEV_ENGINE_DMAOBJ ] =  gf110_dmaeng_oclass;
+		device->oclass[NVDEV_ENGINE_FIFO   ] =  gm20b_fifo_oclass;
+		device->oclass[NVDEV_ENGINE_SW     ] =  gf100_sw_oclass;
+		device->oclass[NVDEV_ENGINE_GR     ] =  gm20b_gr_oclass;
+		device->oclass[NVDEV_ENGINE_CE2    ] = &gm204_ce2_oclass;
+		break;
 	default:
 		nv_fatal(device, "unknown Maxwell chipset\n");
 		return -EINVAL;
Signature · 6 lines
2.4.3

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#15 lore raw

PATCH 6/6 platform: recognize GM20B

In reply to Alexandre Courbot

Allow the platform driver to recognize GM20B.

---
 drm/nouveau/nouveau_platform.c | 1 +
 1 file changed, 1 insertion(+)
drm/nouveau/nouveau_platform.c +1 -0
index dcfbbfa..7a39d44 100644
@@ -252,6 +252,7 @@ static int nouveau_platform_remove(struct platform_device *pdev)
 #if IS_ENABLED(CONFIG_OF)
 static const struct of_device_id nouveau_platform_match[] = {
 	{ .compatible = "nvidia,gk20a" },
+	{ .compatible = "nvidia,gm20b" },
 	{ }
 };
 
Signature · 6 lines
2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [Nouveau] [PATCH 1/6] gr: support for NVIDIA-provided firmwares

In reply to Alexandre Courbot

Why did you change request_firmware to request_firmware_direct?

Quoted 105 lines · Alexandre Courbot

NVIDIA will officially start providing signed firmwares through linux-firmware. Change the GR firmware lookup function to look them up in addition to the extracted firmwares.

---
 drm/nouveau/nvkm/engine/gr/gf100.c | 66 +++++++++++++++++++++++++++++---------
 1 file changed, 51 insertions(+), 15 deletions(-)
drm/nouveau/nvkm/engine/gr/gf100.c +51 -16
index ca11ddb..39d482f 100644
@@ -1544,26 +1544,62 @@ gf100_gr_dtor_fw(struct gf100_gr_fuc *fuc)
        fuc->data = NULL;
 }
 
+/**
+ * gf100_gr_ctor_fw - helper for loading external GR firmwares
+ *
+ * A firmware can either be officially provided by NVIDIA (in which case it will
+ * use a "NVIDIA name", or be extracted from the binary blob (and use a
+ * "Nouveau name". The fwname and nvfwname are to be given the Nouveau and
+ * NVIDIA names of a given firmware, respectively. This function will then
+ * try to load the NVIDIA firmware, then the extracted one, in that order.
+ *
+ */
 int
 gf100_gr_ctor_fw(struct gf100_gr_priv *priv, const char *fwname,
-                struct gf100_gr_fuc *fuc)
+                const char *nvfwname, struct gf100_gr_fuc *fuc)
 {
        struct nvkm_device *device = nv_device(priv);
        const struct firmware *fw;
-       char f[32];
-       int ret;
+       char f[64];
+       int ret = -EINVAL;
+       int i;
 
-       snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset, fwname);
-       ret = request_firmware(&fw, f, nv_device_base(device));
-       if (ret) {
-               snprintf(f, sizeof(f), "nouveau/%s", fwname);
-               ret = request_firmware(&fw, f, nv_device_base(device));
-               if (ret) {
-                       nv_error(priv, "failed to load %s\n", fwname);
-                       return ret;
+       /*
+        * NVIDIA firmware name provided - try to load it
+        * We try this first since most chips that require external firmware
+        * are supported by NVIDIA
+        */
+       if (nvfwname) {
+               snprintf(f, sizeof(f), "nvidia/%s/%s.bin", device->cname,
+                        nvfwname);
+               i = strlen(f);
+               while (i) {
+                       --i;
+                       f[i] = tolower(f[i]);
                }
+               ret = request_firmware_direct(&fw, f, nv_device_base(device));
+               if (!ret)
+                       goto found;
+       }
+
+       /* Nouveau firmware name provided - try to load it */
+       if (fwname) {
+               snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset,
+                        fwname);
+               ret = request_firmware_direct(&fw, f, nv_device_base(device));
+               if (!ret)
+                       goto found;
+
+               snprintf(f, sizeof(f), "nouveau/%s", fwname);
+               ret = request_firmware_direct(&fw, f, nv_device_base(device));
+               if (!ret)
+                       goto found;
        }
 
+       nv_error(priv, "failed to load %s / %s\n", fwname, nvfwname);
+       return ret;
+
+found:
        fuc->size = fw->size;
        fuc->data = kmemdup(fw->data, fuc->size, GFP_KERNEL);
        release_firmware(fw);
@@ -1615,10 +1651,10 @@ gf100_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
        if (use_ext_fw) {
                nv_info(priv, "using external firmware\n");
-               if (gf100_gr_ctor_fw(priv, "fuc409c", &priv->fuc409c) ||
-                   gf100_gr_ctor_fw(priv, "fuc409d", &priv->fuc409d) ||
-                   gf100_gr_ctor_fw(priv, "fuc41ac", &priv->fuc41ac) ||
-                   gf100_gr_ctor_fw(priv, "fuc41ad", &priv->fuc41ad))
+               if (gf100_gr_ctor_fw(priv, "fuc409c", "fecs_inst", &priv->fuc409c) ||
+                   gf100_gr_ctor_fw(priv, "fuc409d", "fecs_data", &priv->fuc409d) ||
+                   gf100_gr_ctor_fw(priv, "fuc41ac", "gpccs_inst", &priv->fuc41ac) ||
+                   gf100_gr_ctor_fw(priv, "fuc41ad", "gpccs_data", &priv->fuc41ad))
                        return -ENODEV;
                priv->firmware = true;
        }
--

2.4.3

Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [Nouveau] [PATCH 1/6] gr: support for NVIDIA-provided firmwares

Quoted 1 line · Ilia Mirkin

Why did you change request_firmware to request_firmware_direct?

request_firmware() outputs an error message if the firmware file does not exist, whereas request_firmware_direct() doesn't. Since the firmware file can be in one of two locations, that seems to be the most appropriate behavior.

However, request_firmware_direct() also does not invoke the userspace helper. In the case of Nouveau I don't believe we need this, but if I overlooked something let me know and I will think of something else.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH 1/6] gr: support for NVIDIA-provided firmwares

In reply to a message not in the archive
Quoted 3 lines · Alexandre Courbot

NVIDIA will officially start providing signed firmwares through linux-firmware. Change the GR firmware lookup function to look them up in addition to the extracted firmwares.

I wonder if perhaps we should just replace the mechanism entirely, and remove the support for nouveau/fuc* as we add "official" support for NVIDIA's ucode. The existing code is actually partially broken anyway, and mostly works by luck and was intended as a development aid / workaround anyway. There are no chipsets (aside from GM2xx...) which we don't currently support using our own ucode, so the impact of removing it will be very minimal.

Thoughts?

Ben.

Quoted 102 lines
---
 drm/nouveau/nvkm/engine/gr/gf100.c | 66 +++++++++++++++++++++++++++++---------
 1 file changed, 51 insertions(+), 15 deletions(-)
drm/nouveau/nvkm/engine/gr/gf100.c +51 -16
index ca11ddb..39d482f 100644
@@ -1544,26 +1544,62 @@ gf100_gr_dtor_fw(struct gf100_gr_fuc *fuc)
        fuc->data = NULL;
 }
 
+/**
+ * gf100_gr_ctor_fw - helper for loading external GR firmwares
+ *
+ * A firmware can either be officially provided by NVIDIA (in which case it will
+ * use a "NVIDIA name", or be extracted from the binary blob (and use a
+ * "Nouveau name". The fwname and nvfwname are to be given the Nouveau and
+ * NVIDIA names of a given firmware, respectively. This function will then
+ * try to load the NVIDIA firmware, then the extracted one, in that order.
+ *
+ */
 int
 gf100_gr_ctor_fw(struct gf100_gr_priv *priv, const char *fwname,
-                struct gf100_gr_fuc *fuc)
+                const char *nvfwname, struct gf100_gr_fuc *fuc)
 {
        struct nvkm_device *device = nv_device(priv);
        const struct firmware *fw;
-       char f[32];
-       int ret;
+       char f[64];
+       int ret = -EINVAL;
+       int i;
 
-       snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset, fwname);
-       ret = request_firmware(&fw, f, nv_device_base(device));
-       if (ret) {
-               snprintf(f, sizeof(f), "nouveau/%s", fwname);
-               ret = request_firmware(&fw, f, nv_device_base(device));
-               if (ret) {
-                       nv_error(priv, "failed to load %s\n", fwname);
-                       return ret;
+       /*
+        * NVIDIA firmware name provided - try to load it
+        * We try this first since most chips that require external firmware
+        * are supported by NVIDIA
+        */
+       if (nvfwname) {
+               snprintf(f, sizeof(f), "nvidia/%s/%s.bin", device->cname,
+                        nvfwname);
+               i = strlen(f);
+               while (i) {
+                       --i;
+                       f[i] = tolower(f[i]);
                }
+               ret = request_firmware_direct(&fw, f, nv_device_base(device));
+               if (!ret)
+                       goto found;
+       }
+
+       /* Nouveau firmware name provided - try to load it */
+       if (fwname) {
+               snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset,
+                        fwname);
+               ret = request_firmware_direct(&fw, f, nv_device_base(device));
+               if (!ret)
+                       goto found;
+
+               snprintf(f, sizeof(f), "nouveau/%s", fwname);
+               ret = request_firmware_direct(&fw, f, nv_device_base(device));
+               if (!ret)
+                       goto found;
        }
 
+       nv_error(priv, "failed to load %s / %s\n", fwname, nvfwname);
+       return ret;
+
+found:
        fuc->size = fw->size;
        fuc->data = kmemdup(fw->data, fuc->size, GFP_KERNEL);
        release_firmware(fw);
@@ -1615,10 +1651,10 @@ gf100_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
        if (use_ext_fw) {
                nv_info(priv, "using external firmware\n");
-               if (gf100_gr_ctor_fw(priv, "fuc409c", &priv->fuc409c) ||
-                   gf100_gr_ctor_fw(priv, "fuc409d", &priv->fuc409d) ||
-                   gf100_gr_ctor_fw(priv, "fuc41ac", &priv->fuc41ac) ||
-                   gf100_gr_ctor_fw(priv, "fuc41ad", &priv->fuc41ad))
+               if (gf100_gr_ctor_fw(priv, "fuc409c", "fecs_inst", &priv->fuc409c) ||
+                   gf100_gr_ctor_fw(priv, "fuc409d", "fecs_data", &priv->fuc409d) ||
+                   gf100_gr_ctor_fw(priv, "fuc41ac", "gpccs_inst", &priv->fuc41ac) ||
+                   gf100_gr_ctor_fw(priv, "fuc41ad", "gpccs_data", &priv->fuc41ad))
                        return -ENODEV;
                priv->firmware = true;
        }
--

2.4.3

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

#8 lore raw

Re: [PATCH 1/6] gr: support for NVIDIA-provided firmwares

In reply to a message not in the archive
Quoted 12 lines · Ben Skeggs
Quoted 3 lines · Alexandre Courbot

NVIDIA will officially start providing signed firmwares through linux-firmware. Change the GR firmware lookup function to look them up in addition to the extracted firmwares.

I wonder if perhaps we should just replace the mechanism entirely, and remove the support for nouveau/fuc* as we add "official" support for NVIDIA's ucode. The existing code is actually partially broken anyway, and mostly works by luck and was intended as a development aid / workaround anyway. There are no chipsets (aside from GM2xx...) which we don't currently support using our own ucode, so the impact of removing it will be very minimal.

Quoted 1 line

Thoughts?

I'm all for making things simpler, and if someone needs to use an external firmware for a Nouveau-supported GPU they can always put it under the nvidia/ firmware directory. So if you agree with it I will remove support for firmwares in nouveau/ in GR. I am not sure whether your statement also applies to other firmwares (falcon, xtensa)?
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#10 lore raw

Re: [PATCH 1/6] gr: support for NVIDIA-provided firmwares

In reply to a message not in the archive
Quoted 13 lines · Alexandre Courbot
Quoted 12 lines · Ben Skeggs
Quoted 3 lines · Alexandre Courbot

NVIDIA will officially start providing signed firmwares through linux-firmware. Change the GR firmware lookup function to look them up in addition to the extracted firmwares.

I wonder if perhaps we should just replace the mechanism entirely, and remove the support for nouveau/fuc* as we add "official" support for NVIDIA's ucode. The existing code is actually partially broken anyway, and mostly works by luck and was intended as a development aid / workaround anyway. There are no chipsets (aside from GM2xx...) which we don't currently support using our own ucode, so the impact of removing it will be very minimal.

Quoted 7 lines
Quoted 1 line

Thoughts?

I'm all for making things simpler, and if someone needs to use an external firmware for a Nouveau-supported GPU they can always put it under the nvidia/ firmware directory. So if you agree with it I will remove support for firmwares in nouveau/ in GR. I am not sure whether your statement also applies to other firmwares (falcon, xtensa)?

I'd say leave the non-gr engines for now, at least until we know what NVIDIA plans on doing with dGPU firmwares.
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau