[PATCH libdrm 2/2] amdgpu: sanitize 64bit VA manager

Alex Deucher alexdeucher at gmail.com
Tue Nov 7 18:38:41 UTC 2017


On Sat, Nov 4, 2017 at 10:43 AM, Christian König
<ckoenig.leichtzumerken at gmail.com> wrote:
> Adding the extra reservation of the 32bit space to the 64bit manager is
> complete nonsense and just a waste of memory and CPU cycles.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>

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

> ---
>  amdgpu/amdgpu_device.c   | 24 ++++++------------------
>  amdgpu/amdgpu_internal.h |  7 -------
>  amdgpu/amdgpu_vamgr.c    |  4 ++--
>  3 files changed, 8 insertions(+), 27 deletions(-)
>
> diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
> index 2b31c45b..344e87ed 100644
> --- a/amdgpu/amdgpu_device.c
> +++ b/amdgpu/amdgpu_device.c
> @@ -270,22 +270,16 @@ int amdgpu_device_initialize(int fd,
>                 goto cleanup;
>         }
>
> -       amdgpu_vamgr_init(&dev->vamgr, dev->dev_info.virtual_address_offset,
> -                         dev->dev_info.virtual_address_max,
> -                         dev->dev_info.virtual_address_alignment);
> -
> +       start = dev->dev_info.virtual_address_offset;
>         max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff);
> -       start = amdgpu_vamgr_find_va(&dev->vamgr,
> -                                    max - dev->dev_info.virtual_address_offset,
> -                                    dev->dev_info.virtual_address_alignment, 0);
> -       if (start > 0xffffffff) {
> -               fprintf(stderr, "%s: amdgpu_vamgr_find_va failed\n", __func__);
> -               goto free_va; /* shouldn't get here */
> -       }
> -
>         amdgpu_vamgr_init(&dev->vamgr_32, start, max,
>                           dev->dev_info.virtual_address_alignment);
>
> +       start = MAX2(dev->dev_info.virtual_address_offset, 0x100000000ULL);
> +       max = MAX2(dev->dev_info.virtual_address_max, 0x100000000ULL);
> +       amdgpu_vamgr_init(&dev->vamgr, start, max,
> +                         dev->dev_info.virtual_address_alignment);
> +
>         r = amdgpu_parse_asic_ids(&dev->asic_ids);
>         if (r) {
>                 fprintf(stderr, "%s: Cannot parse ASIC IDs, 0x%x.",
> @@ -300,12 +294,6 @@ int amdgpu_device_initialize(int fd,
>
>         return 0;
>
> -free_va:
> -       r = -ENOMEM;
> -       amdgpu_vamgr_free_va(&dev->vamgr, start,
> -                            max - dev->dev_info.virtual_address_offset);
> -       amdgpu_vamgr_deinit(&dev->vamgr);
> -
>  cleanup:
>         if (dev->fd >= 0)
>                 close(dev->fd);
> diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
> index 56d15112..e26e5190 100644
> --- a/amdgpu/amdgpu_internal.h
> +++ b/amdgpu/amdgpu_internal.h
> @@ -148,13 +148,6 @@ drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
>
>  drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr);
>
> -drm_private uint64_t
> -amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
> -                    uint64_t alignment, uint64_t base_required);
> -
> -drm_private void
> -amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size);
> -
>  drm_private int amdgpu_parse_asic_ids(struct amdgpu_asic_id **asic_ids);
>
>  drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev);
> diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
> index 8516b594..ab425ef7 100644
> --- a/amdgpu/amdgpu_vamgr.c
> +++ b/amdgpu/amdgpu_vamgr.c
> @@ -66,7 +66,7 @@ drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr)
>         pthread_mutex_destroy(&mgr->bo_va_mutex);
>  }
>
> -drm_private uint64_t
> +static drm_private uint64_t
>  amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
>                      uint64_t alignment, uint64_t base_required)
>  {
> @@ -155,7 +155,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
>         return offset;
>  }
>
> -drm_private void
> +static drm_private void
>  amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size)
>  {
>         struct amdgpu_bo_va_hole *hole;
> --
> 2.11.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list