[PATCH 01/16] drm/amdgpu: rename num_doorbells

Alex Deucher alexdeucher at gmail.com
Thu Mar 30 14:19:45 UTC 2023


On Wed, Mar 29, 2023 at 11:48 AM Shashank Sharma
<shashank.sharma at amd.com> wrote:
>
> From: Shashank Sharma <contactshashanksharma at gmail.com>
>
> Rename doorbell.num_doorbells to doorbell.num_kernel_doorbells to
> make it more readable.
>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: Christian Koenig <christian.koenig at amd.com>
> Signed-off-by: Shashank Sharma <shashank.sharma at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c   |  6 +++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   | 22 ++++++++++----------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h |  4 +++-
>  3 files changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index f99d4873bf22..0385f7f69278 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -96,7 +96,7 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev,
>                                          size_t *start_offset)
>  {
>         /*
> -        * The first num_doorbells are used by amdgpu.
> +        * The first num_kernel_doorbells are used by amdgpu.
>          * amdkfd takes whatever's left in the aperture.
>          */
>         if (adev->enable_mes) {
> @@ -109,11 +109,11 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev,
>                 *aperture_base = adev->doorbell.base;
>                 *aperture_size = 0;
>                 *start_offset = 0;
> -       } else if (adev->doorbell.size > adev->doorbell.num_doorbells *
> +       } else if (adev->doorbell.size > adev->doorbell.num_kernel_doorbells *
>                                                 sizeof(u32)) {
>                 *aperture_base = adev->doorbell.base;
>                 *aperture_size = adev->doorbell.size;
> -               *start_offset = adev->doorbell.num_doorbells * sizeof(u32);
> +               *start_offset = adev->doorbell.num_kernel_doorbells * sizeof(u32);
>         } else {
>                 *aperture_base = 0;
>                 *aperture_size = 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index afe6af9c0138..57ee1c4a81e9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -593,7 +593,7 @@ u32 amdgpu_mm_rdoorbell(struct amdgpu_device *adev, u32 index)
>         if (amdgpu_device_skip_hw_access(adev))
>                 return 0;
>
> -       if (index < adev->doorbell.num_doorbells) {
> +       if (index < adev->doorbell.num_kernel_doorbells) {
>                 return readl(adev->doorbell.ptr + index);
>         } else {
>                 DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index);
> @@ -616,7 +616,7 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v)
>         if (amdgpu_device_skip_hw_access(adev))
>                 return;
>
> -       if (index < adev->doorbell.num_doorbells) {
> +       if (index < adev->doorbell.num_kernel_doorbells) {
>                 writel(v, adev->doorbell.ptr + index);
>         } else {
>                 DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
> @@ -637,7 +637,7 @@ u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index)
>         if (amdgpu_device_skip_hw_access(adev))
>                 return 0;
>
> -       if (index < adev->doorbell.num_doorbells) {
> +       if (index < adev->doorbell.num_kernel_doorbells) {
>                 return atomic64_read((atomic64_t *)(adev->doorbell.ptr + index));
>         } else {
>                 DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index);
> @@ -660,7 +660,7 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
>         if (amdgpu_device_skip_hw_access(adev))
>                 return;
>
> -       if (index < adev->doorbell.num_doorbells) {
> +       if (index < adev->doorbell.num_kernel_doorbells) {
>                 atomic64_set((atomic64_t *)(adev->doorbell.ptr + index), v);
>         } else {
>                 DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
> @@ -1034,7 +1034,7 @@ static int amdgpu_device_doorbell_init(struct amdgpu_device *adev)
>         if (adev->asic_type < CHIP_BONAIRE) {
>                 adev->doorbell.base = 0;
>                 adev->doorbell.size = 0;
> -               adev->doorbell.num_doorbells = 0;
> +               adev->doorbell.num_kernel_doorbells = 0;
>                 adev->doorbell.ptr = NULL;
>                 return 0;
>         }
> @@ -1049,27 +1049,27 @@ static int amdgpu_device_doorbell_init(struct amdgpu_device *adev)
>         adev->doorbell.size = pci_resource_len(adev->pdev, 2);
>
>         if (adev->enable_mes) {
> -               adev->doorbell.num_doorbells =
> +               adev->doorbell.num_kernel_doorbells =
>                         adev->doorbell.size / sizeof(u32);
>         } else {
> -               adev->doorbell.num_doorbells =
> +               adev->doorbell.num_kernel_doorbells =
>                         min_t(u32, adev->doorbell.size / sizeof(u32),
>                               adev->doorbell_index.max_assignment+1);
> -               if (adev->doorbell.num_doorbells == 0)
> +               if (adev->doorbell.num_kernel_doorbells == 0)
>                         return -EINVAL;
>
>                 /* For Vega, reserve and map two pages on doorbell BAR since SDMA
>                  * paging queue doorbell use the second page. The
>                  * AMDGPU_DOORBELL64_MAX_ASSIGNMENT definition assumes all the
>                  * doorbells are in the first page. So with paging queue enabled,
> -                * the max num_doorbells should + 1 page (0x400 in dword)
> +                * the max num_kernel_doorbells should + 1 page (0x400 in dword)
>                  */
>                 if (adev->asic_type >= CHIP_VEGA10)
> -                       adev->doorbell.num_doorbells += 0x400;
> +                       adev->doorbell.num_kernel_doorbells += 0x400;
>         }
>
>         adev->doorbell.ptr = ioremap(adev->doorbell.base,
> -                                    adev->doorbell.num_doorbells *
> +                                    adev->doorbell.num_kernel_doorbells *
>                                      sizeof(u32));
>         if (adev->doorbell.ptr == NULL)
>                 return -ENOMEM;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> index 7199b6b0be81..12263986f889 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> @@ -29,7 +29,9 @@ struct amdgpu_doorbell {
>         resource_size_t         base;
>         resource_size_t         size;
>         u32 __iomem             *ptr;
> -       u32                     num_doorbells;  /* Number of doorbells actually reserved for amdgpu. */
> +
> +       /* Number of doorbells reserved for amdgpu kernel driver */
> +       u32 num_kernel_doorbells;
>  };
>
>  /* Reserved doorbells for amdgpu (including multimedia).
> --
> 2.40.0
>


More information about the amd-gfx mailing list