[PATCH 02/20] drm/amdgpu: don't trample pdev drvdata

Christian König ckoenig.leichtzumerken at gmail.com
Mon May 13 11:54:54 UTC 2024


Am 10.05.24 um 20:12 schrieb Matthew Auld:
> The driver release callback is called when a particular drm_device goes
> away, just like with drmm, so here we should never nuke the pdev drvdata
> pointer, since that could already be pointing to a new drvdata.
> For example something hotunplugs the device, for which we have an open
> driver fd, keeping the drm_device alive, and in the meantime the same
> physical device is re-attached to a new drm_device therefore setting
> drvdata again. Once the original drm_device goes away, we might then
> call the release which then incorrectly tramples the drvdata.
>
> The driver core will already nuke the pointer for us when the pci device
> is removed, so should be safe to simply drop. Alternative would be to
> move to the driver pci remove callback.
>
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Cc: amd-gfx at lists.freedesktop.org

Oh! Very good catch! That might become important for a feature we 
current discuss internally.

Reviewed-by: Christian König <christian.koenig at amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index a0ea6fe8d060..d5fed007c698 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -1450,7 +1450,6 @@ void amdgpu_driver_release_kms(struct drm_device *dev)
>   	struct amdgpu_device *adev = drm_to_adev(dev);
>   
>   	amdgpu_device_fini_sw(adev);
> -	pci_set_drvdata(adev->pdev, NULL);
>   }
>   
>   /*



More information about the Intel-xe mailing list