gpu: nvgpu: Search GPU FW in /lib/firmware/nvidia

In order to conform upstream path, we migrated GPU
firmwares to /lib/firmware/nvidia* for l4t.

Search the GPU fw from both /lib/firmware/nvidia/*
and /lib/firmware/*.

Bug 2975694

Signed-off-by: shaochunk <shaochunk@nvidia.com>
Change-Id: I6c3cadbabd3291d75ecacd8fbb0de80d23566494
(cherry picked from commit 92d0afc571fabbdc144fa25a18931d9250fd78bf)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2934925
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
This commit is contained in:
shaochunk
2023-06-11 23:21:53 +08:00
committed by mobile promotions
parent 8fea295e97
commit 385baa8eec

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -65,7 +65,9 @@ struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g,
{ {
struct device *dev = dev_from_gk20a(g); struct device *dev = dev_from_gk20a(g);
struct nvgpu_firmware *fw; struct nvgpu_firmware *fw;
const struct firmware *linux_fw; const struct firmware *linux_fw = NULL;
char *prefix_path = NULL;
int prefix_len = 0;
/* current->fs is NULL when calling from SYS_EXIT. /* current->fs is NULL when calling from SYS_EXIT.
Add a check here to prevent crash in request_firmware */ Add a check here to prevent crash in request_firmware */
@@ -76,6 +78,19 @@ struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g,
if (!fw) if (!fw)
return NULL; return NULL;
/* Search GPU firmware under /lib/firmware/nvidia */
prefix_len = strlen("nvidia") + strlen(g->name);
prefix_len += 2; /* for the path separator and zero terminator */
prefix_path = nvgpu_kzalloc(g, sizeof(*prefix_path) * prefix_len);
if (prefix_path) {
(void) snprintf(prefix_path, prefix_len,
"%s/%s", "nvidia", g->name);
linux_fw = do_request_firmware(dev,
prefix_path, fw_name, NVGPU_REQUEST_FIRMWARE_NO_WARN);
nvgpu_kfree(g, prefix_path);
}
if (!linux_fw)
linux_fw = do_request_firmware(dev, g->name, fw_name, flags); linux_fw = do_request_firmware(dev, g->name, fw_name, flags);
#ifdef CONFIG_TEGRA_GK20A #ifdef CONFIG_TEGRA_GK20A