Skip to contentSkip to conversation

drm/imagination: Add GPU ID parsing and firmware loading

PATCH Superseded Sarah Walker 2 participants 2 messages Jul 14, 2023 – Jul 17, 2023

Subsystems (3)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 7/17 drm/imagination: Add GPU ID parsing and firmware loading

Read the GPU ID register at probe time and select the correct features/quirks/enhancements. Use the GPU ID to form the firmware file name and load the firmware.

The features/quirks/enhancements arrays are currently hardcoded in the driver for the supported GPUs. We are looking at moving this information to the firmware image.

Changes since v3:
- Use drm_dev_{enter,exit}

---
 drivers/gpu/drm/imagination/Makefile          |   1 +
 drivers/gpu/drm/imagination/pvr_device.c      | 331 ++++++++++-
 drivers/gpu/drm/imagination/pvr_device.h      | 220 ++++++++
 drivers/gpu/drm/imagination/pvr_device_info.c | 227 ++++++++
 drivers/gpu/drm/imagination/pvr_device_info.h | 135 +++++
 drivers/gpu/drm/imagination/pvr_drv.c         | 521 +++++++++++++++++-
 drivers/gpu/drm/imagination/pvr_drv.h         | 107 ++++
 drivers/gpu/drm/imagination/pvr_fw.h          |  20 +
 8 files changed, 1560 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/imagination/pvr_device_info.c
 create mode 100644 drivers/gpu/drm/imagination/pvr_device_info.h
 create mode 100644 drivers/gpu/drm/imagination/pvr_fw.h
drivers/gpu/drm/imagination/Makefile +1 -0
index 186f920d615b..d713b1280776 100644
@@ -5,6 +5,7 @@ subdir-ccflags-y := -I$(srctree)/$(src)
 
 powervr-y := \
 	pvr_device.o \
+	pvr_device_info.o \
 	pvr_drv.o \
 
 obj-$(CONFIG_DRM_POWERVR) += powervr.o
drivers/gpu/drm/imagination/pvr_device.c +330 -1

366 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_device.h +220 -0

269 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_device_info.c new file +227 -0

227 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_device_info.h new file +135 -0

135 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_drv.c +520 -1

545 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_drv.h +107 -0

111 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_fw.h new file +20 -0
new file mode 100644
index 000000000000..ba3bfd41867f
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+/* Copyright (c) 2022 Imagination Technologies Ltd. */
+
+#ifndef PVR_FW_H
+#define PVR_FW_H
+
+#include <linux/firmware.h>
+
+struct pvr_fw_device {
+	/** @firmware: Handle to the firmware loaded into the device. */
+	const struct firmware *firmware;
+
+	/*
+	 * @processor_type: FW processor type for this device. Must be one of
+	 *                  %PVR_FW_PROCESSOR_TYPE_*.
+	 */
+	u16 processor_type;
+};
+
+#endif /* PVR_FW_H */
Signature · 1 line
2.41.0
maintainer
#1 lore raw

drivers/gpu/drm/imagination/pvr_device.c static int pvr_device_clk_init(struct pvr_device *pvr_dev) · line 324

Quoted 10 lines · Sarah Walker
drivers/gpu/drm/imagination/pvr_device.c +10 -0
+/**
+ * pvr_device_gpu_fini() - GPU-specific deinitialization for a PowerVR device
+ * @pvr_dev: Target PowerVR device.
+ */
+static void
+pvr_device_gpu_fini(struct pvr_device *pvr_dev)
+{
+	release_firmware(pvr_dev->fw_dev.firmware);
+}
+

Since you call that function at remove time, I think you can register a devm action using devm_add_action_or_reset() to remove the need to call it explicitly (and probably the need to have pvr_device_fini() in the first place)

Maxime