<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:11pt;color:#0078D7;margin:5pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
thanks Felix,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I will continue to optimize related codes in the future.</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);">
Best Regards,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Kevin</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> Kuehling, Felix <Felix.Kuehling@amd.com><br>
<b>Sent:</b> Wednesday, February 3, 2021 9:53 PM<br>
<b>To:</b> Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Li, Dennis <Dennis.Li@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: optimize list operation in amdgpu_xgmi</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Looks good to me. I see some more redundant code in that function, if<br>
you want to clean it up further:<br>
>         hive = kzalloc(sizeof(*hive), GFP_KERNEL);<br>
>         if (!hive) {<br>
>                 dev_err(adev->dev, "XGMI: allocation failed\n");<br>
>                 hive = NULL;<br>
No need to set hive to NULL. The condition above is only true if it's<br>
already NULL. Also you don't need to print error messages for<br>
out-of-memory errors, because kzalloc will be very noisy if it fails anyway.<br>
<br>
>                 goto pro_end;<br>
>         }<br>
<br>
Either way, this patch is:<br>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com><br>
<br>
Am 2021-02-03 um 4:42 a.m. schrieb Kevin Wang:<br>
> simplify the list opertion.<br>
><br>
> Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
> ---<br>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 10 ++++------<br>
>  1 file changed, 4 insertions(+), 6 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
> index 541ef6be390f..659b385b27b5 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
> @@ -324,7 +324,7 @@ static void amdgpu_xgmi_sysfs_rem_dev_info(struct amdgpu_device *adev,<br>
>  <br>
>  struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)<br>
>  {<br>
> -     struct amdgpu_hive_info *hive = NULL, *tmp = NULL;<br>
> +     struct amdgpu_hive_info *hive = NULL;<br>
>        int ret;<br>
>  <br>
>        if (!adev->gmc.xgmi.hive_id)<br>
> @@ -337,11 +337,9 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)<br>
>  <br>
>        mutex_lock(&xgmi_mutex);<br>
>  <br>
> -     if (!list_empty(&xgmi_hive_list)) {<br>
> -             list_for_each_entry_safe(hive, tmp, &xgmi_hive_list, node)  {<br>
> -                     if (hive->hive_id == adev->gmc.xgmi.hive_id)<br>
> -                             goto pro_end;<br>
> -             }<br>
> +     list_for_each_entry(hive, &xgmi_hive_list, node)  {<br>
> +             if (hive->hive_id == adev->gmc.xgmi.hive_id)<br>
> +                     goto pro_end;<br>
>        }<br>
>  <br>
>        hive = kzalloc(sizeof(*hive), GFP_KERNEL);<br>
</div>
</span></font></div>
</div>
</body>
</html>