[Nouveau] [PATCH v4 28/33] secboot: support for loading LS PMU firmware

Alexandre Courbot acourbot at nvidia.com
Mon Nov 21 08:29:25 UTC 2016


Allow secboot to load a LS PMU firmware.

Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>
---
 drm/nouveau/nvkm/subdev/secboot/Kbuild         |  1 +-
 drm/nouveau/nvkm/subdev/secboot/ls_ucode.h     |  4 +-
 drm/nouveau/nvkm/subdev/secboot/ls_ucode_pmu.c | 89 +++++++++++++++++++-
 3 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100644 drm/nouveau/nvkm/subdev/secboot/ls_ucode_pmu.c

diff --git a/drm/nouveau/nvkm/subdev/secboot/Kbuild b/drm/nouveau/nvkm/subdev/secboot/Kbuild
index 5076d1500f47..094b6801f9e8 100644
--- a/drm/nouveau/nvkm/subdev/secboot/Kbuild
+++ b/drm/nouveau/nvkm/subdev/secboot/Kbuild
@@ -1,5 +1,6 @@
 nvkm-y += nvkm/subdev/secboot/base.o
 nvkm-y += nvkm/subdev/secboot/ls_ucode_gr.o
+nvkm-y += nvkm/subdev/secboot/ls_ucode_pmu.o
 nvkm-y += nvkm/subdev/secboot/acr.o
 nvkm-y += nvkm/subdev/secboot/acr_r352.o
 nvkm-y += nvkm/subdev/secboot/acr_r361.o
diff --git a/drm/nouveau/nvkm/subdev/secboot/ls_ucode.h b/drm/nouveau/nvkm/subdev/secboot/ls_ucode.h
index 7f4292f740b5..381f07b1216c 100644
--- a/drm/nouveau/nvkm/subdev/secboot/ls_ucode.h
+++ b/drm/nouveau/nvkm/subdev/secboot/ls_ucode.h
@@ -27,6 +27,7 @@
 #include <core/falcon.h>
 #include <core/subdev.h>
 
+struct nvkm_acr;
 
 /**
  * struct ls_ucode_img_desc - descriptor of firmware image
@@ -146,6 +147,7 @@ struct fw_bl_desc {
 
 int acr_ls_ucode_load_fecs(const struct nvkm_subdev *, struct ls_ucode_img *);
 int acr_ls_ucode_load_gpccs(const struct nvkm_subdev *, struct ls_ucode_img *);
-
+int acr_ls_ucode_load_pmu(const struct nvkm_subdev *, struct ls_ucode_img *);
+void acr_ls_pmu_post_run(const struct nvkm_acr *, const struct nvkm_secboot *);
 
 #endif
diff --git a/drm/nouveau/nvkm/subdev/secboot/ls_ucode_pmu.c b/drm/nouveau/nvkm/subdev/secboot/ls_ucode_pmu.c
new file mode 100644
index 000000000000..94605ac27341
--- /dev/null
+++ b/drm/nouveau/nvkm/subdev/secboot/ls_ucode_pmu.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016, 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 "ls_ucode.h"
+#include "acr.h"
+
+#include <core/firmware.h>
+#include <subdev/pmu.h>
+
+/**
+ * ls_ucode_img_load_pmu - load and prepare a LS ucode img for PMU falcon
+ *
+ * Load the PMU LS microcode, desc and signature and pack them into a single
+ * blob.
+ */
+int
+acr_ls_ucode_load_pmu(const struct nvkm_subdev *subdev,
+		      struct ls_ucode_img *img)
+{
+	const struct firmware *pmu_fw, *pmu_desc, *sig;
+	struct nvkm_pmu *pmu = subdev->device->pmu;
+	int ret;
+
+	ret = nvkm_firmware_get(subdev->device, "pmu/image", &pmu_fw);
+	if (ret)
+		return ret;
+	img->ucode_data = kmemdup(pmu_fw->data, pmu_fw->size, GFP_KERNEL);
+	nvkm_firmware_put(pmu_fw);
+	if (!img->ucode_data)
+		return -ENOMEM;
+
+	ret = nvkm_firmware_get(subdev->device, "pmu/desc", &pmu_desc);
+	if (ret)
+		return ret;
+	memcpy(&img->ucode_desc, pmu_desc->data, sizeof(img->ucode_desc));
+	img->ucode_size = img->ucode_desc.image_size;
+	nvkm_firmware_put(pmu_desc);
+
+	ret = nvkm_firmware_get(subdev->device, "pmu/sig", &sig);
+	if (ret)
+		return ret;
+	img->sig_size = sig->size;
+	img->sig = kmemdup(sig->data, sig->size, GFP_KERNEL);
+	nvkm_firmware_put(sig);
+	if (!img->sig)
+		return -ENOMEM;
+
+	ret = nvkm_pmu_set_version(pmu, img->ucode_desc.app_version);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+void
+acr_ls_pmu_post_run(const struct nvkm_acr *acr, const struct nvkm_secboot *sb)
+{
+	struct nvkm_device *device = sb->subdev.device;
+	struct nvkm_pmu *pmu = device->pmu;
+	u32 cmdline_size = nvkm_pmu_cmdline_size(pmu);
+	u8 buf[cmdline_size];
+	u32 addr_args = acr->dmem_size - cmdline_size;
+
+	if (cmdline_size == 0)
+		return;
+
+	nvkm_pmu_write_cmdline(pmu, buf);
+	nvkm_falcon_load_dmem(device, sb->base, buf, addr_args, cmdline_size);
+}
-- 
git-series 0.8.10


More information about the Nouveau mailing list