From 385baa8eecd32fbd9e5611c41762c42c68ad55c9 Mon Sep 17 00:00:00 2001 From: shaochunk Date: Sun, 11 Jun 2023 23:21:53 +0800 Subject: [PATCH] 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 Change-Id: I6c3cadbabd3291d75ecacd8fbb0de80d23566494 (cherry picked from commit 92d0afc571fabbdc144fa25a18931d9250fd78bf) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2934925 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/os/linux/firmware.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/firmware.c b/drivers/gpu/nvgpu/os/linux/firmware.c index 1510e513a..b300eafeb 100644 --- a/drivers/gpu/nvgpu/os/linux/firmware.c +++ b/drivers/gpu/nvgpu/os/linux/firmware.c @@ -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 * 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 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. Add a check here to prevent crash in request_firmware */ @@ -76,7 +78,20 @@ struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g, if (!fw) return NULL; - linux_fw = do_request_firmware(dev, g->name, fw_name, flags); + /* 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); #ifdef CONFIG_TEGRA_GK20A /* TO BE REMOVED - Support loading from legacy SOC specific path. */