[PATCH 08/13] drm/amdgpu: move doorbell ptr into mman structure

Christian König christian.koenig at amd.com
Mon Feb 6 11:24:58 UTC 2023


Am 03.02.23 um 20:08 schrieb Shashank Sharma:
> From: Alex Deucher <alexander.deucher at amd.com>
>
> This patch:
> - moves the doorbell.ptr variable to mman structure
> - renames it to doorbell_aper_base_kaddr for better readability;
>
> This change is to make doorbell's ttm management similar to vram's.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Shashank Sharma <shashank.sharma at amd.com>

Yeah, that seems to make sense. Acked-by: Christian König 
<christian.koenig at amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   | 22 ++++++++++----------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h |  1 -
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h      |  1 +
>   3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 16580d9580d4..cda5387aae50 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -597,7 +597,7 @@ u32 amdgpu_mm_rdoorbell(struct amdgpu_device *adev, u32 index)
>   		return 0;
>   
>   	if (index < adev->doorbell.num_doorbells) {
> -		return readl(adev->doorbell.ptr + index);
> +		return readl(adev->mman.doorbell_aper_base_kaddr + index);
>   	} else {
>   		DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index);
>   		return 0;
> @@ -620,7 +620,7 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v)
>   		return;
>   
>   	if (index < adev->doorbell.num_doorbells) {
> -		writel(v, adev->doorbell.ptr + index);
> +		writel(v, adev->mman.doorbell_aper_base_kaddr + index);
>   	} else {
>   		DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
>   	}
> @@ -641,7 +641,7 @@ u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index)
>   		return 0;
>   
>   	if (index < adev->doorbell.num_doorbells) {
> -		return atomic64_read((atomic64_t *)(adev->doorbell.ptr + index));
> +		return atomic64_read((atomic64_t *)(adev->mman.doorbell_aper_base_kaddr + index));
>   	} else {
>   		DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index);
>   		return 0;
> @@ -664,7 +664,7 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
>   		return;
>   
>   	if (index < adev->doorbell.num_doorbells) {
> -		atomic64_set((atomic64_t *)(adev->doorbell.ptr + index), v);
> +		atomic64_set((atomic64_t *)(adev->mman.doorbell_aper_base_kaddr + index), v);
>   	} else {
>   		DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
>   	}
> @@ -1038,7 +1038,7 @@ static int amdgpu_device_doorbell_init(struct amdgpu_device *adev)
>   		adev->gmc.doorbell_aper_base = 0;
>   		adev->gmc.doorbell_aper_size = 0;
>   		adev->doorbell.num_doorbells = 0;
> -		adev->doorbell.ptr = NULL;
> +		adev->mman.doorbell_aper_base_kaddr = NULL;
>   		return 0;
>   	}
>   
> @@ -1071,10 +1071,10 @@ static int amdgpu_device_doorbell_init(struct amdgpu_device *adev)
>   			adev->doorbell.num_doorbells += 0x400;
>   	}
>   
> -	adev->doorbell.ptr = ioremap(adev->gmc.doorbell_aper_base,
> -				     adev->doorbell.num_doorbells *
> -				     sizeof(u32));
> -	if (adev->doorbell.ptr == NULL)
> +	adev->mman.doorbell_aper_base_kaddr = ioremap(adev->gmc.doorbell_aper_base,
> +						      adev->doorbell.num_doorbells *
> +						      sizeof(u32));
> +	if (adev->mman.doorbell_aper_base_kaddr == NULL)
>   		return -ENOMEM;
>   
>   	return 0;
> @@ -1089,8 +1089,8 @@ static int amdgpu_device_doorbell_init(struct amdgpu_device *adev)
>    */
>   static void amdgpu_device_doorbell_fini(struct amdgpu_device *adev)
>   {
> -	iounmap(adev->doorbell.ptr);
> -	adev->doorbell.ptr = NULL;
> +	iounmap(adev->mman.doorbell_aper_base_kaddr);
> +	adev->mman.doorbell_aper_base_kaddr = NULL;
>   }
>   
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> index c6324970eb79..464be28da4fb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> @@ -25,7 +25,6 @@
>    * GPU doorbell structures, functions & helpers
>    */
>   struct amdgpu_doorbell {
> -	u32 __iomem		*ptr;
>   	u32			num_doorbells;	/* Number of doorbells actually reserved for amdgpu. */
>   };
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> index ea53aae3ee0b..243deb1ffc54 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> @@ -52,6 +52,7 @@ struct amdgpu_mman {
>   	struct ttm_device		bdev;
>   	bool				initialized;
>   	void __iomem			*vram_aper_base_kaddr;
> +	u32 __iomem			*doorbell_aper_base_kaddr;
>   
>   	/* buffer handling */
>   	const struct amdgpu_buffer_funcs	*buffer_funcs;



More information about the amd-gfx mailing list