All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philip Yang <yangp@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	"Philip Yang" <Philip.Yang@amd.com>,
	amd-gfx@lists.freedesktop.org
Cc: Felix.Kuehling@amd.com, david.yatsin@amd.com,
	pierre-eric.pelloux-prayer@amd.com, kent.russell@amd.com
Subject: Re: [PATCH v5 5/6] drm/amdgpu: Add helper to alloc GART entries
Date: Mon, 15 Dec 2025 10:50:41 -0500	[thread overview]
Message-ID: <65a58cd1-27e5-4c09-8802-a58a456fde77@amd.com> (raw)
In-Reply-To: <ee2f2f81-6b5f-4b87-bea1-e3ade42ec772@amd.com>



On 2025-12-15 10:14, Christian König wrote:
> On 12/10/25 00:43, Philip Yang wrote:
>> Add helper amdgpu_gtt_mgr_alloc/free_entries, export the configurable drm_mm
>> allocator parameters to caller.
>>
>> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 27 +++++++++++++++++++++
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  7 ++++++
>>   2 files changed, 34 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> index 895c1e4c6747..d21c7187e4aa 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> @@ -321,3 +321,30 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>>   	ttm_resource_manager_cleanup(man);
>>   	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
>>   }
>> +
>> +int amdgpu_gtt_mgr_alloc_entries(struct amdgpu_gtt_mgr *mgr,
>> +				 struct drm_mm_node *node,
>> +				 u64 num_pages, u64 alignment,
>> +				 unsigned long color,
>> +				 enum drm_mm_insert_mode mode)
> The color is unused as far as I remember and the insert mode should be hardcoded, at least I don't see a good reason to expose that.
>
> Any specific reason that was added here?
The color parameter removed in next version, Eric pointed out same 
issue, the new alloc color is hardcoded inside alloc_entries.

Thanks,
Philip
>
> Regards,
> Christian.
>
>> +{
>> +	struct amdgpu_device *adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
>> +	int r;
>> +
>> +	spin_lock(&mgr->lock);
>> +	r = drm_mm_insert_node_in_range(&mgr->mm, node, num_pages,
>> +					alignment, color, 0,
>> +					adev->gmc.gart_size >> PAGE_SHIFT,
>> +					mode);
>> +	spin_unlock(&mgr->lock);
>> +	return r;
>> +}
>> +
>> +void amdgpu_gtt_mgr_free_entries(struct amdgpu_gtt_mgr *mgr,
>> +				 struct drm_mm_node *mm_node)
>> +{
>> +	spin_lock(&mgr->lock);
>> +	if (drm_mm_node_allocated(mm_node))
>> +		drm_mm_remove_node(mm_node);
>> +	spin_unlock(&mgr->lock);
>> +}
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> index 72488124aa59..28511e66d364 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> @@ -141,6 +141,13 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
>>   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
>>   void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
>>   
>> +int amdgpu_gtt_mgr_alloc_entries(struct amdgpu_gtt_mgr *mgr,
>> +				 struct drm_mm_node *node,
>> +				 u64 num_pages, u64 alignment,
>> +				 unsigned long color,
>> +				 enum drm_mm_insert_mode mode);
>> +void amdgpu_gtt_mgr_free_entries(struct amdgpu_gtt_mgr *mgr,
>> +				 struct drm_mm_node *mm_node);
>>   uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
>>   
>>   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);


  reply	other threads:[~2025-12-15 15:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 23:43 [PATCH v5 0/6] drm/amdkfd: Move gfx9 MQD to HBM Philip Yang
2025-12-09 23:43 ` [PATCH v5 1/6] drm/amdgpu: Fix gfx9 update PTE mtype flag Philip Yang
2025-12-09 23:43 ` [PATCH v5 2/6] drm/amdkfd: Bind MQD in GART with mtype RW Philip Yang
2025-12-09 23:43 ` [PATCH v5 3/6] drm/amdkfd: Add domain parameter to alloc kernel BO Philip Yang
2025-12-09 23:43 ` [PATCH v5 4/6] drm/amdkfd: Move gfx9 MQD to VRAM domain Philip Yang
2025-12-09 23:43 ` [PATCH v5 5/6] drm/amdgpu: Add helper to alloc GART entries Philip Yang
2025-12-10 12:57   ` Pierre-Eric Pelloux-Prayer
2025-12-10 14:05     ` Philip Yang
2025-12-15 15:14   ` Christian König
2025-12-15 15:50     ` Philip Yang [this message]
2025-12-09 23:43 ` [PATCH v5 6/6] drm/amdkfd: Map VRAM MQD on GART Philip Yang
2025-12-15 15:20   ` Christian König
2025-12-15 16:35     ` Philip Yang

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=65a58cd1-27e5-4c09-8802-a58a456fde77@amd.com \
    --to=yangp@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Philip.Yang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=david.yatsin@amd.com \
    --cc=kent.russell@amd.com \
    --cc=pierre-eric.pelloux-prayer@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.