summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/nvgpu_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/nvgpu_common.c')
-rw-r--r--drivers/gpu/nvgpu/nvgpu_common.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/nvgpu_common.c b/drivers/gpu/nvgpu/nvgpu_common.c
index bdc07e50..fac818a2 100644
--- a/drivers/gpu/nvgpu/nvgpu_common.c
+++ b/drivers/gpu/nvgpu/nvgpu_common.c
@@ -15,9 +15,11 @@
15 */ 15 */
16 16
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/firmware.h>
18 19
19#include "gk20a/gk20a_scale.h" 20#include "gk20a/gk20a_scale.h"
20#include "gk20a/gk20a.h" 21#include "gk20a/gk20a.h"
22#include "nvgpu_common.h"
21 23
22#define EMC3D_DEFAULT_RATIO 750 24#define EMC3D_DEFAULT_RATIO 750
23 25
@@ -152,3 +154,68 @@ int nvgpu_probe(struct gk20a *g,
152 154
153 return 0; 155 return 0;
154} 156}
157
158static const struct firmware *do_request_firmware(struct device *dev,
159 const char *prefix, const char *fw_name, int flags)
160{
161 const struct firmware *fw;
162 char *fw_path = NULL;
163 int path_len, err;
164
165 if (prefix) {
166 path_len = strlen(prefix) + strlen(fw_name);
167 path_len += 2; /* for the path separator and zero terminator*/
168
169 fw_path = kzalloc(sizeof(*fw_path) * path_len, GFP_KERNEL);
170 if (!fw_path)
171 return NULL;
172
173 sprintf(fw_path, "%s/%s", prefix, fw_name);
174 fw_name = fw_path;
175 }
176
177#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
178 err = request_firmware(&fw, fw_name, dev);
179#else
180 if (flags & NVGPU_REQUEST_FIRMWARE_NO_WARN)
181 err = request_firmware_direct(&fw, fw_name, dev);
182 else
183 err = request_firmware(&fw, fw_name, dev);
184#endif
185
186 kfree(fw_path);
187 if (err)
188 return NULL;
189 return fw;
190}
191
192/* This is a simple wrapper around request_firmware that takes 'fw_name' and
193 * applies an IP specific relative path prefix to it. The caller is
194 * responsible for calling release_firmware later. */
195const struct firmware *nvgpu_request_firmware(struct gk20a *g,
196 const char *fw_name,
197 int flags)
198{
199 struct device *dev = g->dev;
200 const struct firmware *fw;
201
202 /* current->fs is NULL when calling from SYS_EXIT.
203 Add a check here to prevent crash in request_firmware */
204 if (!current->fs || !fw_name)
205 return NULL;
206
207 BUG_ON(!g->ops.name);
208 fw = do_request_firmware(dev, g->ops.name, fw_name, flags);
209
210#ifdef CONFIG_TEGRA_GK20A
211 /* TO BE REMOVED - Support loading from legacy SOC specific path. */
212 if (!fw && !(flags & NVGPU_REQUEST_FIRMWARE_NO_SOC)) {
213 struct gk20a_platform *platform = gk20a_get_platform(dev);
214 fw = do_request_firmware(dev,
215 platform->soc_name, fw_name, flags);
216 }
217#endif
218
219 return fw;
220}
221