[PATCH] drm/amdgpu: fix contiguous handling for IB parsing

Alex Deucher alexdeucher at gmail.com
Wed Jul 24 13:32:38 UTC 2024


On Wed, Jul 24, 2024 at 4:00 AM Christian König
<ckoenig.leichtzumerken at gmail.com> wrote:
>
> Otherwise we won't get correct access to the IB.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3501
Fixes: e362b7c8f8c7 ("drm/amdgpu: Modify the contiguous flags behaviour")

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

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index ec888fc6ead8..41055224930f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -1763,7 +1763,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
>         struct ttm_operation_ctx ctx = { false, false };
>         struct amdgpu_vm *vm = &fpriv->vm;
>         struct amdgpu_bo_va_mapping *mapping;
> -       int r;
> +       int i, r;
>
>         addr /= AMDGPU_GPU_PAGE_SIZE;
>
> @@ -1778,13 +1778,12 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
>         if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
>                 return -EINVAL;
>
> -       if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) {
> -               (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> -               amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
> -               r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
> -               if (r)
> -                       return r;
> -       }
> +       amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
> +       for (i = 0; i < (*bo)->placement.num_placement; i++)
> +               (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
> +       r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
> +       if (r)
> +               return r;
>
>         return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
>  }
> --
> 2.34.1
>


More information about the amd-gfx mailing list