<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">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi,</p>
<p><br>
</p>
<p>I wrote those changes back in March as part of a cleanup sweep. The idea being was that if some had failed the state of the driver would be unknown so it was cleaner to simply abort allocating any memory and set all of the pointers to NULL.</p>
<p><br>
</p>
<p>Generally speaking if you fail to kmalloc a few bytes you've got bigger problems to worry about than your audio not working ideally.</p>
<p><br>
</p>
<p>Tom</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<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 Alexandre Demers <alexandre.f.demers@gmail.com><br>
<b>Sent:</b> Friday, August 12, 2016 11:43<br>
<b>To:</b> Freedesktop - AMD-gfx<br>
<b>Cc:</b> Alexander Deucher<br>
<b>Subject:</b> radeon VS amdgpu: _afmt_init() behavior if kzalloc fails</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>While comparing radeon's radeon_afmt_init() to dce_vX_0_afmt_init() on the amdgpu's side, I saw that on the latter:</div>
<div>1- when kzalloc fails to allocate mem for all afmt, an ENOMEM is returned</div>
<div>2- all previously allocated afmt are freed</div>
<div><br>
</div>
<div>So on the amdgpu's side, it is an "all or none allocated" situation, while on the radeon's side, some afmt may be allocated and initialized.</div>
<div><br>
</div>
<div>Moreover, returning an ENOMEM prevents any other function calls in <span style="font-size:13.3333px; line-height:normal">dce_vX_0_</span><span style="font-size:13.3333px; line-height:normal">sw_init() on the amdgpu's side, while it continues on the radeon's
side.</span><br>
</div>
<div><span style="font-size:13.3333px; line-height:normal"><br>
</span></div>
<div><span style="font-size:13.3333px; line-height:normal">What is the expected behavior here? Should we rewind the memory allocation as it is done under amdgpu when we can't allocate memory for all afmt or is it OK to do as it is done on radeon? Should we
stop any remaining steps in radeon_modeset_init() if it fails (thus, returning a ENOMEM from radeon_afmt_init())?</span></div>
<div><span style="font-size:13.3333px; line-height:normal"><br>
</span></div>
<div><span style="font-size:13.3333px; line-height:normal">The patch is already ready if needed, I could send it later from home if the amdgpu's behavior is the one that we are looking for.</span></div>
<div><span style="font-size:13.3333px; line-height:normal"><br>
</span></div>
<div><span style="font-size:13.3333px; line-height:normal">Cheers,</span></div>
<div><span style="font-size:13.3333px; line-height:normal">Alexandre Demers</span></div>
</div>
</div>
</div>
</div>
</body>
</html>