[PATCH] drm/amdkfd: Release the topology_lock in error case

Felix Kuehling felix.kuehling at amd.com
Wed Nov 16 20:49:18 UTC 2022


Am 2022-11-16 um 03:04 schrieb Ma Jun:
> Release the topology_lock in error case
>
> Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
> Reported-by: Dan Carpenter <error27 at gmail.com>
Dan, did you change your email address, is this one correct?

Ma Jun, thanks for looking into this. Some of this problem predates your 
patch that was flagged by Dan. I would prefer a more consistent and 
robust handling of these error cases. I think everything inside the 
topology lock could be moved into another function to simplify the error 
handling. I'm attaching a completely untested patch to illustrate the idea.

Regards,
   Felix


> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index ef9c6fdfb88d..5ea737337658 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -1841,6 +1841,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
>   			pr_err("Error creating VCRAT for GPU (ID: 0x%x)\n",
>   			       gpu_id);
>   			topology_crat_proximity_domain--;
> +			up_write(&topology_lock);
>   			return res;
>   		}
>   
> @@ -1851,6 +1852,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
>   			pr_err("Error parsing VCRAT for GPU (ID: 0x%x)\n",
>   			       gpu_id);
>   			topology_crat_proximity_domain--;
> +			up_write(&topology_lock);
>   			goto err;
>   		}
>   
> @@ -1860,6 +1862,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
>   		dev = kfd_assign_gpu(gpu);
>   		if (WARN_ON(!dev)) {
>   			res = -ENODEV;
> +			up_write(&topology_lock);
>   			goto err;
>   		}
>   
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-drm-amdkfd-Release-the-topology_lock-in-error-case.patch
Type: text/x-patch
Size: 4282 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20221116/f417e1e0/attachment-0001.bin>


More information about the amd-gfx mailing list