<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">Hi Hawking,</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<div><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">A new function is defined in this patch, but it has not been used.</span></div>
<div><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">I am not sure whether this separate patch will generate a warning or whether it can be directly merged into patch-2
?</span></div>
<div><br>
</div>
<div><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">and the "(u8 *)" is not necessary for this case, </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">discard
or using (void *) is better for this case.</span></div>
<div><i><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">__visible void *memcpy(void *to, const void *from, size_t n)</span><br>
</i><br>
</div>
<div><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">thanks.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">Best Regards,</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">Kevin</span></div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Hawking Zhang <Hawking.Zhang@amd.com><br>
<b>Sent:</b> Saturday, December 4, 2021 6:20 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> [PATCH 1/4] drm/amdgpu: add helper to load ip_discovery binary from file</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">To be used when ip_discovery binary is not carried by vbios<br>
<br>
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com><br>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 31 ++++++++++++++++++-<br>
1 file changed, 30 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c<br>
index 4e3669407518..8ec60f826c7e 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c<br>
@@ -67,7 +67,8 @@<br>
#include "smuio_v11_0_6.h"<br>
#include "smuio_v13_0.h"<br>
<br>
-MODULE_FIRMWARE("amdgpu/ip_discovery.bin");<br>
+#define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"<br>
+MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);<br>
<br>
#define mmRCC_CONFIG_MEMSIZE 0xde3<br>
#define mmMM_INDEX 0x0<br>
@@ -187,6 +188,34 @@ static int amdgpu_discovery_read_binary(struct amdgpu_device *adev, uint8_t *bin<br>
return 0;<br>
}<br>
<br>
+static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)<br>
+{<br>
+ const struct firmware *fw;<br>
+ const char *fw_name;<br>
+ int r;<br>
+<br>
+ switch (amdgpu_discovery) {<br>
+ case 2:<br>
+ fw_name = FIRMWARE_IP_DISCOVERY;<br>
+ break;<br>
+ default:<br>
+ dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");<br>
+ return -EINVAL;<br>
+ }<br>
+<br>
+ r = request_firmware(&fw, fw_name, adev->dev);<br>
+ if (r) {<br>
+ dev_err(adev->dev, "can't load firmware \"%s\"\n",<br>
+ fw_name);<br>
+ return r;<br>
+ }<br>
+<br>
+ memcpy((u8 *)binary, (u8 *)fw->data, adev->mman.discovery_tmr_size);<br>
+ release_firmware(fw);<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)<br>
{<br>
uint16_t checksum = 0;<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>