[PATCH v3 5/7] drm/ivpu: Implement firmware parsing and booting
Jacek Lawrynowicz
jacek.lawrynowicz at linux.intel.com
Mon Nov 14 08:21:16 UTC 2022
Hi,
On 11/1/2022 11:08 AM, Thomas Zimmermann wrote:
> Hi
>
> Am 24.09.22 um 17:11 schrieb Jacek Lawrynowicz:
>> Read, parse and boot VPU firmware image.
>>
>> Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski at linux.intel.com>
>> Signed-off-by: Krystian Pradzynski <krystian.pradzynski at linux.intel.com>
>> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz at linux.intel.com>
>> ---
>> drivers/gpu/drm/ivpu/Makefile | 1 +
>> drivers/gpu/drm/ivpu/ivpu_drv.c | 122 +++++++-
>> drivers/gpu/drm/ivpu/ivpu_drv.h | 10 +
>> drivers/gpu/drm/ivpu/ivpu_fw.c | 422 ++++++++++++++++++++++++++++
>> drivers/gpu/drm/ivpu/ivpu_fw.h | 38 +++
>> drivers/gpu/drm/ivpu/ivpu_hw_mtl.c | 11 +
>> drivers/gpu/drm/ivpu/vpu_boot_api.h | 241 ++++++++++++++++
>> include/uapi/drm/ivpu_drm.h | 21 ++
>> 8 files changed, 865 insertions(+), 1 deletion(-)
>> create mode 100644 drivers/gpu/drm/ivpu/ivpu_fw.c
>> create mode 100644 drivers/gpu/drm/ivpu/ivpu_fw.h
>> create mode 100644 drivers/gpu/drm/ivpu/vpu_boot_api.h
>>
>> diff --git a/drivers/gpu/drm/ivpu/ivpu_fw.c b/drivers/gpu/drm/ivpu/ivpu_fw.c
>> new file mode 100644
>> index 000000000000..d55f13f2daed
>> --- /dev/null
>> +++ b/drivers/gpu/drm/ivpu/ivpu_fw.c
>> @@ -0,0 +1,422 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Copyright © 2020-2022 Intel Corporation
>> + */
>> +
>> +#include <linux/firmware.h>
>> +#include <linux/highmem.h>
>> +#include <linux/moduleparam.h>
>> +#include <linux/pci.h>
>> +
>> +#include "vpu_boot_api.h"
>> +#include "ivpu_drv.h"
>> +#include "ivpu_fw.h"
>> +#include "ivpu_gem.h"
>> +#include "ivpu_hw.h"
>> +#include "ivpu_ipc.h"
>> +
>> +#define FW_MAX_NAMES 3
>> +#define FW_GLOBAL_MEM_START (2ull * SZ_1G)
>> +#define FW_GLOBAL_MEM_END (3ull * SZ_1G)
>> +#define FW_SHARED_MEM_SIZE SZ_256M /* Must be aligned to FW_SHARED_MEM_ALIGNMENT */
>> +#define FW_SHARED_MEM_ALIGNMENT SZ_128K /* VPU MTRR limitation */
>> +#define FW_RUNTIME_MAX_SIZE SZ_512M
>> +#define FW_SHAVE_NN_MAX_SIZE SZ_2M
>> +#define FW_RUNTIME_MIN_ADDR (FW_GLOBAL_MEM_START)
>> +#define FW_RUNTIME_MAX_ADDR (FW_GLOBAL_MEM_END - FW_SHARED_MEM_SIZE)
>> +#define FW_VERSION_HEADER_SIZE SZ_4K
>> +#define FW_FILE_IMAGE_OFFSET (VPU_FW_HEADER_SIZE + FW_VERSION_HEADER_SIZE)
>> +
>> +#define WATCHDOG_MSS_REDIRECT 32
>> +#define WATCHDOG_NCE_REDIRECT 33
>> +
>> +#define ADDR_TO_L2_CACHE_CFG(addr) ((addr) >> 31)
>> +
>> +#define IVPU_FW_CHECK_API(vdev, fw_hdr, name) ivpu_fw_check_api(vdev, fw_hdr, #name, \
>> + VPU_##name##_API_VER_INDEX, \
>> + VPU_##name##_API_VER_MAJOR, \
>> + VPU_##name##_API_VER_MINOR)
>> +
>> +static char *ivpu_firmware;
>> +module_param_named_unsafe(firmware, ivpu_firmware, charp, 0644);
>> +MODULE_PARM_DESC(firmware, "VPU firmware binary in /lib/firmware/..");
>> +
>> +static int ivpu_fw_request(struct ivpu_device *vdev)
>> +{
>> + const char *fw_names[FW_MAX_NAMES] = {
>> + ivpu_firmware,
>> + "mtl_vpu.bin",
>> + "intel/vpu/mtl_vpu_v0.0.bin"
>> + };
>> + int ret = -ENOENT;
>> + int i;
>> +
>> + for (i = 0; i < FW_MAX_NAMES; i++) {
>
> Better remove the constant FW_MAX_NAMES entirely and use ARRAY_SIZE(fw_names) here.
OK
Regards,
Jacek
More information about the dri-devel
mailing list