AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Luben Tuikov <luben.tuikov@amd.com>,
	AMD Graphics <amd-gfx@lists.freedesktop.org>
Cc: "Alex Deucher" <Alexander.Deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH v4] drm/amdgpu: Fix size validation for non-exclusive domains (v4)
Date: Wed, 14 Dec 2022 10:52:45 +0100	[thread overview]
Message-ID: <e1ab3da2-377d-ad5f-d06d-353ce0f05b72@gmail.com> (raw)
In-Reply-To: <20221214094124.160353-1-luben.tuikov@amd.com>

Am 14.12.22 um 10:41 schrieb Luben Tuikov:
> Fix amdgpu_bo_validate_size() to check whether the TTM domain manager for the
> requested memory exists, else we get a kernel oops when dereferencing "man".
>
> v2: Make the patch standalone, i.e. not dependent on local patches.
> v3: Preserve old behaviour and just check that the manager pointer is not
>      NULL.
> v4: Complain if GTT domain requested and it is uninitialized--most likely a
>      bug.
>
> Cc: Alex Deucher <Alexander.Deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: AMD Graphics <amd-gfx@lists.freedesktop.org>
> Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>

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

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 20 +++++++++-----------
>   1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index fd3ab4b5e5bb1f..983a12cac329a7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -448,27 +448,25 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
>   
>   	/*
>   	 * If GTT is part of requested domains the check must succeed to
> -	 * allow fall back to GTT
> +	 * allow fall back to GTT.
>   	 */
>   	if (domain & AMDGPU_GEM_DOMAIN_GTT) {
>   		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   
> -		if (size < man->size)
> +		if (man && size < man->size)
>   			return true;
> -		else
> -			goto fail;
> -	}
> -
> -	if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
> +		else if (!man)
> +			pr_err_ratelimited("GTT domain requested but GTT mem manager uninitialized, for size: %lu\n",
> +					   size);
> +		goto fail;
> +	} else if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
>   		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   
> -		if (size < man->size)
> +		if (man && size < man->size)
>   			return true;
> -		else
> -			goto fail;
> +		goto fail;
>   	}
>   
> -
>   	/* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU */
>   	return true;
>   
>
> base-commit: 84abaa3a855571ebd4e57a7249b867a2fa3763da


      reply	other threads:[~2022-12-14  9:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14  9:41 [PATCH v4] drm/amdgpu: Fix size validation for non-exclusive domains (v4) Luben Tuikov
2022-12-14  9:52 ` Christian König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1ab3da2-377d-ad5f-d06d-353ce0f05b72@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=luben.tuikov@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox