[Intel-xe] [PATCH 1/2] drm/xe: Call drmm_add_action_or_reset() early in xe_device_create()

Rodrigo Vivi rodrigo.vivi at kernel.org
Fri May 19 14:51:28 UTC 2023


On Thu, May 18, 2023 at 06:56:50PM -0300, Gustavo Sousa wrote:
> Otherwise no cleanup is actually done if we branch to err_put.
> 
> This works for now: currently we do know that, once inside
> xe_device_destroy(), ttm_device_init() was successful so we can safely
> call ttm_device_fini(); and, for xe->ordered_wq, there is an upcoming
> commit to check its value before calling destroy_workqueue().
> 
> However, we might need change this in the future if we have more
> initializers called that can fail in a way that we can not know which
> one was it once inside xe_device_destroy().
> 
> Signed-off-by: Gustavo Sousa <gustavo.sousa at intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_device.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index f7f6a6a97757..4614bb791fb0 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -187,6 +187,10 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
>  	if (WARN_ON(err))
>  		goto err_put;
>  
> +	err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL);
> +	if (err)
> +		goto err_put;
> +
>  	xe->info.devid = pdev->device;
>  	xe->info.revid = pdev->revision;
>  	xe->info.enable_guc = enable_guc;
> @@ -212,10 +216,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
>  	if (WARN_ON(err))
>  		goto err_put;
>  
> -	err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL);
> -	if (err)
> -		goto err_put;
> -
>  	return xe;
>  
>  err_put:
> -- 
> 2.40.1
> 


More information about the Intel-xe mailing list