Created
November 2, 2020 23:12
-
-
Save shantur/abf342ac48c84b6ebdc5bbee8d750eff to your computer and use it in GitHub Desktop.
ESXi Linux VM Amdgpu bios not found hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |
index 50dff69a0f6e..76b66284f631 100644 | |
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |
@@ -29,6 +29,7 @@ | |
#include "amdgpu.h" | |
#include "atom.h" | |
+#include <linux/firmware.h> | |
#include <linux/pci.h> | |
#include <linux/slab.h> | |
#include <linux/acpi.h> | |
@@ -121,6 +122,45 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) | |
return true; | |
} | |
+static bool amdgpu_read_bios_from_firmware(struct amdgpu_device *adev) | |
+{ | |
+ const uint8_t __iomem *bios; | |
+ resource_size_t size; | |
+ const struct firmware *fw = NULL; | |
+ char *err = NULL; | |
+ | |
+ request_firmware(&fw, "amdgpu/vbios.bin", adev->dev); | |
+ if (!fw) { | |
+ err = "firmware request returned NULL\n"; | |
+ goto out; | |
+ } | |
+ size = fw->size; | |
+ bios = fw->data; | |
+ | |
+ if (size == 0 || !bios) { | |
+ err = "firmware request returned zero sized or NULL data\n"; | |
+ goto out; | |
+ } | |
+ | |
+ if (bios[0] != 0x55 || bios[1] != 0xaa) { | |
+ err = "wrong signature on firmware\n"; | |
+ goto out; | |
+ } | |
+ adev->bios = kmalloc(size, GFP_KERNEL); | |
+ if (adev->bios == NULL) { | |
+ err = "failed to kmalloc() memory for firmware\n"; | |
+ goto out; | |
+ } | |
+ memcpy(adev->bios, bios, size); | |
+out: | |
+ if (err) | |
+ DRM_ERROR(err); | |
+ if (fw) | |
+ release_firmware(fw); | |
+ return !err; | |
+} | |
+ | |
+ | |
bool amdgpu_read_bios(struct amdgpu_device *adev) | |
{ | |
uint8_t __iomem *bios; | |
@@ -433,6 +473,9 @@ bool amdgpu_get_bios(struct amdgpu_device *adev) | |
if (amdgpu_read_platform_bios(adev)) | |
goto success; | |
+ if (amdgpu_read_bios_from_firmware(adev)) | |
+ goto success; | |
+ | |
DRM_ERROR("Unable to locate a BIOS ROM\n"); | |
return false; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment