[PATCH 1/4] drm/amdgpu: add helper to load ip_discovery binary from file

Wang, Yang(Kevin) KevinYang.Wang at amd.com
Mon Dec 6 11:41:09 UTC 2021


[AMD Official Use Only]

Hi Hawking,

A new function is defined in this patch, but it has not been used.
I am not sure whether this separate patch will generate a warning or whether it can be directly merged into patch-2 ?

and the "(u8 *)" is not necessary for this case, discard or using (void *) is better for this case.
__visible void *memcpy(void *to, const void *from, size_t n)

thanks.

Best Regards,
Kevin

________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Hawking Zhang <Hawking.Zhang at amd.com>
Sent: Saturday, December 4, 2021 6:20 PM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Zhang, Hawking <Hawking.Zhang at amd.com>
Subject: [PATCH 1/4] drm/amdgpu: add helper to load ip_discovery binary from file

To be used when ip_discovery binary is not carried by vbios

Signed-off-by: Hawking Zhang <Hawking.Zhang at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 31 ++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 4e3669407518..8ec60f826c7e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -67,7 +67,8 @@
 #include "smuio_v11_0_6.h"
 #include "smuio_v13_0.h"

-MODULE_FIRMWARE("amdgpu/ip_discovery.bin");
+#define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
+MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);

 #define mmRCC_CONFIG_MEMSIZE    0xde3
 #define mmMM_INDEX              0x0
@@ -187,6 +188,34 @@ static int amdgpu_discovery_read_binary(struct amdgpu_device *adev, uint8_t *bin
         return 0;
 }

+static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
+{
+       const struct firmware *fw;
+       const char *fw_name;
+       int r;
+
+       switch (amdgpu_discovery) {
+       case 2:
+               fw_name = FIRMWARE_IP_DISCOVERY;
+               break;
+       default:
+               dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
+               return -EINVAL;
+       }
+
+       r = request_firmware(&fw, fw_name, adev->dev);
+       if (r) {
+               dev_err(adev->dev, "can't load firmware \"%s\"\n",
+                       fw_name);
+               return r;
+       }
+
+       memcpy((u8 *)binary, (u8 *)fw->data, adev->mman.discovery_tmr_size);
+       release_firmware(fw);
+
+       return 0;
+}
+
 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)
 {
         uint16_t checksum = 0;
--
2.17.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20211206/994ca396/attachment-0001.htm>


More information about the amd-gfx mailing list