mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 02:44:41 +01:00
drm/amdgpu: Add helper to alloc GART entries
Add helper amdgpu_gtt_mgr_alloc/free_entries, define GART_ENTRY_WITHOUT_BO_COLOR color for GART node not allocated with GTT bo, then amdgpu_gtt_mgr_recover skip those mm_node. Signed-off-by: Philip Yang <Philip.Yang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
ec9243d1b4
commit
698fa62f56
2 changed files with 54 additions and 0 deletions
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "amdgpu.h"
|
||||
|
||||
#define GART_ENTRY_WITHOUT_BO_COLOR 1
|
||||
|
||||
static inline struct amdgpu_gtt_mgr *
|
||||
to_gtt_mgr(struct ttm_resource_manager *man)
|
||||
{
|
||||
|
|
@ -180,6 +182,49 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
|
|||
kfree(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_gtt_mgr_alloc_entries - alloc GART entries without GTT bo
|
||||
*
|
||||
* @mgr: The GTT manager object
|
||||
* @mm_node: The drm mm node to return the new allocation node information
|
||||
* @num_pages: The number of pages for the new allocation
|
||||
* @mode: The new allocation mode
|
||||
*
|
||||
* Helper to dynamic alloc GART entries to map memory not accociated with
|
||||
* GTT BO, for example VRAM BO physical memory, remote physical memory.
|
||||
*/
|
||||
int amdgpu_gtt_mgr_alloc_entries(struct amdgpu_gtt_mgr *mgr,
|
||||
struct drm_mm_node *mm_node,
|
||||
u64 num_pages,
|
||||
enum drm_mm_insert_mode mode)
|
||||
{
|
||||
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, mm_node, num_pages,
|
||||
0, GART_ENTRY_WITHOUT_BO_COLOR, 0,
|
||||
adev->gmc.gart_size >> PAGE_SHIFT,
|
||||
mode);
|
||||
spin_unlock(&mgr->lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_gtt_mgr_free_entries - free GART entries not accocaited with GTT bo
|
||||
*
|
||||
* @mgr: The GTT manager object
|
||||
* @mm_node: The drm mm node to free
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_gtt_mgr_recover - re-init gart
|
||||
*
|
||||
|
|
@ -196,6 +241,9 @@ void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
|
|||
adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
|
||||
spin_lock(&mgr->lock);
|
||||
drm_mm_for_each_node(mm_node, &mgr->mm) {
|
||||
if (mm_node->color == GART_ENTRY_WITHOUT_BO_COLOR)
|
||||
continue;
|
||||
|
||||
node = container_of(mm_node, typeof(*node), mm_nodes[0]);
|
||||
amdgpu_ttm_recover_gart(node->base.bo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,12 @@ 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 *mm_node,
|
||||
u64 num_pages,
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue