Commit 475cf02b authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/core: support versioned firmware loading

We have a need for this now with updated SEC2 LS FW images that have an
incompatible interface from the previous version.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 8854eed1
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
#define __NVKM_FIRMWARE_H__ #define __NVKM_FIRMWARE_H__
#include <core/subdev.h> #include <core/subdev.h>
int nvkm_firmware_get_version(const struct nvkm_subdev *, const char *fwname,
int min_version, int max_version,
const struct firmware **);
int nvkm_firmware_get(const struct nvkm_subdev *, const char *fwname, int nvkm_firmware_get(const struct nvkm_subdev *, const char *fwname,
const struct firmware **fw); const struct firmware **);
void nvkm_firmware_put(const struct firmware *fw); void nvkm_firmware_put(const struct firmware *);
#endif #endif
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
* Firmware files released by NVIDIA will always follow this format. * Firmware files released by NVIDIA will always follow this format.
*/ */
int int
nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname, nvkm_firmware_get_version(const struct nvkm_subdev *subdev, const char *fwname,
const struct firmware **fw) int min_version, int max_version,
const struct firmware **fw)
{ {
struct nvkm_device *device = subdev->device; struct nvkm_device *device = subdev->device;
char f[64]; char f[64];
...@@ -49,8 +50,29 @@ nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname, ...@@ -49,8 +50,29 @@ nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname,
cname[i] = tolower(cname[i]); cname[i] = tolower(cname[i]);
} }
snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname); for (i = max_version; i >= min_version; i--) {
return request_firmware(fw, f, device->dev); if (i != 0)
snprintf(f, sizeof(f), "nvidia/%s/%s-%d.bin", cname, fwname, i);
else
snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname);
if (!firmware_request_nowarn(fw, f, device->dev)) {
nvkm_debug(subdev, "firmware \"%s\" loaded\n", f);
return i;
}
nvkm_debug(subdev, "firmware \"%s\" unavailable\n", f);
}
nvkm_error(subdev, "failed to load firmware \"%s\"", fwname);
return -ENOENT;
}
int
nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname,
const struct firmware **fw)
{
return nvkm_firmware_get_version(subdev, fwname, 0, 0, fw);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment