From: "Christian König" <christian.koenig@amd.com>
To: "Ma, Jun" <majun@amd.com>, Ma Jun <Jun.Ma2@amd.com>,
amd-gfx@lists.freedesktop.org, Alexander.Deucher@amd.com
Subject: Re: [PATCH] drm/amd: Simplify the size check funciton
Date: Mon, 28 Aug 2023 08:00:35 +0200 [thread overview]
Message-ID: <aaff221e-d61e-f2b0-bbff-c8208e067ca6@amd.com> (raw)
In-Reply-To: <b3df28b7-286b-7e5d-f6a3-ab144846247d@amd.com>
Am 28.08.23 um 07:09 schrieb Ma, Jun:
> Hi Christian,
>
> On 8/25/2023 4:08 PM, Christian König wrote:
>>
>> Am 25.08.23 um 07:22 schrieb Ma Jun:
>>> Simplify the code logic of size check function amdgpu_bo_validate_size
>>>
>>> Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 28 +++++++++-------------
>>> 1 file changed, 11 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> index 807ea74ece25..4c95db954a76 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> @@ -480,7 +480,7 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
>>> *cpu_addr = NULL;
>>> }
>>>
>>> -/* Validate bo size is bit bigger then the request domain */
>>> +/* Validate bo size is bit bigger than the request domain */
>>> static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
>>> unsigned long size, u32 domain)
>>> {
>>> @@ -490,29 +490,23 @@ 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.
>>> */
>>> - if (domain & AMDGPU_GEM_DOMAIN_GTT) {
>>> + if (domain & AMDGPU_GEM_DOMAIN_GTT)
>>> man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>>> -
>>> - if (man && size < man->size)
>>> - return true;
>>> - else if (!man)
>>> - WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
>>> - goto fail;
>>> - } else if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
>>> + else if (domain & AMDGPU_GEM_DOMAIN_VRAM)
>>> man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>>> + else
>>> + return true;
>>>
>>> - if (man && size < man->size)
>>> - return true;
>>> - goto fail;
>>> + if (!man) {
>>> + WARN_ON_ONCE("Mem mananger of mem domain %d is uninitialized", domain);
>>> + return false;
>>> }
>> That change here is not correct. It's perfectly valid for userspace to
>> request VRAM even if VRAM isn't initialized.
>>
>> Only the GTT manager is mandatory. That's why the code previously looked
>> like it does.
>>
> Thanks for your explanation.
> How about changing the code to the following?
>
> + if (!man) {
> + if (domain & AMDGPU_GEM_DOMAIN_GTT)
> + WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
> + return false;
> }
Of hand that looks like it should work, but I need to see the full patch.
Regards,
Christian.
>
> Regards,
> Ma Jun
>
>> regards,
>> Christian.
>>
>>>
>>> /* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU, _DOMAIN_DOORBELL */
>>> - return true;
>>> + if (size < man->size)
>>> + return true;
>>>
>>> -fail:
>>> - if (man)
>>> - DRM_DEBUG("BO size %lu > total memory in domain: %llu\n", size,
>>> - man->size);
>>> + DRM_DEBUG("BO size %lu > total memory in domain: %llu\n", size, man->size);
>>> return false;
>>> }
>>>
next prev parent reply other threads:[~2023-08-28 6:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 5:22 [PATCH] drm/amd: Simplify the size check funciton Ma Jun
2023-08-25 8:08 ` Christian König
2023-08-28 5:09 ` Ma, Jun
2023-08-28 6:00 ` Christian König [this message]
2023-08-28 8:33 ` Ma, Jun
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=aaff221e-d61e-f2b0-bbff-c8208e067ca6@amd.com \
--to=christian.koenig@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Jun.Ma2@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=majun@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.