<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#008000;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Might be nice to apply this to where we free the vbios in amdgpu_device_fini_sw() as well. Either way:</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com></div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Sent:</b> Wednesday, February 5, 2025 6:38 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Zhang, Hawking <Hawking.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Subject:</b> [PATCH 1/4] drm/amdgpu: Add wrapper for freeing vbios memory</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Use bios_release wrapper to release memory allocated for vbios image and<br>
reset the variables.<br>
<br>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 20 ++++++++++++++------<br>
1 file changed, 14 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c<br>
index 423fd2eebe1e..a9b3f4702f6c 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c<br>
@@ -84,6 +84,13 @@ static bool check_atom_bios(struct amdgpu_device *adev, size_t size)<br>
return false;<br>
}<br>
<br>
+static inline void amdgpu_bios_release(struct amdgpu_device *adev)<br>
+{<br>
+ kfree(adev->bios);<br>
+ adev->bios = NULL;<br>
+ adev->bios_size = 0;<br>
+}<br>
+<br>
/* If you boot an IGP board with a discrete card as the primary,<br>
* the IGP rom is not accessible via the rom bar as the IGP rom is<br>
* part of the system bios. On boot, the system bios puts a<br>
@@ -121,7 +128,7 @@ static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev)<br>
iounmap(bios);<br>
<br>
if (!check_atom_bios(adev, size)) {<br>
- kfree(adev->bios);<br>
+ amdgpu_bios_release(adev);<br>
return false;<br>
}<br>
<br>
@@ -149,7 +156,7 @@ bool amdgpu_read_bios(struct amdgpu_device *adev)<br>
pci_unmap_rom(adev->pdev, bios);<br>
<br>
if (!check_atom_bios(adev, size)) {<br>
- kfree(adev->bios);<br>
+ amdgpu_bios_release(adev);<br>
return false;<br>
}<br>
<br>
@@ -189,7 +196,7 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)<br>
amdgpu_asic_read_bios_from_rom(adev, adev->bios, len);<br>
<br>
if (!check_atom_bios(adev, len)) {<br>
- kfree(adev->bios);<br>
+ amdgpu_bios_release(adev);<br>
return false;<br>
}<br>
<br>
@@ -225,7 +232,8 @@ static bool amdgpu_read_platform_bios(struct amdgpu_device *adev)<br>
<br>
return true;<br>
free_bios:<br>
- kfree(adev->bios);<br>
+ amdgpu_bios_release(adev);<br>
+<br>
return false;<br>
}<br>
<br>
@@ -327,7 +335,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)<br>
}<br>
<br>
if (!check_atom_bios(adev, size)) {<br>
- kfree(adev->bios);<br>
+ amdgpu_bios_release(adev);<br>
return false;<br>
}<br>
adev->bios_size = size;<br>
@@ -392,7 +400,7 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)<br>
GFP_KERNEL);<br>
<br>
if (!check_atom_bios(adev, vhdr->ImageLength)) {<br>
- kfree(adev->bios);<br>
+ amdgpu_bios_release(adev);<br>
return false;<br>
}<br>
adev->bios_size = vhdr->ImageLength;<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>